[SCM] Samba Shared Repository - branch v4-21-test updated

Jule Anger janger at samba.org
Wed Oct 2 09:29:02 UTC 2024


The branch, v4-21-test has been updated
       via  aabaf6aaf55 lib:ldb: Document environment variables in ldb manpage
       via  a56ce559eb1 lib:ldb: Remove trailing spaces from ldb.3.xml
       via  c9463d6dc98 lib:ldb: Don't use RTLD_DEEPBIND by default
       via  a4cc81cc2f2 lib:ldb: Remove trailing spaces from ldb_modules.c
       via  d42fa9251f9 smbd: remove just created sharemode entry in the error codepaths
       via  923d52f9033 smbd: consolidate DH reconnect failure code
       via  87ead9aec51 s3:tests: let test_durable_handle_reconnect.sh run smb2.durable-v2-regressions.durable_v2_reconnect_bug15624
       via  8fd281aff73 s4:torture/smb2: add smb2.durable-v2-regressions.durable_v2_reconnect_bug15624
       via  bb7be26b5dc vfs_error_inject: add 'error_inject:durable_reconnect = st_ex_nlink'
       via  acf50a3abfb smbd: add option "smbd:debug events" for tevent handling duration threshold warnings
       via  41f1b054ca0 smbd: move trace_state variable behind tv variable
       via  62309ed5907 smbd: add option "smbd lease break:debug hung procs"
       via  1d930df5404 smbd: log share_mode_watch_recv() errors as errors
       via  f4b1210f958 s3/lib: add option "serverid watch:debug script"
       via  1f6fc1ba3b5 s3/lib: add option "serverid watch:debug = yes" to print kernel stack of hanging process
       via  ae157ab2729 s3/lib: add next helper variable in server_id_watch_*
       via  4bec0a7fd10 s3:utils: use the correct secrets.tdb in net_use_krb_machine_account()
       via  d583d40ca32 s3:utils: let 'net ads testjoin' fail without valid machine credentials
       via  52772aed8b4 s3:test_update_keytab_clustered: add net ads testjoin checks in more places
      from  0ed55bfe082 sync machine password to keytab: handle FreeIPA use case

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-21-test


- Log -----------------------------------------------------------------
commit aabaf6aaf55103d59d98e49d3c632bc5a65186b4
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 09:22:08 2024 +0200

    lib:ldb: Document environment variables in ldb manpage
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15643
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Sep 27 09:06:43 UTC 2024 on atb-devel-224
    
    (cherry picked from commit 20a3a94e06a2294206ec233ccc7f873d6ef2aca0)
    
    Autobuild-User(v4-21-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-21-test): Wed Oct  2 09:28:09 UTC 2024 on atb-devel-224

commit a56ce559eb181f3e050cba1e436df5517f4af68a
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 09:40:23 2024 +0200

    lib:ldb: Remove trailing spaces from ldb.3.xml
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15643
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit d6ff05cb5708fb6746176821bee5f713195efa54)

commit c9463d6dc98bee7c90439f00c9ab94f611f6eaf1
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 09:19:44 2024 +0200

    lib:ldb: Don't use RTLD_DEEPBIND by default
    
    It should be off by default, as this is not needed by default. It
    crashes named on startup, if bind is built with jemalloc support.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15643
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit dc6927fdca2ad77dbcf212ef4d3ba0d118ec7bdf)

commit a4cc81cc2f2173d78730c6abb06f7959547d7433
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Sep 25 09:19:17 2024 +0200

    lib:ldb: Remove trailing spaces from ldb_modules.c
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15643
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 8d6b5183770895fef002b6cce84902d1874fa502)

commit d42fa9251f948bc2b3a51a17dd69c9db98a72a45
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 9 14:53:32 2024 +0200

    smbd: remove just created sharemode entry in the error codepaths
    
    Without this we leave stale sharemode entries around that can lead to all sorts
    of havoc.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Thu Sep 19 19:36:19 UTC 2024 on atb-devel-224
    
    (cherry picked from commit 2ff3b9bc0d254a63a913ff9084de3d794fee27d0)

commit 923d52f90338937df72184fef2a813d9a96b8343
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 9 14:52:44 2024 +0200

    smbd: consolidate DH reconnect failure code
    
    No change in behaviour, except that we now
    also call fd_close() if vfs_default_durable_cookie()
    failed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit a91457f97c98fcec1ed062514c364271af1df669)

