mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
provision: Properly cancel transactions on the secrets ldb.
This commit is contained in:
@ -749,7 +749,8 @@ def secretsdb_setup_dns(secretsdb, setup_path, private_dir,
|
||||
|
||||
def setup_secretsdb(path, setup_path, session_info, backend_credentials, lp):
|
||||
"""Setup the secrets database.
|
||||
This function does not handle exceptions and transaction on purpose,
|
||||
|
||||
:note: This function does not handle exceptions and transaction on purpose,
|
||||
it's up to the caller to do this job.
|
||||
|
||||
:param path: Path to the secrets database.
|
||||
@ -768,6 +769,7 @@ def setup_secretsdb(path, setup_path, session_info, backend_credentials, lp):
|
||||
secrets_ldb = Ldb(path, session_info=session_info,
|
||||
lp=lp)
|
||||
secrets_ldb.transaction_start()
|
||||
try:
|
||||
secrets_ldb.load_ldif_file_add(setup_path("secrets.ldif"))
|
||||
|
||||
if backend_credentials is not None and backend_credentials.authentication_requested():
|
||||
@ -784,6 +786,9 @@ def setup_secretsdb(path, setup_path, session_info, backend_credentials, lp):
|
||||
})
|
||||
|
||||
return secrets_ldb
|
||||
except:
|
||||
secrets_ldb.transaction_cancel()
|
||||
raise
|
||||
|
||||
def setup_privileges(path, setup_path, session_info, lp):
|
||||
"""Setup the privileges database.
|
||||
@ -1398,6 +1403,7 @@ def provision(setup_dir, logger, session_info,
|
||||
session_info=session_info,
|
||||
backend_credentials=provision_backend.secrets_credentials, lp=lp)
|
||||
|
||||
try:
|
||||
logger.info("Setting up the registry")
|
||||
setup_registry(paths.hklm, setup_path, session_info,
|
||||
lp=lp)
|
||||
@ -1510,6 +1516,9 @@ def provision(setup_dir, logger, session_info,
|
||||
|
||||
create_phpldapadmin_config(paths.phpldapadminconfig, setup_path,
|
||||
ldapi_url)
|
||||
except:
|
||||
secrets_ldb.transaction_cancel()
|
||||
raise
|
||||
|
||||
#Now commit the secrets.ldb to disk
|
||||
secrets_ldb.transaction_commit()
|
||||
|
Reference in New Issue
Block a user