mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
samba-tool domain classicupgrade: Do not mix python-samdb transactions and passdb modifications
This worked previously because we knew the same tdb was in use under the hood, but now that nested TDB transactions are banned this breaks, and it breaks for LMDB. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
parent
f8b368c9f0
commit
5dc7db5786
@ -785,38 +785,28 @@ Please fix this account before attempting to upgrade again
|
||||
result.samdb.transaction_commit()
|
||||
|
||||
logger.info("Adding users")
|
||||
# Start a new transaction (should speed this up a little, due to index churn)
|
||||
result.samdb.transaction_start()
|
||||
|
||||
try:
|
||||
# Export users to samba4 backend
|
||||
logger.info("Importing users")
|
||||
for username in userdata:
|
||||
if username.lower() == 'administrator':
|
||||
if userdata[username].user_sid != dom_sid(str(domainsid) + "-500"):
|
||||
logger.error("User 'Administrator' in your existing directory has SID %s, expected it to be %s" % (userdata[username].user_sid, dom_sid(str(domainsid) + "-500")))
|
||||
raise ProvisioningError("User 'Administrator' in your existing directory does not have SID ending in -500")
|
||||
if username.lower() == 'root':
|
||||
if userdata[username].user_sid == dom_sid(str(domainsid) + "-500"):
|
||||
logger.warn('User root has been replaced by Administrator')
|
||||
else:
|
||||
logger.warn('User root has been kept in the directory, it should be removed in favour of the Administrator user')
|
||||
# Export users to samba4 backend
|
||||
logger.info("Importing users")
|
||||
for username in userdata:
|
||||
if username.lower() == 'administrator':
|
||||
if userdata[username].user_sid != dom_sid(str(domainsid) + "-500"):
|
||||
logger.error("User 'Administrator' in your existing directory has SID %s, expected it to be %s" % (userdata[username].user_sid, dom_sid(str(domainsid) + "-500")))
|
||||
raise ProvisioningError("User 'Administrator' in your existing directory does not have SID ending in -500")
|
||||
if username.lower() == 'root':
|
||||
if userdata[username].user_sid == dom_sid(str(domainsid) + "-500"):
|
||||
logger.warn('User root has been replaced by Administrator')
|
||||
else:
|
||||
logger.warn('User root has been kept in the directory, it should be removed in favour of the Administrator user')
|
||||
|
||||
s4_passdb.add_sam_account(userdata[username])
|
||||
if username in uids:
|
||||
add_ad_posix_idmap_entry(result.samdb, userdata[username].user_sid, uids[username], "ID_TYPE_UID", logger)
|
||||
if (username in homes) and (homes[username] is not None) and \
|
||||
(username in shells) and (shells[username] is not None) and \
|
||||
(username in pgids) and (pgids[username] is not None):
|
||||
add_posix_attrs(samdb=result.samdb, sid=userdata[username].user_sid, name=username, nisdomain=domainname.lower(), xid_type="ID_TYPE_UID", home=homes[username], shell=shells[username], pgid=pgids[username], logger=logger)
|
||||
s4_passdb.add_sam_account(userdata[username])
|
||||
if username in uids:
|
||||
add_ad_posix_idmap_entry(result.samdb, userdata[username].user_sid, uids[username], "ID_TYPE_UID", logger)
|
||||
if (username in homes) and (homes[username] is not None) and \
|
||||
(username in shells) and (shells[username] is not None) and \
|
||||
(username in pgids) and (pgids[username] is not None):
|
||||
add_posix_attrs(samdb=result.samdb, sid=userdata[username].user_sid, name=username, nisdomain=domainname.lower(), xid_type="ID_TYPE_UID", home=homes[username], shell=shells[username], pgid=pgids[username], logger=logger)
|
||||
|
||||
except:
|
||||
# We need this, so that we do not give even more errors due to not cancelling the transaction
|
||||
result.samdb.transaction_cancel()
|
||||
raise
|
||||
|
||||
logger.info("Committing 'add users' transaction to disk")
|
||||
result.samdb.transaction_commit()
|
||||
|
||||
logger.info("Adding users to groups")
|
||||
# Start a new transaction (should speed this up a little, due to index churn)
|
||||
|
Loading…
x
Reference in New Issue
Block a user