commit 87ead9aec519afd82a070ea0efab36a14a7adb3e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 26 14:42:12 2024 +0200

    s3:tests: let test_durable_handle_reconnect.sh run smb2.durable-v2-regressions.durable_v2_reconnect_bug15624
    
    This demonstrates the dead lock after a durable reconnect failed
    because the stat info changed, the file can't be accessed anymore
    as we leak the incomplete share mode entry in a still running
    process.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 14875448ca06a3a28800343a3a326f1a66bccec0)

commit 8fd281aff73d07e845995611662d88a48bfecf35
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 26 14:42:02 2024 +0200

    s4:torture/smb2: add smb2.durable-v2-regressions.durable_v2_reconnect_bug15624
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit ef4ef04e7f83b1029446ff8b5fc5fdf4ab33edbd)

commit bb7be26b5dc32b91ef2280af245e197c0f9deb3b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Aug 26 14:11:02 2024 +0200

    vfs_error_inject: add 'error_inject:durable_reconnect = st_ex_nlink'
    
    This allows to simulate durable reconnect failures because the stat
    information of the file changed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 692ed832dfff61ad1c9b646b5c8d6f85f25efb99)

commit acf50a3abfb25df17dc371082b7d28fe874f737a
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 20 14:28:43 2024 +0100

    smbd: add option "smbd:debug events" for tevent handling duration threshold warnings
    
    Can be used to enable printing an error message if tevent event handlers ran
    longer then three seconds. Also logs a message with a loglevel of 3 if there
    were no events at hall.
    
    Enabled by default with 'log level = 10' or
    'smbd profiling level = on'...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 90d776cb18395ed804f0ab4fd13ef571fc0ad827)

commit 41f1b054ca06d7c267a2d49c4850e9832059ddd6
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 20 14:27:27 2024 +0100

    smbd: move trace_state variable behind tv variable
    
    Next commit adds timestamp variables to trace_state that want to be initialized
    with the current time, so moving behind tv we can then just reuse tv for that.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 679e12aee2f0c283a6f9b9c6008c549a6ca9633e)

commit 62309ed59079ed86bfef3d116cfb76de54114727
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 4 19:18:19 2024 +0200

    smbd: add option "smbd lease break:debug hung procs"
    
    By enabling this a process sending a lease break message to another process
    holding a lease will start watching that process and if that process didn't
    process the lease break within 10 seconds (cf server_id_watch_waited()), we log
    a kernel stack backtrace of that process.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit d8613d7ee23c4e990285a387eb9ac2eeefff9749)

commit 1d930df540414024351899a517de83c4260653be
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Apr 5 12:15:28 2024 +0200

    smbd: log share_mode_watch_recv() errors as errors
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit b45e78871aadca6ae33475bee890736838f44219)

commit f4b1210f9586e186a42387ce648a7e03f23a5691
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 25 15:17:08 2024 +0200

    s3/lib: add option "serverid watch:debug script"
    
    This takes just PID and NODE:PID on a cluster.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 7add7dbf1aee13b4d9ab70d1a5312c8ff30d9e00)

commit 1f6fc1ba3b5248dbb03ff6d7e42e2547496b52af
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 4 12:31:05 2024 +0200

    s3/lib: add option "serverid watch:debug = yes" to print kernel stack of hanging process
    
    We only do if sys_have_proc_fds() returns true, so it's most likely
    linux...
    
    Enabled by default with log level 10...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 5c57e840527432c4b1a7ec94894939022a9e9622)

commit ae157ab2729087fa46282c004f7083a47f297ff5
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 25 15:24:57 2024 +0200

    s3/lib: add next helper variable in server_id_watch_*
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15624
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit d76edcd48437715c7541b5b1e6a56245c25f460b)

commit 4bec0a7fd109370fbfb6daca85fd293b0f430b8a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 11 18:21:58 2024 +0200

    s3:utils: use the correct secrets.tdb in net_use_krb_machine_account()
    
    On a cluster we need to use the ctdb controlled database and not
    a local secrets.tdb...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15714
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Sep 20 05:54:43 UTC 2024 on atb-devel-224
    
    (cherry picked from commit f9ee4db2ba74e4f1f1b6d6f32082e5b0fe60f9b9)

