[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Feb 8 03:43:02 UTC 2018


The branch, master has been updated
       via  a3485c4 ctdb-tests: Set test timeout to an hour
       via  7009479 python SamDB: init default flags to FLG_DONT_CREATE_DB
       via  736e438 pyldb: Expose extra flags
       via  a157091 samdb: Add tests for samdb tdb file creation.
       via  b96b51f lib/crypto: Update REQUIREMENTS for recent Samba changes
      from  701b2ed WHATSNEW: Start release notes for Samba 4.9.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a3485c41b826e307b31a1113abcea9843ca78540
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 5 15:45:09 2018 +1100

    ctdb-tests: Set test timeout to an hour
    
    The current 10 minute timeout is causing autobuild failures in some
    environments.
    
    This timeout is simply meant to stop a test run from hanging
    indefinitely due to a broken test.  A 1 hour timeout is better than no
    timeout.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Feb  8 04:42:56 CET 2018 on sn-devel-144

commit 7009479b7a91715543e228412435ab2fdb6221ae
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jan 9 07:43:18 2018 +1300

    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 at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 736e438bf44d84d30d8d5091a3f915ef307a6b45
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Jan 9 07:41:32 2018 +1300

    pyldb: Expose extra flags
    
    Expose the SHOW_BINARY, ENABLE_TRACING and DONT_CREATE_DB flag constants
    in the python api.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a157091a22446fd60830d5f352e44c6bad9264ba
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Wed Feb 7 14:59:21 2018 +1300

    samdb: Add tests for samdb tdb file creation.
    
    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.
    
    Also 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 at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b96b51fa95ca3723dfb0a86d5186f5b8a3485a99
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Feb 8 10:49:33 2018 +1300

    lib/crypto: Update REQUIREMENTS for recent Samba changes
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/tests/run_tests.sh         |   2 +-
 lib/crypto/REQUIREMENTS         |   2 +-
 lib/ldb/pyldb.c                 |   4 +
 python/samba/samdb.py           |   3 +-
 python/samba/tests/samdb_api.py | 158 ++++++++++++++++++++++++++++++++++++++++
 python/samba/upgradehelpers.py  |   7 +-
 selftest/tests.py               |   1 +
 7 files changed, 173 insertions(+), 4 deletions(-)
 create mode 100644 python/samba/tests/samdb_api.py


Changeset truncated at 500 lines:

diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh
index a2a44a1..a7ca44e 100755
--- a/ctdb/tests/run_tests.sh
+++ b/ctdb/tests/run_tests.sh
@@ -45,7 +45,7 @@ export TEST_LOCAL_DAEMONS
 [ -n "$TEST_LOCAL_DAEMONS" ] || TEST_LOCAL_DAEMONS=3
 export TEST_VAR_DIR=""
 export TEST_CLEANUP=false
-export TEST_TIMEOUT=600
+export TEST_TIMEOUT=3600
 export TEST_SOCKET_WRAPPER_SO_PATH=""
 
 temp=$(getopt -n "$prog" -o "AcCdDehHNqS:T:vV:xX" -l help -- "$@")
diff --git a/lib/crypto/REQUIREMENTS b/lib/crypto/REQUIREMENTS
index 5e02aea..3cd8a15 100644
--- a/lib/crypto/REQUIREMENTS
+++ b/lib/crypto/REQUIREMENTS
@@ -16,7 +16,6 @@ ARCFOUR (RC4)
  - Password encryption on SAMR for password set/get
  - NETLOGON SamLogon session keys
  - Schannel
- - generate_random_data()
 
  # GNUTLS >= 3.0.0
  # NETTLE
@@ -60,6 +59,7 @@ AES128 CCM
 
 AES128 GCM
  - SMB2 3.10 SMB encryption
+ - encrypted_secrets ldb module (encrypt secrets within sam.ldb)
 
  # GNUTLS >= 3.0.0
  # NETTLE (AES-NI available)
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 04b3f1b..4b02edb 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -4226,6 +4226,10 @@ static PyObject* module_init(void)
 	ADD_LDB_INT(FLG_NOSYNC);
 	ADD_LDB_INT(FLG_RECONNECT);
 	ADD_LDB_INT(FLG_NOMMAP);
+	ADD_LDB_INT(FLG_SHOW_BINARY);
+	ADD_LDB_INT(FLG_ENABLE_TRACING);
+	ADD_LDB_INT(FLG_DONT_CREATE_DB);
+
 
 	/* Historical misspelling */
 	PyModule_AddIntConstant(m, "ERR_ALIAS_DEREFERINCING_PROBLEM", LDB_ERR_ALIAS_DEREFERENCING_PROBLEM);
diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index 4645629..82eb7a4 100644
--- a/python/samba/samdb.py
+++ b/python/samba/samdb.py
@@ -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:
diff --git a/python/samba/tests/samdb_api.py b/python/samba/tests/samdb_api.py
new file mode 100644
index 0000000..81c6266
--- /dev/null
+++ b/python/samba/tests/samdb_api.py
@@ -0,0 +1,158 @@
+# Tests for the samba samdb api
+#
+# Copyright (C) Andrew Bartlett <abartlet at samba.org> 2018
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from samba.tests import TestCaseInTempDir
+from samba.samdb import SamDB
+from ldb import LdbError, ERR_OPERATIONS_ERROR
+import os
+import errno
+
+
+class SamDBApiTestCase(TestCaseInTempDir):
+
+    def setUp(self):
+        super(SamDBApiTestCase, self).setUp()
+
+    def tearDown(self):
+        try:
+            os.remove(self.tempdir + "/test.db")
+        except OSError as e:
+            self.assertEquals(e.errno, errno.ENOENT)
+
+        try:
+            os.remove(self.tempdir + "/existing.db")
+        except OSError as e:
+            self.assertEquals(e.errno, errno.ENOENT)
+
+        super(SamDBApiTestCase, self).tearDown()
+
+    # Attempt to open and existing non tdb file as a tdb file.
+    # Don't create new db is set, the default
+    #
+    # Should fail to open
+    # And the existing file should be left intact.
+    #
+    def test_dont_create_db_existing_non_tdb_file(self):
+        existing_name = self.tempdir + "/existing.db"
+        existing = open(existing_name, "w")
+        existing.write("This is not a tdb file!!!!!!\n")
+        existing.close()
+
+        try:
+            SamDB(url="tdb://" + existing_name)
+            self.fail("Exception not thrown ")
+        except LdbError as (err, _):
+            self.assertEquals(err, ERR_OPERATIONS_ERROR)
+
+        existing = open(existing_name, "r")
+        contents = existing.readline()
+        self.assertEquals("This is not a tdb file!!!!!!\n", contents)
+
+    # Attempt to open and existing non tdb file as a tdb file.
+    # Don't create new db is cleared
+    #
+    # Should open as a tdb file
+    # And the existing file should be over written
+    #
+    def test_create_db_existing_file_non_tdb_file(self):
+        existing_name = self.tempdir + "/existing.db"
+        existing = open(existing_name, "w")
+        existing.write("This is not a tdb file!!!!!!")
+        existing.close()
+
+        SamDB(url="tdb://" + existing_name, flags=0)
+
+        existing = open(existing_name, "r")
+        contents = existing.readline()
+        self.assertEquals("TDB file\n", contents)
+
+    #
+    # Attempt to open an existing tdb file as a tdb file.
+    # Don't create new db is set, the default
+    #
+    # Should open successfully
+    # And the existing file should be left intact.
+    #
+    def test_dont_create_db_existing_tdb_file(self):
+        existing_name = self.tempdir + "/existing.db"
+        initial = SamDB(url="tdb://" + existing_name, flags=0)
+        dn = "dn=,cn=test_dont_create_db_existing_tdb_file"
+        initial.add({
+            "dn": dn,
+            "cn": "test_dont_create_db_existing_tdb_file"
+        })
+
+        cn = initial.searchone("cn", dn)
+        self.assertEquals("test_dont_create_db_existing_tdb_file", cn)
+
+        second = SamDB(url="tdb://" + existing_name)
+        cn = second.searchone("cn", dn)
+        self.assertEquals("test_dont_create_db_existing_tdb_file", cn)
+
+    #
+    # Attempt to open an existing tdb file as a tdb file.
+    # Don't create new db is explicitly cleared
+    #
+    # Should open successfully
+    # And the existing file should be left intact.
+    #
+    def test_create_db_existing_file_tdb_file(self):
+        existing_name = self.tempdir + "/existing.db"
+        initial = SamDB(url="tdb://" + existing_name, flags=0)
+        dn = "dn=,cn=test_dont_create_db_existing_tdb_file"
+        initial.add({
+            "dn": dn,
+            "cn": "test_dont_create_db_existing_tdb_file"
+        })
+
+        cn = initial.searchone("cn", dn)
+        self.assertEquals("test_dont_create_db_existing_tdb_file", cn)
+
+        second = SamDB(url="tdb://" + existing_name, flags=0)
+        cn = second.searchone("cn", dn)
+        self.assertEquals("test_dont_create_db_existing_tdb_file", cn)
+
+    # Open a non existent TDB file.
+    # Don't create new db is set, the default
+    #
+    # Should fail
+    # and the database file should not be created
+    def test_dont_create_db_new_file(self):
+        try:
+            SamDB(url="tdb://" + self.tempdir + "/test.db")
+            self.fail("Exception not thrown ")
+        except LdbError as (err, _):
+            self.assertEquals(err, ERR_OPERATIONS_ERROR)
+
+        try:
+            file = open(self.tempdir + "/test.db", "r")
+            self.fail("New database file created")
+        except IOError as e:
+            self.assertEquals(e.errno, errno.ENOENT)
+
+
+    # Open a SamDB with the don't create new DB flag cleared.
+    # The underlying database file does not exist.
+    #
+    # Should successful open the SamDB creating a new database file.
+    #
+    def test_create_db_new_file(self):
+        SamDB(url="tdb://" + self.tempdir + "/test.db", flags=0)
+        existing = open(self.tempdir + "/test.db", "r")
+        contents = existing.readline()
+        self.assertEquals("TDB file\n", contents)
diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py
index e026262..9f017bc 100644
--- a/python/samba/upgradehelpers.py
+++ b/python/samba/upgradehelpers.py
@@ -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/tests.py b/selftest/tests.py
index b2d1a67..ec48b03 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -154,6 +154,7 @@ planpythontestsuite("none", "samba.tests.graph")
 plantestsuite("wafsamba.duplicate_symbols", "none", [os.path.join(srcdir(), "buildtools/wafsamba/test_duplicate_symbol.sh")])
 planpythontestsuite("none", "samba.tests.glue", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.tdb_util", py3_compatible=True)
+planpythontestsuite("none", "samba.tests.samdb_api")
 
 if with_pam:
     plantestsuite("samba.tests.pam_winbind(local)", "ad_member",


-- 
Samba Shared Repository



More information about the samba-cvs mailing list