[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Mar 10 22:56:01 UTC 2021


The branch, master has been updated
       via  65510204d41 smbd: Ensure errno is preserved across fsp destructor
       via  b659ec940c7 python: Disable calls to _dsdb_garbage_collect_tombstones without addc
       via  fed09b307f6 samba-tool: Enable pydns without ad dc
       via  a7897cc6cd5 samba-tool: Enable pydsdb without ad dc
       via  e5e39a836ae python: Test samdb import
      from  bb17b4e1bbd ldb: dn tests use cmocka print functions

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


- Log -----------------------------------------------------------------
commit 65510204d4123b1825ea57607e84ba50f8ce3baf
Author: Sachin Prabhu <sprabhu at redhat.com>
Date:   Wed Mar 10 12:22:07 2021 +0000

    smbd: Ensure errno is preserved across fsp destructor
    
    The errno can be overwritten by the calls made by the fsp destructor.
    This can cause problems if the original errno was required by subsequent
    calls.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Signed-off-by: Sachin Prabhu <sprabhu at redhat.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Wed Mar 10 22:55:17 UTC 2021 on sn-devel-184

commit b659ec940c7515bc46e3f984be7554cdcdf840a0
Author: David Mulder <dmulder at suse.com>
Date:   Thu Dec 3 17:32:09 2020 +0000

    python: Disable calls to _dsdb_garbage_collect_tombstones without addc
    
    dsdb._dsdb_garbage_collect_tombstones isn't
    built without the addc, so ignore calls to it
    in samdb.
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit fed09b307f6fcdf3189a02f34c9a4c1ba243e586
Author: David Mulder <dmulder at suse.com>
Date:   Thu Sep 17 13:27:41 2020 -0600

    samba-tool: Enable pydns without ad dc
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a7897cc6cd5ba2df57d354c71b625e98be2a3243
Author: David Mulder <dmulder at suse.com>
Date:   Thu Sep 17 13:27:14 2020 -0600

    samba-tool: Enable pydsdb without ad dc
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit e5e39a836ae3ae8d8d9d338be67d2299390473be
Author: David Mulder <dmulder at suse.com>
Date:   Mon Dec 7 07:39:00 2020 -0700

    python: Test samdb import
    
    Signed-off-by: David Mulder <dmulder at suse.com>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 python/samba/samdb.py                        |  5 +++++
 python/samba/tests/{policy.py => imports.py} | 29 +++++++++++++---------------
 source3/smbd/files.c                         |  3 +++
 source4/dns_server/wscript_build             |  3 +--
 source4/dsdb/pydsdb.c                        |  4 ++++
 source4/dsdb/wscript_build                   |  3 +--
 source4/selftest/tests.py                    |  4 ++++
 7 files changed, 31 insertions(+), 20 deletions(-)
 copy python/samba/tests/{policy.py => imports.py} (56%)


Changeset truncated at 500 lines:

diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index f95709ab7c8..292bee14da3 100644
--- a/python/samba/samdb.py
+++ b/python/samba/samdb.py
@@ -34,6 +34,7 @@ from samba.dcerpc import drsblobs, misc
 from samba.common import normalise_int32
 from samba.common import get_bytes, cmp
 from samba.dcerpc import security
+from samba import is_ad_dc_built
 import binascii
 
 __docformat__ = "restructuredText"
@@ -1369,6 +1370,10 @@ schemaUpdateNow: 1
         '''garbage_collect_tombstones(lp, samdb, [dn], current_time, tombstone_lifetime)
         -> (num_objects_expunged, num_links_expunged)'''
 
+        if not is_ad_dc_built():
+            raise SamDBError('Cannot garbage collect tombstones: ' \
+                'AD DC was not built')
+
         if tombstone_lifetime is None:
             return dsdb._dsdb_garbage_collect_tombstones(self, dn,
                                                          current_time)
diff --git a/python/samba/tests/policy.py b/python/samba/tests/imports.py
similarity index 56%
copy from python/samba/tests/policy.py
copy to python/samba/tests/imports.py
index 4029150c752..727f529ea9d 100644
--- a/python/samba/tests/policy.py
+++ b/python/samba/tests/imports.py
@@ -1,5 +1,5 @@
-# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2010
+# Unix SMB/CIFS implementation. Tests for python imports
+# Copyright (C) David Mulder <dmulder at samba.org> 2020
 #
 # 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
@@ -14,21 +14,18 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
-
-"""Tests for the libpolicy Python bindings.
-
-"""
-
 from samba.tests import TestCase
-from samba import policy
-
 
-class PolicyTests(TestCase):
+class PyImportsTestCase(TestCase):
+    def setUp(self):
+        super().setUp()
 
-    def test_get_gpo_flags(self):
-        self.assertEqual(["GPO_FLAG_USER_DISABLE"],
-                          policy.get_gpo_flags(policy.GPO_FLAG_USER_DISABLE))
+    def tearDown(self):
+        super().tearDown()
 
-    def test_get_gplink_options(self):
-        self.assertEqual(["GPLINK_OPT_DISABLE"],
-                          policy.get_gplink_options(policy.GPLINK_OPT_DISABLE))
+    def test_samdb_import(self):
+        try:
+            from samba import dsdb, dsdb_dns
+            from samba import samdb
+        except ImportError as e:
+            self.fail('Failed to import samdb from samba: %s' % str(e))
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 8e01815531d..b13d151a876 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -358,10 +358,12 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname)
 {
 	struct files_struct *fsp = smb_fname->fsp;
 	NTSTATUS status;
+	int saved_errno = errno;
 
 	destroy_fsp_smb_fname_link(&smb_fname->fsp_link);
 
 	if (fsp == NULL) {
+		errno = saved_errno;
 		return 0;
 	}
 
@@ -380,6 +382,7 @@ static int smb_fname_fsp_destructor(struct smb_filename *smb_fname)
 	file_free(NULL, fsp);
 	smb_fname->fsp = NULL;
 
+	errno = saved_errno;
 	return 0;
 }
 
diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index e97c85de44a..85ffb4c7b2f 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -103,5 +103,4 @@ bld.SAMBA_PYTHON('python_dsdb_dns',
                  source='pydns.c',
                  deps='samdb %s %s dnsserver_common %s' % (
                      pyldb_util, pyrpc_util, pytalloc_util),
-                 realname='samba/dsdb_dns.so',
-                 enabled=bld.AD_DC_BUILD_IS_ENABLED())
+                 realname='samba/dsdb_dns.so')
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index b68d76ada49..95b23d8adc3 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -1168,6 +1168,7 @@ static PyObject *py_dsdb_allocate_rid(PyObject *self, PyObject *args)
 	return PyLong_FromLong(rid);
 }
 
+#ifdef AD_DC_BUILD_IS_ENABLED
 static PyObject *py_dns_delete_tombstones(PyObject *self, PyObject *args)
 {
 	PyObject *py_ldb;
@@ -1333,6 +1334,7 @@ static PyObject *py_dsdb_garbage_collect_tombstones(PyObject *self, PyObject *ar
 	return Py_BuildValue("(II)", num_objects_removed,
 			    num_links_removed);
 }
+#endif
 
 static PyObject *py_dsdb_load_udv_v2(PyObject *self, PyObject *args)
 {
@@ -1466,6 +1468,7 @@ static PyMethodDef py_dsdb_methods[] = {
 	{ "_dsdb_get_wellknown_dn", (PyCFunction)py_dsdb_get_wellknown_dn, METH_VARARGS, NULL },
 	{ "_dsdb_DsReplicaAttribute", (PyCFunction)py_dsdb_DsReplicaAttribute, METH_VARARGS, NULL },
 	{ "_dsdb_normalise_attributes", (PyCFunction)py_dsdb_normalise_attributes, METH_VARARGS, NULL },
+#ifdef AD_DC_BUILD_IS_ENABLED
 	{ "_dsdb_garbage_collect_tombstones", (PyCFunction)py_dsdb_garbage_collect_tombstones, METH_VARARGS,
 		"_dsdb_kcc_check_deleted(samdb, [dn], current_time, tombstone_lifetime)"
 		" -> (num_objects_expunged, num_links_expunged)" },
@@ -1473,6 +1476,7 @@ static PyMethodDef py_dsdb_methods[] = {
 		METH_VARARGS, NULL},
 	{ "_dns_delete_tombstones", (PyCFunction)py_dns_delete_tombstones,
 		METH_VARARGS, NULL},
+#endif
 	{ "_dsdb_create_own_rid_set", (PyCFunction)py_dsdb_create_own_rid_set, METH_VARARGS,
 		"_dsdb_create_own_rid_set(samdb)"
 		" -> None" },
diff --git a/source4/dsdb/wscript_build b/source4/dsdb/wscript_build
index dbe58859a14..0238ea2e2d7 100644
--- a/source4/dsdb/wscript_build
+++ b/source4/dsdb/wscript_build
@@ -79,6 +79,5 @@ bld.SAMBA_PYTHON('python_dsdb',
                  # removes it so we end up with unresolved symbols.
                  deps='samdb %s dcerpc com_err %s %s dsdb_garbage_collect_tombstones scavenge_dns_records' %\
                  (pyldb_util, pyrpc_util, pyparam_util),
-                 realname='samba/dsdb.so',
-                 enabled=bld.AD_DC_BUILD_IS_ENABLED()
+                 realname='samba/dsdb.so'
                  )
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index bc8fea83474..a0afe76e8d9 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -809,6 +809,10 @@ planoldpythontestsuite("ad_dc:local", "samba.tests.gpo", extra_args=['-U"$USERNA
 planoldpythontestsuite("ad_member", "samba.tests.gpo_member", extra_args=['-U"$USERNAME%$PASSWORD"'])
 planoldpythontestsuite("ad_dc:local", "samba.tests.dckeytab", extra_args=['-U"$USERNAME%$PASSWORD"'])
 
+# Run the import test in environments that may not have the ad-dc built
+for env in ['fileserver_smb1', 'nt4_member', 'clusteredmember', 'ktest', 'nt4_dc', 'nt4_dc_smb1_done', 'nt4_dc_smb1', 'simpleserver', 'fileserver_smb1_done', 'fileserver', 'maptoguest', 'nt4_dc_schannel']:
+    planoldpythontestsuite(env, "samba.tests.imports")
+
 planoldpythontestsuite("none", "samba.tests.krb5.kcrypto")
 planoldpythontestsuite("ad_dc_default", "samba.tests.krb5.simple_tests",
                        environ={'SERVICE_USERNAME':'$SERVER'})


-- 
Samba Shared Repository



More information about the samba-cvs mailing list