commit d583d40ca328db2a6b8af05bfdc79f766d9955de
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 18 23:48:00 2024 +0200

    s3:utils: let 'net ads testjoin' fail without valid machine credentials
    
    This will allow doing tests and make sure using anonymous credentials
    doesn't cause false positive results...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15714
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit ab3fc1595c0a2e0aa3719cc2fe4684e9a0a2f9d8)

commit 52772aed8b48543de715ac546ca8571ab492eb9e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Sep 19 00:14:56 2024 +0200

    s3:test_update_keytab_clustered: add net ads testjoin checks in more places
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15714
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit 690c800c33df4d06d409b9ccfa57e5fa575ab1aa)

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

Summary of changes:
 lib/ldb/common/ldb_modules.c                       |  55 ++++----
 lib/ldb/man/ldb.3.xml                              |  23 +++-
 selftest/selftest.pl                               |   6 -
 selftest/skip                                      |   1 +
 selftest/wscript                                   |   5 +-
 source3/lib/server_id_watch.c                      | 129 +++++++++++++++++-
 source3/modules/vfs_error_inject.c                 |  76 +++++++++++
 .../script/tests/test_durable_handle_reconnect.sh  |  18 +++
 .../script/tests/test_update_keytab_clustered.sh   |  16 ++-
 source3/smbd/durable.c                             | 150 ++++++++-------------
 source3/smbd/open.c                                | 115 ++++++++++++++--
 source3/smbd/smb2_process.c                        |  72 +++++++++-
 source3/utils/net_ads.c                            |   6 +
 source3/utils/net_util.c                           |   6 +-
 source4/torture/smb2/durable_v2_open.c             | 118 ++++++++++++++++
 source4/torture/smb2/smb2.c                        |   2 +
 16 files changed, 637 insertions(+), 161 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/common/ldb_modules.c b/lib/ldb/common/ldb_modules.c
index b5627b0d04f..08d251f9bdd 100644
--- a/lib/ldb/common/ldb_modules.c
+++ b/lib/ldb/common/ldb_modules.c
@@ -631,9 +631,9 @@ int ldb_next_start_trans(struct ldb_module *module)
 		/* Set a default error string, to place the blame somewhere */
 		ldb_asprintf_errstring(module->ldb, "start_trans error in module %s: %s (%d)", module->ops->name, ldb_strerror(ret), ret);
 	}
-	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { 
-		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_start_trans error: %s", 
-			  ldb_errstring(module->ldb));				
+	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_start_trans error: %s",
+			  ldb_errstring(module->ldb));
 	}
 	return ret;
 }
@@ -650,9 +650,9 @@ int ldb_next_end_trans(struct ldb_module *module)
 		/* Set a default error string, to place the blame somewhere */
 		ldb_asprintf_errstring(module->ldb, "end_trans error in module %s: %s (%d)", module->ops->name, ldb_strerror(ret), ret);
 	}
-	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { 
-		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_end_trans error: %s", 
-			  ldb_errstring(module->ldb));				
+	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_end_trans error: %s",
+			  ldb_errstring(module->ldb));
 	}
 	return ret;
 }
@@ -720,9 +720,9 @@ int ldb_next_prepare_commit(struct ldb_module *module)
 		/* Set a default error string, to place the blame somewhere */
 		ldb_asprintf_errstring(module->ldb, "prepare_commit error in module %s: %s (%d)", module->ops->name, ldb_strerror(ret), ret);
 	}
-	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { 
-		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_prepare_commit error: %s", 
-			  ldb_errstring(module->ldb));				
+	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_prepare_commit error: %s",
+			  ldb_errstring(module->ldb));
 	}
 	return ret;
 }
@@ -739,9 +739,9 @@ int ldb_next_del_trans(struct ldb_module *module)
 		/* Set a default error string, to place the blame somewhere */
 		ldb_asprintf_errstring(module->ldb, "del_trans error in module %s: %s (%d)", module->ops->name, ldb_strerror(ret), ret);
 	}
-	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { 
-		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_del_trans error: %s", 
-			  ldb_errstring(module->ldb));				
+	if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
+		ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_next_del_trans error: %s",
+			  ldb_errstring(module->ldb));
 	}
 	return ret;
 }
