[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Mar 21 00:46:02 UTC 2024


The branch, master has been updated
       via  8f1a80147d8 pidl: add "return ENOTSUP" for int return type in s3 template
       via  56719a5d107 pidl: fix trailing double-quote on last line of s3 server stubs
       via  efffb2484bb s3-librpc: merge two PIDL lists
       via  d13226366b2 ldb_dn: make LDB_FREE, TALLOC_FREE
       via  bf654a04675 pyldb: ldb_msg_richcmp: avoid one intransitive compare
       via  8cf77b5775a ldb:ldb_dn: use safe transitive comparison in ldb_dn_compare()
       via  118b9ec5e07 pyldb: add a FIXME for a non-transitive compare
       via  461192fdbea pyldb_utils: pyldb_Object_AsDn() sets TypeError more often
       via  e4babdfa445 ldb:pyldb.h: include some headers that are used
       via  2ed90bbfb47 lib/ldb: don't allow repeated connections
       via  d58c2c299de ldb:pytests: test duplicate connections fail
       via  c7c42762c68 ldb-samba:ldb_wrap: don't crash if "ldb_url" opaque is unset
       via  4ce132cea93 pyldb: py_ldb_init() uses py_ldb_connect() for connecting
       via  14a6109e9a2 pyldb: catch errors in ldb_db_get_casefold
       via  c17ff0a3357 pytest:segfault: do not assume PLEASE_NO_GDB_BACKTRACE var is unset
       via  5ceecd3f739 pytest:segfault: prevent @no_gdb_backtrace smearing on exception
       via  682a87fd0a8 selftest: Run samba.tests.segfault with TALLOC_FREE_FILL
       via  c04ac95ce40 py:samdb: make SamDB.__str__ show the URL and ID
       via  ecd65265ac0 selftest/gdb_backtrace: print `info threads` and some signpost headers
       via  12ce289922c selftest/gdb_backtrace: avoid printing backtrace twice with 1 thread
       via  904479cdf6d selftest/gdb_backtrace: print python traceback if available
      from  da500249fcf tests: gmsa blackbox tests

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


- Log -----------------------------------------------------------------
commit 8f1a80147d8d95c5f59f2e8c2a18bfaee29cfcf5
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 19 22:00:11 2024 +0100

    pidl: add "return ENOTSUP" for int return type in s3 template
    
    Guenther
    
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Mar 21 00:45:29 UTC 2024 on atb-devel-224

commit 56719a5d107b6590b10165347345d6b5366af755
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 19 18:24:13 2024 +0100

    pidl: fix trailing double-quote on last line of s3 server stubs
    
    Guenther
    
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit efffb2484bbf7058eec1f085bab65639c42b1656
Author: Günther Deschner <gd at samba.org>
Date:   Thu Mar 14 15:22:25 2024 +0100

    s3-librpc: merge two PIDL lists
    
    Guenther
    
    Signed-off-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit d13226366b254502125f572b8bd574709c125613
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 15 23:29:34 2024 +1300

    ldb_dn: make LDB_FREE, TALLOC_FREE
    
    This LDB_FREE() seems to predate TALLOC_FREE(), and was identical
    until TALLOC_FREE was optimised to avoid calling talloc_free(NULL) in
    b9fcfc6399eab750880ee0b9806311dd351a8ff6.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bf654a046754c1ceaf669fb7e9f36eddc3266a28
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 15 15:47:55 2024 +1300

    pyldb: ldb_msg_richcmp: avoid one intransitive compare
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 8cf77b5775a314b606bf870f99695a45cfbbd084
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 15 15:03:44 2024 +1300

    ldb:ldb_dn: use safe transitive comparison in ldb_dn_compare()
    
    The comparison we make is unconventional, and makes no difference in
    normal usage, where we just want to know whether two DNs are the same
    or not. But with over 100 callers, it is possible that something
    somewhere is attempting a sort.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 118b9ec5e075e19c79e8974beeb64dcb0392877f
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 14 16:36:07 2024 +1300

    pyldb: add a FIXME for a non-transitive compare
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 461192fdbeaafcd9d0af083d220afff3af2bdef7
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 15 12:12:26 2024 +1300

    pyldb_utils: pyldb_Object_AsDn() sets TypeError more often
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit e4babdfa4451ce251ce4632a320deb63d38003cd
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 22:29:10 2024 +1300

    ldb:pyldb.h: include some headers that are used
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2ed90bbfb4777f5948df10760342c031b5fcd081
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Wed Mar 20 12:18:12 2024 +1300

    lib/ldb: don't allow repeated connections
    
    In the best case, this would have leaked.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit d58c2c299dee35bd4fde619481509b31a0ff9215
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 11:09:39 2024 +1300

    ldb:pytests: test duplicate connections fail
    
    (they don't yet).
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c7c42762c68e9cf9af41bdaf509c14f7fd385702
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 11:07:20 2024 +1300

    ldb-samba:ldb_wrap: don't crash if "ldb_url" opaque is unset
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4ce132cea930a22c9468ecd9061e9cacace9ff0b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue Mar 5 23:57:15 2024 +0000

    pyldb: py_ldb_init() uses py_ldb_connect() for connecting
    
    To avoid all the same logic, subtly different.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 14a6109e9a254e3fe5ba1b1d153047f90b421d3b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Fri Mar 8 11:02:23 2024 +1300

    pyldb: catch errors in ldb_db_get_casefold
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c17ff0a3357f7f1d12c755b291fcce7ce4c7eb5a
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 14 14:48:23 2024 +1300

    pytest:segfault: do not assume PLEASE_NO_GDB_BACKTRACE var is unset
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 5ceecd3f739b347e684895115c5f9cd79b91f4b7
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 11:05:55 2024 +1300

    pytest:segfault: prevent @no_gdb_backtrace smearing on exception
    
    It is OK for one of these tests to raise an exception -- that is often
    the only reasonable thing to do when you'd otherwise crash -- but the
    @no_gdb_backtrace decorator would not clean up in that case, leading to
    no gdb backtraces for all subsequent tests.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 682a87fd0a81e13eabaa422d89209688b7b19098
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Dec 4 10:34:57 2023 +1300

    selftest: Run samba.tests.segfault with TALLOC_FREE_FILL
    
    This helps make use-after-free testing reliable.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit c04ac95ce404f13183688c2d0d7f1eeb0edc4c4b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 14 14:15:47 2024 +1300

    py:samdb: make SamDB.__str__ show the URL and ID
    
    Getting the right samdb is going to matter more, so it is useful for
    debugging to see which is which.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ecd65265ac05b1cf68a4378deb17f0ef08479e9b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Wed Mar 13 12:25:40 2024 +1300

    selftest/gdb_backtrace: print `info threads` and some signpost headers
    
    Search for '###'.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 12ce289922ca594384ffb9e035fcd9815e2aa331
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 23:13:56 2024 +1300

    selftest/gdb_backtrace: avoid printing backtrace twice with 1 thread
    
    We call 'thread apply all bt full' in case there are interesting
    things going on in other threads, but often there are no other threads
    and it only serves to repeat the original trace (and very slowly, for
    some reason).
    
    The $_inferior_thread_count convenience variable is new in gdb 13.1
    (2022-ish) so we init-if-undefined it to default to the old behaviour.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 904479cdf6d58142baa012a7b588fca857f275f4
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Thu Mar 7 22:30:24 2024 +1300

    selftest/gdb_backtrace: print python traceback if available
    
    If a program happens to have 'PyList_New' defined but is not a python
    script, gdb will print
    
    > Undefined command: "py-bt".  Try "help".
    
    and probably stop. This happens after the C backtraces have been
    printed, so nothing is lost.
    
    The traceback is printed twice -- once in conventional Python style
    for clarity, and once with extra "full" information.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 lib/ldb-samba/ldb_wrap.c               |  2 +-
 lib/ldb/common/ldb.c                   | 11 +++++++
 lib/ldb/common/ldb_dn.c                | 13 ++++++--
 lib/ldb/pyldb.c                        | 56 +++++++++++++++++++---------------
 lib/ldb/pyldb.h                        |  2 ++
 lib/ldb/pyldb_util.c                   |  1 +
 lib/ldb/tests/python/api.py            | 14 +++++++++
 pidl/lib/Parse/Pidl/Samba3/Template.pm |  4 ++-
 python/samba/samdb.py                  |  8 +++++
 python/samba/tests/segfault.py         | 10 ++++--
 selftest/gdb_backtrace                 | 18 ++++++++++-
 source3/librpc/idl/wscript_build       |  9 +-----
 source4/selftest/tests.py              |  3 +-
 13 files changed, 110 insertions(+), 41 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb-samba/ldb_wrap.c b/lib/ldb-samba/ldb_wrap.c
index cfc8732cf60..437aaee101a 100644
--- a/lib/ldb-samba/ldb_wrap.c
+++ b/lib/ldb-samba/ldb_wrap.c
@@ -352,7 +352,7 @@ int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx,
 	const char *base_url =
 		(const char *)ldb_get_opaque(ldb, "ldb_url");
 	char *path, *p, *full_name;
-	if (name == NULL) {
+	if (name == NULL || base_url == NULL) {
 		return NULL;
 	}
 	if (strncmp("tdb://", base_url, 6) == 0) {
diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c
index 7d3b2dc6afa..71a5c98a542 100644
--- a/lib/ldb/common/ldb.c
+++ b/lib/ldb/common/ldb.c
@@ -243,6 +243,17 @@ int ldb_connect(struct ldb_context *ldb, const char *url,
 {
 	int ret;
 	char *url2;
+
+	const char *existing_url = ldb_get_opaque(ldb, "ldb_url");
+	if (existing_url != NULL) {
+		ldb_asprintf_errstring(
+			ldb,
+			"This LDB has already connected to '%s', and "
+			"cannot also connect to '%s'",
+			existing_url, url);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
 	/* We seem to need to do this here, or else some utilities don't
 	 * get ldb backends */
 
diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c
index 601da57a1b1..39fe1e81f0d 100644
--- a/lib/ldb/common/ldb_dn.c
+++ b/lib/ldb/common/ldb_dn.c
@@ -38,7 +38,7 @@
 
 #define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed
 
-#define LDB_FREE(x) do { talloc_free(x); x = NULL; } while(0)
+#define LDB_FREE(x) TALLOC_FREE(x)
 
 /**
    internal ldb exploded dn structures
@@ -1156,8 +1156,15 @@ int ldb_dn_compare(struct ldb_dn *dn0, struct ldb_dn *dn1)
 
 	}
 
-	if (dn0->comp_num != dn1->comp_num) {
-		return (dn1->comp_num - dn0->comp_num);
+	/*
+	 * Notice that for comp_num, Samba reverses the usual order of
+	 * comparison. A DN with fewer components is greater than one
+	 * with more.
+	 */
+	if (dn0->comp_num > dn1->comp_num) {
+		return -1;
+	} else if (dn0->comp_num < dn1->comp_num) {
+		return 1;
 	}
 
 	if (dn0->comp_num == 0) {
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 5d995243d44..60ec4d299c4 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -482,7 +482,12 @@ static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self,
 static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self,
 		PyObject *Py_UNUSED(ignored))
 {
-	return PyUnicode_FromString(ldb_dn_get_casefold(self->dn));
+	const char *s = ldb_dn_get_casefold(self->dn);
+	if (s == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+	return PyUnicode_FromString(s);
 }
 
 static PyObject *py_ldb_dn_get_linearized(PyLdbDnObject *self,
@@ -1200,43 +1205,33 @@ static const char **PyList_AsStrList(TALLOC_CTX *mem_ctx, PyObject *list,
 	return ret;
 }
 
+static PyObject *py_ldb_connect(PyLdbObject *self, PyObject *args, PyObject *kwargs);
+
 static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs)
 {
 	const char * const kwnames[] = { "url", "flags", "options", NULL };
 	char *url = NULL;
-	PyObject *py_options = Py_None;
-	const char **options;
+	PyObject *py_options = NULL;
 	unsigned int flags = 0;
-	int ret;
-	struct ldb_context *ldb;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zIO:Ldb.__init__",
 					 discard_const_p(char *, kwnames),
-					 &url, &flags, &py_options))
+					 &url, &flags, &py_options)) {
 		return -1;
-
-	ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
-
-	if (py_options == Py_None) {
-		options = NULL;
-	} else {
-		options = PyList_AsStrList(ldb, py_options, "options");
-		if (options == NULL)
-			return -1;
 	}
 
 	if (url != NULL) {
-		ret = ldb_connect(ldb, url, flags, options);
-		if (ret != LDB_SUCCESS) {
-			PyErr_SetLdbError(PyExc_LdbError, ret, ldb);
-			talloc_free(options);
+		/* py_ldb_connect returns py_None on success, NULL on error */
+		PyObject *result = py_ldb_connect(self, args, kwargs);
+		if (result == NULL) {
 			return -1;
 		}
+		Py_DECREF(result);
 	} else {
+		struct ldb_context *ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
 		ldb_set_flags(ldb, flags);
 	}
 
-	talloc_free(options);
 	return 0;
 }
 
@@ -4023,7 +4018,18 @@ static PyObject *py_ldb_msg_richcmp(PyLdbMessageObject *py_msg1,
 
 	msg1 = pyldb_Message_AsMessage(py_msg1),
 	msg2 = pyldb_Message_AsMessage(py_msg2);
-
+	/*
+	 * FIXME: this can be a non-transitive compare, unsuitable for
+	 * sorting.
+	 *
+	 * supposing msg1, msg2, and msg3 have 1, 2, and 3 elements
+	 * each. msg2 has a NULL DN, while msg1 has a DN that compares
+	 * higher than msg3. Then:
+	 *
+	 * msg1 < msg2, due to num_elements.
+	 * msg2 < msg3, due to num_elements.
+	 * msg1 > msg3, due to DNs.
+	 */
 	if ((msg1->dn != NULL) || (msg2->dn != NULL)) {
 		ret = ldb_dn_compare(msg1->dn, msg2->dn);
 		if (ret != 0) {
@@ -4031,9 +4037,11 @@ static PyObject *py_ldb_msg_richcmp(PyLdbMessageObject *py_msg1,
 		}
 	}
 
-	ret = msg1->num_elements - msg2->num_elements;
-	if (ret != 0) {
-		return richcmp(ret, op);
+	if (msg1->num_elements > msg2->num_elements) {
+		return richcmp(1, op);
+	}
+	if (msg1->num_elements < msg2->num_elements) {
+		return richcmp(-1, op);
 	}
 
 	for (i = 0; i < msg1->num_elements; i++) {
diff --git a/lib/ldb/pyldb.h b/lib/ldb/pyldb.h
index 6c8dfd1b51a..34357eada1a 100644
--- a/lib/ldb/pyldb.h
+++ b/lib/ldb/pyldb.h
@@ -27,6 +27,8 @@
 #define _PYLDB_H_
 
 #include <talloc.h>
+#include "ldb_private.h"
+#include "lib/replace/system/python.h"
 
 typedef struct {
 	PyObject_HEAD
diff --git a/lib/ldb/pyldb_util.c b/lib/ldb/pyldb_util.c
index d1c5fad2b56..9d7086cf294 100644
--- a/lib/ldb/pyldb_util.c
+++ b/lib/ldb/pyldb_util.c
@@ -130,6 +130,7 @@ bool pyldb_Object_AsDn(TALLOC_CTX *mem_ctx, PyObject *object,
 
 	PyLdb_Dn_Type = PyLdb_GetPyType("Dn");
 	if (PyLdb_Dn_Type == NULL) {
+		PyErr_SetString(PyExc_TypeError, "Expected DN");
 		return false;
 	}
 
diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py
index 66cbc359372..866bfb0f751 100755
--- a/lib/ldb/tests/python/api.py
+++ b/lib/ldb/tests/python/api.py
@@ -124,6 +124,20 @@ class SimpleLdb(LdbBaseTest):
         x = ldb.Ldb()
         x.connect(self.url(), flags=self.flags())
 
+    def test_connect_twice(self):
+        url = self.url()
+        x = ldb.Ldb(url)
+        with self.assertRaises(ldb.LdbError):
+            x.connect(url, flags=self.flags())
+
+    def test_connect_twice_later(self):
+        url = self.url()
+        flags = self.flags()
+        x = ldb.Ldb()
+        x.connect(url, flags)
+        with self.assertRaises(ldb.LdbError):
+            x.connect(url, flags)
+
     def test_repr(self):
         x = ldb.Ldb()
         self.assertTrue(repr(x).startswith("<ldb connection"))
diff --git a/pidl/lib/Parse/Pidl/Samba3/Template.pm b/pidl/lib/Parse/Pidl/Samba3/Template.pm
index 6c1bbf3725b..53e6a320e7c 100644
--- a/pidl/lib/Parse/Pidl/Samba3/Template.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/Template.pm
@@ -74,6 +74,8 @@ $pad"."struct $fname *r)
 		$res .= "\treturn WERR_NOT_SUPPORTED;\n";
 	} elsif ($d->{RETURN_TYPE} eq "HRESULT") {
 		$res .= "\treturn HRES_ERROR_NOT_SUPPORTED;\n";
+	} elsif ($d->{RETURN_TYPE} eq "int") {
+		$res .= "\treturn ENOTSUP;\n";
 	}
 
 	$res .= "}
@@ -83,7 +85,7 @@ $pad"."struct $fname *r)
 	}
 $res .=
 "/* include the generated boilerplate */
-#include \"librpc/gen_ndr/ndr_$name\_scompat.c\
+#include \"librpc/gen_ndr/ndr_$name\_scompat.c\"\
 ";
 }
 
diff --git a/python/samba/samdb.py b/python/samba/samdb.py
index 085dff43848..b831cf56250 100644
--- a/python/samba/samdb.py
+++ b/python/samba/samdb.py
@@ -104,6 +104,14 @@ class SamDB(samba.Ldb):
 
         super().connect(url=url, flags=flags, options=options)
 
+    def __repr__(self):
+        if self.url:
+            return f"<SamDB {id(self):x} ({self.url})>"
+
+        return f"<SamDB {id(self):x} (no connection)>"
+
+    __str__ = __repr__
+
     def am_rodc(self):
         """return True if we are an RODC"""
         return dsdb._am_rodc(self)
diff --git a/python/samba/tests/segfault.py b/python/samba/tests/segfault.py
index 6c01088e5f8..885a9c91d11 100644
--- a/python/samba/tests/segfault.py
+++ b/python/samba/tests/segfault.py
@@ -58,9 +58,15 @@ def segfault_detector(f):
 def no_gdb_backtrace(f):
     from os import environ
     def w(*args, **kwargs):
+        old = environ.get('PLEASE_NO_GDB_BACKTRACE')
         environ['PLEASE_NO_GDB_BACKTRACE'] = '1'
-        f(*args, **kwargs)
-        del environ['PLEASE_NO_GDB_BACKTRACE']
+        try:
+            f(*args, **kwargs)
+        finally:
+            if old is not None:
+                environ['PLEASE_NO_GDB_BACKTRACE'] = old
+            else:
+                del environ['PLEASE_NO_GDB_BACKTRACE']
 
     return w
 
diff --git a/selftest/gdb_backtrace b/selftest/gdb_backtrace
index ec2396a630e..0c55af3cf2b 100755
--- a/selftest/gdb_backtrace
+++ b/selftest/gdb_backtrace
@@ -131,9 +131,25 @@ EOF
 gdb)
 	cat <<EOF >${BATCHFILE_MAIN}
 set height 0
+echo \\n### detailed backtrace\\n\\n
 bt full
-thread apply all bt full
+init-if-undefined \$_inferior_thread_count = 0
+if \$_inferior_thread_count != 1
+  echo \\n### info threads\\n\\n
+  info threads
+  echo \\n### backtrace for all threads\\n\\n
+  thread apply all bt full
+end
+echo \\n### info locals\\n\\n
 info locals
+if PyList_New
+  echo \\n### Python traceback\\n\\n
+  py-bt
+  echo \\n### Python locals\\n\\n
+  py-locals
+  echo \\n### Python full traceback\\n\\n
+  py-bt-full
+end
 quit
 EOF
 	${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" </dev/null
diff --git a/source3/librpc/idl/wscript_build b/source3/librpc/idl/wscript_build
index f46c4983792..3602ba94b51 100644
--- a/source3/librpc/idl/wscript_build
+++ b/source3/librpc/idl/wscript_build
@@ -27,15 +27,8 @@ absinclude=os.path.join(bld.srcnode.abspath(), 'bin/default/include')
 
 bld.SAMBA_PIDL_LIST('PIDL',
                     '''
-                       libnet_join.idl
+                       libnet_join.idl ads.idl
                     ''',
                     options='--includedir=%s --includedir=%s --header --ndr-parser' % (topinclude, absinclude),
                     output_dir='../gen_ndr',
                     generate_tables=False)
-
-bld.SAMBA_PIDL_LIST('PIDL',
-                    '''
-                       ads.idl
-                    ''',
-                    options='--includedir=%s --includedir=%s --header --ndr-parser' % (topinclude, absinclude),
-                    output_dir='../gen_ndr')
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 310226f625a..7a93df2134d 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -1377,7 +1377,8 @@ planoldpythontestsuite("ad_dc",
                        extra_args=['-U"$USERNAME%$PASSWORD"'])
 planoldpythontestsuite("ad_dc",
                        "samba.tests.segfault",
-                       extra_args=['-U"$USERNAME%$PASSWORD"'])
+                       extra_args=['-U"$USERNAME%$PASSWORD"'],
+                       environ={"TALLOC_FREE_FILL": "0xab"})
 # Need to test the password hashing in multiple environments to ensure that
 # all the possible options are covered
 #


-- 
Samba Shared Repository



More information about the samba-cvs mailing list