diff options
author | Matthieu Patou <mat@matws.net> | 2010-01-15 14:09:06 +0300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-01-21 07:11:21 +1300 |
commit | 8c6fc09f18757e49e90936266fa763e0267d2e57 (patch) | |
tree | d1c38fc3bd0a97f01214aaed9d4bb07c65793932 | |
parent | 929dbf8ef817cb1646a5f82b9a0f0eece4ab84ee (diff) | |
download | samba-8c6fc09f18757e49e90936266fa763e0267d2e57.tar.gz samba-8c6fc09f18757e49e90936266fa763e0267d2e57.tar.bz2 samba-8c6fc09f18757e49e90936266fa763e0267d2e57.zip |
upgradeprovision: forbid running upgradeprovision when there is more than 1 DC
-rwxr-xr-x | source4/scripting/bin/upgradeprovision | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision index 1c70e377ae..e2ee8d053f 100755 --- a/source4/scripting/bin/upgradeprovision +++ b/source4/scripting/bin/upgradeprovision @@ -189,6 +189,23 @@ def get_paths(targetdir=None,smbconf=None): paths = provision_paths_from_lp(lp,"foo") return paths + +def sanitychecks(credentials,session_info,names,paths): + sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp,options=["modules:samba_dsdb"]) + # First update the SD for the rootdn + sam_ldb.set_session_info(session) + res = sam_ldb.search(expression="objectClass=ntdsdsa",base=str(names.configdn), scope=SCOPE_SUBTREE,attrs=["dn"],controls=["search_options:1:2"]) + if len(res) == 0: + print "No DC found, your provision is most probalby hardly broken !" + return 0 + elif len(res) != 1: + print "Found %d domain controllers, for the moment upgradeprovision is not able to handle upgrade on \ +domain with more than one DC, please demote the other DC before upgrading"%len(res) + return 0 + else: + return 1 + + # This function guesses (fetches) informations needed to make a fresh provision # from the current provision # It includes: realm, workgroup, partitions, netbiosname, domain guid, ... @@ -891,6 +908,9 @@ def setup_path(file): # Guess all the needed names (variables in fact) from the current # provision. names = guess_names_from_current_provision(creds,session,paths) +if not sanitychecks(creds,session,names,paths): + print "Sanity checks for the upgrade fails, checks messages and correct it before rerunning upgradeprovision" + sys.exit(1) # Let's see them print_names(names) # With all this information let's create a fresh new provision used as reference |