@@ -777,17 +777,17 @@ int ldb_module_send_entry(struct ldb_request *req,
 	    req->handle->nesting == 0) {
 		char *s;
 		struct ldb_ldif ldif;
-		
+
 		ldif.changetype = LDB_CHANGETYPE_NONE;
 		ldif.msg = discard_const_p(struct ldb_message, msg);
 
 		ldb_debug_add(req->handle->ldb, "ldb_trace_response: ENTRY\n");
 
-		/* 
+		/*
 		 * The choice to call
 		 * ldb_ldif_write_redacted_trace_string() is CRITICAL
 		 * for security.  It ensures that we do not output
-		 * passwords into debug logs 
+		 * passwords into debug logs
 		 */
 
 		s = ldb_ldif_write_redacted_trace_string(req->handle->ldb, msg, &ldif);
@@ -945,7 +945,7 @@ static int ldb_modules_load_path(const char *path, const char *version)
 	int dlopen_flags;
 
 #ifdef RTLD_DEEPBIND
-	bool deepbind_enabled = (getenv("LDB_MODULES_DISABLE_DEEPBIND") == NULL);
+	bool deepbind_enabled = (getenv("LDB_MODULES_ENABLE_DEEPBIND") != NULL);
 #endif
 
 	ret = stat(path, &st);
@@ -981,21 +981,12 @@ static int ldb_modules_load_path(const char *path, const char *version)
 	dlopen_flags = RTLD_NOW;
 #ifdef RTLD_DEEPBIND
 	/*
-	 * use deepbind if possible, to avoid issues with different
-	 * system library variants, for example ldb modules may be linked
-	 * against Heimdal while the application may use MIT kerberos.
-	 *
-	 * See the dlopen manpage for details.
-	 *
-	 * One typical user is the bind_dlz module of Samba,
-	 * but symbol versioning might be enough...
+	 * On systems where e.g. different kerberos libraries are used, like a
+	 * mix of Heimdal and MIT Kerberos, LDB_MODULES_ENABLE_DEEPBIND should
+	 * be set to avoid issues.
 	 *
-	 * We need a way to disable this in order to allow the
-	 * ldb_*ldap modules to work with a preloaded socket wrapper.
-	 *
-	 * So in future we may remove this completely
-	 * or at least invert the default behavior.
-	*/
+	 * By default Linux distributions only have one Kerberos library.
+	 */
 	if (deepbind_enabled) {
 		dlopen_flags |= RTLD_DEEPBIND;
 	}
@@ -1104,8 +1095,8 @@ static int ldb_modules_load_dir(const char *modules_dir, const char *version)
 	return LDB_SUCCESS;
 }
 
