python SamDB: init default flags to FLG_DONT_CREATE_DB
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 8 Jan 2018 18:43:18 +0000 (07:43 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 7 Feb 2018 22:45:23 +0000 (23:45 +0100)
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>
python/samba/samdb.py
python/samba/upgradehelpers.py
selftest/knownfail.d/samdb [deleted file]

index 46456290c9ef2e203ca6e3a58f73f9d401bb275c..82eb7a4ef4cf2c3321deccbf23fa05186bce8855 100644 (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:
index e026262b9a7b6430e7021c275b4d19d96c41f126..9f017bce594ce0c22fb68ec0e59e1c04003a78d8 100644 (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)
diff --git a/selftest/knownfail.d/samdb b/selftest/knownfail.d/samdb
deleted file mode 100644 (file)
index 6a4ab97..0000000
+++ /dev/null
@@ -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\)