1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

python SamDB: init default flags to FLG_DONT_CREATE_DB

The current defaults for SamDB are to create the database file if it does not
exist.  Most of the uses of SamDB assume the database already exists, and so
auto-creation is not the desired behaviour.

TDB will overwrite an existing non TDB file with a newly created TDB file.
This becomes an issue when using alternate database file formats i.e. lmdb.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Gary Lockyer 2018-01-09 07:43:18 +13:00 committed by Andrew Bartlett
parent 736e438bf4
commit 7009479b7a
3 changed files with 8 additions and 4 deletions

View File

@ -42,7 +42,8 @@ class SamDB(samba.Ldb):
hash_well_known = {}
def __init__(self, url=None, lp=None, modules_dir=None, session_info=None,
credentials=None, flags=0, options=None, global_schema=True,
credentials=None, flags=ldb.FLG_DONT_CREATE_DB,
options=None, global_schema=True,
auto_connect=True, am_rodc=None):
self.lp = lp
if not auto_connect:

View File

@ -138,7 +138,12 @@ def get_ldbs(paths, creds, session, lp):
ldbs = ProvisionLDB()
ldbs.sam = SamDB(paths.samdb, session_info=session, credentials=creds, lp=lp, options=["modules:samba_dsdb"])
ldbs.sam = SamDB(paths.samdb,
session_info=session,
credentials=creds,
lp=lp,
options=["modules:samba_dsdb"],
flags=0)
ldbs.secrets = Ldb(paths.secrets, session_info=session, credentials=creds, lp=lp)
ldbs.idmap = Ldb(paths.idmapdb, session_info=session, credentials=creds, lp=lp)
ldbs.privilege = Ldb(paths.privilege, session_info=session, credentials=creds, lp=lp)

View File

@ -1,2 +0,0 @@
^samba.tests.samdb_api.samba.tests.samdb_api.SamDBApiTestCase.test_dont_create_db_existing_non_tdb_file\(none\)
^samba.tests.samdb_api.samba.tests.samdb_api.SamDBApiTestCase.test_dont_create_db_new_file\(none\)