-/* 
-   load any additional modules from the given directory 
+/*
+   load any additional modules from the given directory
 */
 void ldb_set_modules_dir(struct ldb_context *ldb, const char *path)
 {
diff --git a/lib/ldb/man/ldb.3.xml b/lib/ldb/man/ldb.3.xml
index 1c0a2ece552..f8d3cb50446 100644
--- a/lib/ldb/man/ldb.3.xml
+++ b/lib/ldb/man/ldb.3.xml
@@ -243,11 +243,32 @@ ldb_search(3) manual pages.
 	</itemizedlist>
 </refsect1>
 
+<refsect1>
+	<title>ENVIRONMENT VARIABLES</title>
+
+	<itemizedlist>
+		<listitem><para>
+			<envar>LDB_URL</envar>
+			 - connect to the provided URL (cmdline tools only)
+		</para></listitem>
+
+		<listitem><para>
+			<envar>LDB_MODULES_PATH</envar>
+			 - path where to load ldb modules from
+		</para></listitem>
+
+		<listitem><para>
+			<envar>LDB_MODULES_ENABLE_DEEPBIND</envar>
+			 - enable RTLD_DEEPBIND when loading ldb modules
+		</para></listitem>
+	</itemizedlist>
+</refsect1>
+
 <refsect1>
 	<title>Author</title>
 
 	<para>
-		ldb was written by 
+		ldb was written by
 		 <ulink url="https://www.samba.org/~tridge/">Andrew Tridgell</ulink>.
 	</para>
 
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 26b1663b5b6..a0c4ec80f59 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -433,12 +433,6 @@ $ENV{UID_WRAPPER} = 1;
 # We are already hitting the limit, so double it.
 $ENV{NSS_WRAPPER_MAX_HOSTENTS} = 200;
 
-# Disable RTLD_DEEPBIND hack for Samba bind dlz module
-#
-# This is needed in order to allow the ldb_*ldap module
-# to work with a preloaded socket wrapper.
-$ENV{LDB_MODULES_DISABLE_DEEPBIND} = 1;
-
 my $socket_wrapper_dir;
 if ($opt_socket_wrapper) {
 	$socket_wrapper_dir = SocketWrapper::setup_dir("$prefix_abs/w", $opt_socket_wrapper_pcap);
diff --git a/selftest/skip b/selftest/skip
index b5266bb16d8..c539243ab8e 100644
--- a/selftest/skip
+++ b/selftest/skip
@@ -147,3 +147,4 @@ bench # don't run benchmarks in our selftest
 ^samba4.smb2.tcon.*\(ad_dc_ntvfs\)$ # Ignore ad_dc_ntvfs since this is a new test
 ^samba4.smb2.mkdir.*\(ad_dc_ntvfs\)$ # Ignore ad_dc_ntvfs since this is a new test
 ^samba3.blackbox.open-eintr.*
+smb2.durable-v2-regressions # Only used in blackbox tests
diff --git a/selftest/wscript b/selftest/wscript
index 52c34dcb88d..95e70706e63 100644
--- a/selftest/wscript
+++ b/selftest/wscript
@@ -333,9 +333,8 @@ def cmd_testonly(opt):
         asan_options += ":suppressions=${srcdir}/selftest/sanitizer/asan.supp"
         asan_options += " "
 
-        # And we need to disable RTLD_DEEPBIND in ldb and socket wrapper
-        no_leak_check = "LDB_MODULES_DISABLE_DEEPBIND=1 "
-        no_leak_check += "SOCKET_WRAPPER_DISABLE_DEEP_BIND=1"
+        # We need to disable RTLD_DEEPBIND in socket wrapper
+        no_leak_check = "SOCKET_WRAPPER_DISABLE_DEEP_BIND=1"
         no_leak_check += " "
         env.CORE_COMMAND = asan_options + no_leak_check + env.CORE_COMMAND
 
diff --git a/source3/lib/server_id_watch.c b/source3/lib/server_id_watch.c
index f0189e0e896..77b1952f9eb 100644
--- a/source3/lib/server_id_watch.c
+++ b/source3/lib/server_id_watch.c
@@ -17,16 +17,19 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "replace.h"
-#include <tevent.h>
-#include <talloc.h>
+#include "includes.h"
 #include "serverid.h"
 #include "server_id_watch.h"
+#include "lib/util/server_id.h"
 #include "lib/util/tevent_unix.h"
+#include "lib/util/util_file.h"
 
 struct server_id_watch_state {
 	struct tevent_context *ev;
 	struct server_id pid;
+	struct timeval start;
+	struct timeval warn;
+	bool debug;
 };
 
 static void server_id_watch_waited(struct tevent_req *subreq);
@@ -37,6 +40,7 @@ struct tevent_req *server_id_watch_send(TALLOC_CTX *mem_ctx,
 {
 	struct tevent_req *req, *subreq;
 	struct server_id_watch_state *state;
+	struct timeval next;
 
 	req = tevent_req_create(mem_ctx, &state, struct server_id_watch_state);
 	if (req == NULL) {
@@ -44,14 +48,21 @@ struct tevent_req *server_id_watch_send(TALLOC_CTX *mem_ctx,
 	}
 	state->ev = ev;
 	state->pid = pid;
+	state->start = tevent_timeval_current();
+	state->warn = tevent_timeval_add(&state->start, 10, 0);
+
+	state->debug = lp_parm_bool(GLOBAL_SECTION_SNUM,
+				    "serverid watch",
+				    "debug",
+				    CHECK_DEBUGLVL(DBGLVL_DEBUG));
 
 	if (!serverid_exists(&state->pid)) {
 		tevent_req_done(req);
 		return tevent_req_post(req, ev);
 	}
 
-	subreq = tevent_wakeup_send(
-		state, ev, tevent_timeval_current_ofs(0, 500000));
+	next = tevent_timeval_add(&state->start, 0, 500000);
+	subreq = tevent_wakeup_send(state, ev, next);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -66,6 +77,8 @@ static void server_id_watch_waited(struct tevent_req *subreq)
 		subreq, struct tevent_req);
 	struct server_id_watch_state *state = tevent_req_data(
 		req, struct server_id_watch_state);
+	struct timeval now;
+	struct timeval next;
 	bool ok;
 
 	ok = tevent_wakeup_recv(subreq);
@@ -80,8 +93,110 @@ static void server_id_watch_waited(struct tevent_req *subreq)
 		return;
 	}
 
-	subreq = tevent_wakeup_send(
-		state, state->ev, tevent_timeval_current_ofs(0, 500000));
+	now = tevent_timeval_current();
+
+	if (!state->debug) {
+		goto next;
+	}
+
+	if (timeval_compare(&state->warn, &now) == -1) {
+		double duration = timeval_elapsed2(&state->start, &now);
+		const char *cmd = NULL;
+		char proc_path[64] = { 0, };
+		char *kstack = NULL;
+		struct server_id_buf buf;
+		const char *pid = server_id_str_buf(state->pid, &buf);
+		int ret;
+
+		state->warn = tevent_timeval_add(&now, 10, 0);
+
+		cmd = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+					   "serverid watch",
+					   "debug script",
+					   NULL);
+		if (cmd != NULL) {
+			char *cmdstr = NULL;
+			char *output = NULL;
+			int fd;
+
+			/*
+			 * Note in a cluster setup pid will be
+			 * a NOTE:PID like '1:3978365'
+			 *
+			 * Without clustering it is just '3978365'
+			 */
+			cmdstr = talloc_asprintf(state, "%s %s", cmd, pid);
+			if (cmdstr == NULL) {
+				DBG_ERR("Process %s hanging for %f seconds?\n"
+					"talloc_asprintf failed\n",
+					pid, duration);
+				goto next;
+			}
+
+			become_root();
+			ret = smbrun(cmdstr, &fd, NULL);
+			unbecome_root();
+			if (ret != 0) {
+				DBG_ERR("Process %s hanging for %f seconds?\n"
+					"smbrun('%s') failed\n",
+					pid, duration, cmdstr);
+				TALLOC_FREE(cmdstr);
+				goto next;
+			}
+
+			output = fd_load(fd, NULL, 0, state);
+			close(fd);
+			if (output == NULL) {
+				DBG_ERR("Process %s hanging for %f seconds?\n"
+					"fd_load() of smbrun('%s') failed\n",
+					pid, duration, cmdstr);
+				TALLOC_FREE(cmdstr);
+				goto next;
+			}
+			DBG_ERR("Process %s hanging for %f seconds?\n"
+				"%s returned:\n%s",
+				pid, duration, cmdstr, output);
+			TALLOC_FREE(cmdstr);
+			TALLOC_FREE(output);
+			goto next;
+		}
+
+		if (!procid_is_local(&state->pid) || !sys_have_proc_fds()) {
+			DBG_ERR("Process %s hanging for %f seconds?\n",
+				pid, duration);
+			goto next;
+		}
+
+		ret = snprintf(proc_path,
+			       ARRAY_SIZE(proc_path),
+			       "/proc/%" PRIu64 "/stack",
+			       state->pid.pid);
+		if (ret < 0) {
+			DBG_ERR("Process %s hanging for %f seconds?\n"
+				"snprintf failed\n",
+				pid, duration);
+			goto next;
+		}
+
+		become_root();
+		kstack = file_load(proc_path, NULL, 0, state);
+		unbecome_root();
+		if (kstack == NULL) {
+			DBG_ERR("Process %s hanging for %f seconds?\n"
+				"file_load [%s] failed\n",
+				pid, duration, proc_path);
+			goto next;
+		}
+
+		DBG_ERR("Process %s hanging for %f seconds?\n"
+			"%s:\n%s",
+			pid, duration, proc_path, kstack);
+		TALLOC_FREE(kstack);
+	}
+
+next:
+	next = tevent_timeval_add(&now, 0, 500000);
+	subreq = tevent_wakeup_send(state, state->ev, next);
 	if (tevent_req_nomem(subreq, req)) {
 		return;
 	}
diff --git a/source3/modules/vfs_error_inject.c b/source3/modules/vfs_error_inject.c
index 529504fd8d5..dcf0de0a2d9 100644
--- a/source3/modules/vfs_error_inject.c
+++ b/source3/modules/vfs_error_inject.c
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "smbd/smbd.h"
+#include "librpc/gen_ndr/ndr_open_files.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -204,11 +205,86 @@ static int vfs_error_inject_unlinkat(struct vfs_handle_struct *handle,
 	return -1;
 }
 
+static NTSTATUS vfs_error_inject_durable_reconnect(struct vfs_handle_struct *handle,
+						   struct smb_request *smb1req,
+						   struct smbXsrv_open *op,
+						   const DATA_BLOB old_cookie,
+						   TALLOC_CTX *mem_ctx,
+						   struct files_struct **fsp,
+						   DATA_BLOB *new_cookie)
+{
+	const char *vfs_func = "durable_reconnect";
+	const char *err_str = NULL;
+	NTSTATUS status;
+	enum ndr_err_code ndr_err;
+	struct vfs_default_durable_cookie cookie;
+	DATA_BLOB modified_cookie = data_blob_null;
+
+	err_str = lp_parm_const_string(SNUM(handle->conn),
+				       "error_inject",
+				       vfs_func,
+				       NULL);
+	if (err_str == NULL) {
+		return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
+						      smb1req,
+						      op,
+						      old_cookie,
+						      mem_ctx,
+						      fsp,
+						      new_cookie);
+	}
+
+	ndr_err = ndr_pull_struct_blob(&old_cookie, talloc_tos(), &cookie,
+			(ndr_pull_flags_fn_t)ndr_pull_vfs_default_durable_cookie);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		status = ndr_map_error2ntstatus(ndr_err);
+		return status;
+	}
+
+	if (strcmp(cookie.magic, VFS_DEFAULT_DURABLE_COOKIE_MAGIC) != 0) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	if (cookie.version != VFS_DEFAULT_DURABLE_COOKIE_VERSION) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	if (strequal(err_str, "st_ex_nlink")) {
+		cookie.stat_info.st_ex_nlink += 1;
+	} else {
+		DBG_ERR("Unknown error inject %s requested "
+			"for vfs function %s\n", err_str, vfs_func);
+		return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
+						      smb1req,
+						      op,
+						      old_cookie,
+						      mem_ctx,
+						      fsp,
+						      new_cookie);
+	}
+
+	ndr_err = ndr_push_struct_blob(&modified_cookie, talloc_tos(), &cookie,
+			(ndr_push_flags_fn_t)ndr_push_vfs_default_durable_cookie);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		status = ndr_map_error2ntstatus(ndr_err);
+		return status;
+	}
+
+	return SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
+					      smb1req,
+					      op,
+					      modified_cookie,
+					      mem_ctx,
+					      fsp,
+					      new_cookie);
+}
+
 static struct vfs_fn_pointers vfs_error_inject_fns = {
 	.chdir_fn = vfs_error_inject_chdir,
 	.pwrite_fn = vfs_error_inject_pwrite,
 	.openat_fn = vfs_error_inject_openat,
 	.unlinkat_fn = vfs_error_inject_unlinkat,
+	.durable_reconnect_fn = vfs_error_inject_durable_reconnect,
 };
 
 static_decl_vfs;
diff --git a/source3/script/tests/test_durable_handle_reconnect.sh b/source3/script/tests/test_durable_handle_reconnect.sh
index 0ab32974824..fd5c156956f 100755
--- a/source3/script/tests/test_durable_handle_reconnect.sh
+++ b/source3/script/tests/test_durable_handle_reconnect.sh
@@ -33,4 +33,22 @@ testit "durable_v2_delay.durable_v2_reconnect_delay_msec" $VALGRIND \
 
 rm $delay_inject_conf
 
+error_inject_conf=$(dirname $SMB_CONF_PATH)/error_inject.conf
+
+cat > $error_inject_conf << _EOF
+	kernel share modes = no
+	kernel oplocks = no
+	posix locking = no
+	error_inject:durable_reconnect = st_ex_nlink
+_EOF


-- 
Samba Shared Repository



More information about the samba-cvs mailing list