1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

upgrade: Properly cancel/commit transactions in a couple more places.

This commit is contained in:
Jelmer Vernooij
2010-06-13 15:13:12 +02:00
parent 956a256faa
commit 3552ad3ab1
2 changed files with 133 additions and 120 deletions

View File

@ -580,13 +580,17 @@ def check_diff_name(newpaths, paths, creds, session, basedn, names, ischema):
newsam_ldb = Ldb(newpaths.samdb, session_info=session, credentials=creds,lp=lp)
sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp, options=["modules:samba_dsdb"])
sam_ldb.transaction_start()
try:
if ischema:
reference = newsam_ldb.search(expression="objectClass=*",base=basedn, scope=SCOPE_SUBTREE,attrs=["dn"])
current = sam_ldb.search(expression="objectClass=*",base=basedn, scope=SCOPE_SUBTREE,attrs=["dn"])
else:
reference = newsam_ldb.search(expression="objectClass=*",base=basedn, scope=SCOPE_SUBTREE,attrs=["dn"],controls=["search_options:1:2"])
current = sam_ldb.search(expression="objectClass=*",base=basedn, scope=SCOPE_SUBTREE,attrs=["dn"],controls=["search_options:1:2"])
except:
sam_ldb.transaction_cancel()
raise
else:
sam_ldb.transaction_commit()
# Create a hash for speeding the search of new object
for i in range(0,len(reference)):
@ -629,6 +633,7 @@ def check_diff_name(newpaths, paths, creds, session, basedn, names, ischema):
sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp, options=["modules:samba_dsdb"])
sam_ldb.transaction_start()
try:
# XXX: This needs to be wrapped in try/except so we
# abort on exceptions.
message(SIMPLE, "There are %d missing objects"%(len(listMissing)))
@ -678,7 +683,10 @@ def check_diff_name(newpaths, paths, creds, session, basedn, names, ischema):
message(CHANGE, "%s is different from the reference one, changed attributes: %s"%(dn,attributes))
changed = changed + 1
sam_ldb.modify(delta)
except:
sam_ldb.transaction_cancel()
raise
else:
sam_ldb.transaction_commit()
message(SIMPLE, "There are %d changed objects"%(changed))
return hashallSD
@ -724,6 +732,7 @@ def update_sd(paths, creds, session, names):
sam_ldb = Ldb(paths.samdb, session_info=session, credentials=creds,lp=lp,options=["modules:samba_dsdb"])
sam_ldb.transaction_start()
try:
# First update the SD for the rootdn
sam_ldb.set_session_info(session)
res = sam_ldb.search(expression="objectClass=*", base=str(names.rootdn), scope=SCOPE_BASE,\
@ -774,6 +783,10 @@ def update_sd(paths, creds, session, names):
attrs=["dn","nTSecurityDescriptor"], controls=["search_options:1:2"])
print "bad stuff" +ndr_unpack(security.descriptor,str(res[0]["nTSecurityDescriptor"])).as_sddl(names.domainsid)
return
except:
sam_ldb.transaction_cancel()
raise
else:
sam_ldb.transaction_commit()

View File

@ -173,7 +173,7 @@ def newprovision(names, setup_dir, creds, session, smbconf, provdir, logger):
:param session: Session object
:param smbconf: Path to the smb.conf file
:param provdir: Directory where the provision will be stored
:param messagefunc: A function for displaying the message of the provision
:param logger: A `Logger`
"""
if os.path.isdir(provdir):
shutil.rmtree(provdir)