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

Jule Anger janger at samba.org
Fri Jan 13 11:57:02 UTC 2023


The branch, v4-17-test has been updated
       via  0bc115f7570 s3:smbstatus: go to cmdline_messaging_context_free
       via  69f6517f93b source3/wscript: Remove implicit int and implicit function declarations
       via  fab96048ba5 source3/wscript: Fix detection of major/minor macros
       via  409dd9b20ea buildtools/wafsamba: Avoid calling lib_func without a prototype
       via  cedb4ff4ca9 s4:lib/messaging: fix interaction between imessaging_context_destructor and irpc_destructor
       via  b1d5552f2e2 s3:rpc_server/srvsvc: make sure we (re-)load all shares as root.
       via  a8934a92f1a selftest: add samba3.blackbox.registry_share
       via  658a590b353 testprogs: Add testit_grep_count() helper
      from  33a5ca2f999 s3: smbd: Strip any leading '\' characters if the SMB2 DFS flag is set.

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


- Log -----------------------------------------------------------------
commit 0bc115f75704c9dbad86117fd40b023920f31986
Author: Jones Syue <jonessyue at qnap.com>
Date:   Wed Jan 11 16:59:42 2023 +0800

    s3:smbstatus: go to cmdline_messaging_context_free
    
    If the locking.tdb is not found,
    (for example, fresh new installed samba server is not running yet)
    smbstatus utility would exit earlier,
    and lock files are left behind in the directory 'msg.sock' and 'msg.lock'.
    Consider that a script to run smbstatus utility in a loop,
    this might result in used space slowly growing-up on the underlying filesystem.
    Since the samba server is not running yet,
    there is no cleanupd daemon could delete these files to reclaim space.
    
    Supposed to use 'ret = 0; goto done;' instead of exit(0),
    this would go through the cmdline_messaging_context_free() which deletes
    the lock files in the directory msg.sock and msg.lock before smbstatus
    utility is exiting.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15282
    
    Signed-off-by: Jones Syue <jonessyue at qnap.com>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Wed Jan 11 17:08:10 UTC 2023 on sn-devel-184
    
    (cherry picked from commit de5d31f452b2445bd92b1746efb05aa096716af8)
    
    Autobuild-User(v4-17-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-17-test): Fri Jan 13 11:56:59 UTC 2023 on sn-devel-184

commit 69f6517f93b59cdd447751b1ac9f293d1342655e
Author: Florian Weimer <fweimer at redhat.com>
Date:   Mon Nov 21 14:12:43 2022 +0100

    source3/wscript: Remove implicit int and implicit function declarations
    
    This should fix the remaining C89isms in these configure checks.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15281
    
    Signed-off-by: Florian Weimer <fweimer at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 7779050a6765a37cc0c6438309e512782220dcb3)

commit fab96048ba53e01eff63d060f544bf97944ab8f8
Author: Florian Weimer <fweimer at redhat.com>
Date:   Mon Nov 21 13:53:17 2022 +0100

    source3/wscript: Fix detection of major/minor macros
    
    These macros are only available via <sys/sysmacros.h> as of glibc
    commit e16deca62e16f645213dffd4ecd1153c37765f17 ("[BZ #19239] Don't
    include sys/sysmacros.h from sys/types.h."), which went into
    glibc 2.28.
    
    This is different from the usual C99 cleanups because it changes
    the configure check result with existing compilers that usually
    accept implicit function declarations.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15281
    
    Signed-off-by: Florian Weimer <fweimer at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit d0ee9d5a43072ecbd37327f5dc936c546f97ba34)

commit 409dd9b20ea4995c4b7848c83c001074d7557b03
Author: Florian Weimer <fweimer at redhat.com>
Date:   Mon Nov 21 13:37:41 2022 +0100

    buildtools/wafsamba: Avoid calling lib_func without a prototype
    
    This is a backport of commit f4c0a750d4adebcf2342a44e85f04526c34
    ("WAF: Fix detection of linker features")
    to buildtools/wafsamba/samba_conftests.py.  It fixes the check for
    rpath support with compilers in strict C99 mode.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15281
    
    Signed-off-by: Florian Weimer <fweimer at redhat.com>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 75db84b1e59a42737343445c43c41494460c89f0)

commit cedb4ff4ca9ed2ca195287917904579cadce1c68
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Dec 31 01:24:57 2022 +0100

    s4:lib/messaging: fix interaction between imessaging_context_destructor and irpc_destructor
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15280
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    (cherry picked from commit 0d096931196524a2d1bf59470bc629dc9231131e)

commit b1d5552f2e2808db3eeb1e3492df87be12e6b99b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 28 13:50:45 2022 +0100

    s3:rpc_server/srvsvc: make sure we (re-)load all shares as root.
    
    This fixes a regression in commit f03665bb7e8ea97699062630f2aa1bac4c5dfc7f
    
    The use of reload_services() has a lot of side effects, e.g. reopen of
    log files and other things, which are only useful in smbd, but not in rpcd_classic.
    It was also unloading the user and registry shares we loaded a few lines
    above.
    
    We need to do all (re-)loading as root, otherwise we won't be able
    to read root only smb.conf files, access registry shares, ...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15243
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15266
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Walker <awalker at ixsystems.com>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Thu Dec 29 21:14:02 UTC 2022 on sn-devel-184
    
    (cherry picked from commit f28553105be7465026bcc0fcbbed6a1a8c2133dd)

commit a8934a92f1a166fb66e247b9fb2be5758f1a91fc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Dec 28 16:18:40 2022 +0100

    selftest: add samba3.blackbox.registry_share
    
    This demonstrates the regression introduced by
    f03665bb7e8ea97699062630f2aa1bac4c5dfc7f, where
    registry shares are no longer listed.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15243
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15266
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Walker <awalker at ixsystems.com>
    (cherry picked from commit a00c7395fbc7974a61a70ae54ea6ae6349933de2)

commit 658a590b3532ffab79d463d28749a480b923384e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Nov 9 14:04:23 2022 +0100

    testprogs: Add testit_grep_count() helper
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 55feb593012fc5b24e795a00081666fca740429c)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15243
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15266

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

Summary of changes:
 buildtools/wafsamba/samba_waf18.py          |  3 ++-
 selftest/target/Samba3.pm                   | 30 ++++++++++++++++++++++
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   | 28 ++++++++++++---------
 source3/script/tests/test_registry_share.sh | 39 +++++++++++++++++++++++++++++
 source3/selftest/tests.py                   |  4 +++
 source3/utils/status.c                      |  3 ++-
 source3/wscript                             | 15 +++++------
 source4/lib/messaging/messaging.c           | 13 ++++++++++
 source4/lib/messaging/messaging_internal.h  |  3 +++
 testprogs/blackbox/subunit.sh               | 29 +++++++++++++++++++++
 10 files changed, 146 insertions(+), 21 deletions(-)
 create mode 100755 source3/script/tests/test_registry_share.sh


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_waf18.py b/buildtools/wafsamba/samba_waf18.py
index e2a078bd3a0..cfdceea14ca 100644
--- a/buildtools/wafsamba/samba_waf18.py
+++ b/buildtools/wafsamba/samba_waf18.py
@@ -209,7 +209,8 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
         lib_node.parent.mkdir()
         lib_node.write('int lib_func(void) { return 42; }\n', 'w')
         main_node = bld.srcnode.make_node('main.c')
-        main_node.write('int main(void) {return !(lib_func() == 42);}', 'w')
+        main_node.write('int lib_func(void);\n'
+                        'int main(void) {return !(lib_func() == 42);}', 'w')
         linkflags = []
         if version_script:
             script = bld.srcnode.make_node('ldscript')
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 64374ab9bcd..72c8abac867 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -532,6 +532,36 @@ sub setup_clusteredmember
 			return undef;
 		}
 
+		my $registry_share_template = "$node_ret->{SERVERCONFFILE}.registry_share_template";
+		unless (open(REGISTRYCONF, ">$registry_share_template")) {
+			warn("Unable to open $registry_share_template");
+			teardown_env($self, $node_ret);
+			teardown_env($self, $ctdb_data);
+			return undef;
+		}
+
+		print REGISTRYCONF "
+[registry_share]
+	copy = tmp
+	comment = smb username is [%U]
+";
+
+		close(REGISTRYCONF);
+
+		my $net = Samba::bindir_path($self, "net");
+		my $cmd = "";
+
+		$cmd .= "UID_WRAPPER_ROOT=1 ";
+		$cmd .= "$net conf import $node_ret->{CONFIGURATION} ${registry_share_template}";
+
+		my $net_ret = system($cmd);
+		if ($net_ret != 0) {
+			warn("net conf import failed: $net_ret\n$cmd");
+			teardown_env($self, $node_ret);
+			teardown_env($self, $ctdb_data);
+			return undef;
+		}
+
 		my $nmblookup = Samba::bindir_path($self, "nmblookup");
 		do {
 			print "Waiting for the LOGON SERVER registration ...\n";
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index fbc617c3ac1..5b57e3e0bdf 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -639,30 +639,34 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
 	union srvsvc_NetShareCtr ctr;
 	uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
 	const char *unix_name = session_info->unix_info->unix_name;
-	int existing_home = lp_servicenumber(unix_name);
+	int existing_home = -1;
 	int added_home = -1;
 	WERROR ret = WERR_OK;
 
 	DEBUG(5,("init_srv_share_info_ctr\n"));
 
-	/* Ensure all the usershares are loaded. */
+	/*
+	 * We need to make sure to reload the services for the connecting user.
+	 * It is possible that we have includes with substitutions.
+	 *
+	 *  include = /etc/samba/%U.conf
+	 *
+	 * We also need all printers and usershares.
+	 *
+	 * We need to be root in order to have access to registry shares
+	 * and root only smb.conf files.
+	 */
 	become_root();
+	lp_kill_all_services();
+	lp_load_with_shares(get_dyn_CONFIGFILE());
 	delete_and_reload_printers();
 	load_usershare_shares(NULL, connections_snum_used);
 	load_registry_shares();
-	unbecome_root();
-
+	existing_home = lp_servicenumber(unix_name);
 	if (existing_home == -1) {
 		added_home = register_homes_share(unix_name);
 	}
-
-	/*
-	 * We need to make sure to reload the services for the connecting user.
-	 * It is possible that the we have includes with substitutions.
-	 *
-	 *  include = /etc/samba/%U.conf
-	 */
-	reload_services(NULL, NULL, false);
+	unbecome_root();
 
 	num_services = lp_numservices();
 
diff --git a/source3/script/tests/test_registry_share.sh b/source3/script/tests/test_registry_share.sh
new file mode 100755
index 00000000000..22e9f732a58
--- /dev/null
+++ b/source3/script/tests/test_registry_share.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Blackbox tests for registry shares
+#
+
+if [ $# -lt 3 ]; then
+	cat <<EOF
+Usage: test_registry_share.sh SERVER USERNAME PASSWORD
+EOF
+	exit 1
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+shift 3
+failed=0
+
+samba_bindir="$BINDIR"
+samba_srcdir="$SRCDIR"
+smbclient="$samba_bindir/smbclient"
+rpcclient="$samba_bindir/rpcclient"
+
+. $samba_srcdir/testprogs/blackbox/subunit.sh
+. $samba_srcdir/testprogs/blackbox/common_test_fns.inc
+
+test_smbclient \
+	"Test access to registry share [${USERNAME}]" \
+	"ls" "//${SERVER}/registry_share" "-U$USERNAME%$PASSWORD" ||
+	failed=$((failed + 1))
+
+testit_grep_count \
+	"Test for share enum with registry share" \
+	"netname: registry_share" \
+	1 \
+	${rpcclient} "ncacn_np:${SERVER}" "-U$USERNAME%$PASSWORD" \
+	-c netshareenum ||
+	failed=$((failed + 1))
+
+testok "$0" "$failed"
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 01ec90e9878..54c788fd441 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -1376,6 +1376,10 @@ plantestsuite("samba3.blackbox.smbXsrv_client_cross_node", "clusteredmember:loca
                configuration,
                'ctdb0', 'ctdb1',
                "tmp"])
+plantestsuite("samba3.blackbox.registry_share", "clusteredmember",
+              [os.path.join(samba3srcdir,
+                            "script/tests/test_registry_share.sh"),
+               "$SERVER", '$DC_USERNAME', "$DC_PASSWORD"])
 
 env = 'fileserver'
 plantestsuite("samba3.blackbox.virus_scanner", "%s:local" % (env),
diff --git a/source3/utils/status.c b/source3/utils/status.c
index e311f067c9c..7a8fc75f345 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -1163,7 +1163,8 @@ int main(int argc, const char *argv[])
 			fprintf(stderr, "This is normal if an SMB client has never "
 				 "connected to your server.\n");
 			TALLOC_FREE(db_path);
-			exit(0);
+			ret = 0;
+			goto done;
 		} else {
 			TALLOC_FREE(db);
 			TALLOC_FREE(db_path);
diff --git a/source3/wscript b/source3/wscript
index 22be17a1a6f..e77cd127e60 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -603,11 +603,11 @@ msg.msg_accrightslen = sizeof(fd);
     conf.CHECK_HEADERS('asm/types.h')
 
     conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
-                    headers='unistd.h sys/types.h',
+                    headers='sys/sysmacros.h unistd.h sys/types.h',
                     msg="Checking for major macro")
 
     conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
-                    headers='unistd.h sys/types.h',
+                    headers='sys/sysmacros.h unistd.h sys/types.h',
                     msg="Checking for minor macro")
 
     conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
@@ -1314,7 +1314,7 @@ syscall(SYS_initgroups, 16, NULL, NULL, 0);
 
     if conf.CHECK_CODE('''
 #include <time.h>
-main() {
+int main() {
         struct tm *tm;
         if (sizeof(time_t) == 8) {
                 time_t max_time = 0x7fffffffffffffffll;
@@ -1345,7 +1345,7 @@ main() {
 #if defined(HAVE_SYS_SYSMACROS_H)
 #include <sys/sysmacros.h>
 #endif
-main() { dev_t dev = makedev(1,2); return 0; }
+int main() { dev_t dev = makedev(1,2); return 0; }
 ''',
         'HAVE_MAKEDEV',
         addmain=False,
@@ -1355,12 +1355,13 @@ main() { dev_t dev = makedev(1,2); return 0; }
 #include <stdio.h>
 #include <limits.h>
 #include <signal.h>
+#include <stdlib.h>
 
 void exit_on_core(int ignored) {
         exit(1);
 }
 
-main() {
+int main() {
         char *newpath;
         signal(SIGSEGV, exit_on_core);
         newpath = realpath("/tmp", NULL);
@@ -1517,9 +1518,9 @@ main() {
     # Check for getcwd allowing a NULL arg.
     conf.CHECK_CODE('''
 #include <unistd.h>
-main() {
+int main() {
         char *s = getcwd(NULL,0);
-        exit(s != NULL ?  0 : 1);
+        return s != NULL ?  0 : 1;
 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
         msg="getcwd takes a NULL argument")
 
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 8603c167ad4..67b0366423a 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -48,6 +48,7 @@
   a pending irpc call
 */
 struct irpc_request {
+	struct irpc_request *prev, *next;
 	struct imessaging_context *msg_ctx;
 	int callid;
 	struct {
@@ -400,6 +401,16 @@ NTSTATUS imessaging_process_cleanup(
 
 static int imessaging_context_destructor(struct imessaging_context *msg)
 {
+	struct irpc_request *irpc = NULL;
+	struct irpc_request *next = NULL;
+
+	for (irpc = msg->requests; irpc != NULL; irpc = next) {
+		next = irpc->next;
+
+		DLIST_REMOVE(msg->requests, irpc);
+		irpc->callid = -1;
+	}
+
 	DLIST_REMOVE(msg_ctxs, msg);
 	TALLOC_FREE(msg->msg_dgm_ref);
 	return 0;
@@ -1035,6 +1046,7 @@ failed:
 static int irpc_destructor(struct irpc_request *irpc)
 {
 	if (irpc->callid != -1) {
+		DLIST_REMOVE(irpc->msg_ctx->requests, irpc);
 		idr_remove(irpc->msg_ctx->idr, irpc->callid);
 		if (irpc->msg_ctx->discard_incoming) {
 			SMB_ASSERT(irpc->msg_ctx->num_incoming_listeners > 0);
@@ -1238,6 +1250,7 @@ static struct tevent_req *irpc_bh_raw_call_send(TALLOC_CTX *mem_ctx,
 	/* make sure we accept incoming messages */
 	SMB_ASSERT(state->irpc->msg_ctx->num_incoming_listeners < UINT64_MAX);
 	state->irpc->msg_ctx->num_incoming_listeners += 1;
+	DLIST_ADD_END(state->irpc->msg_ctx->requests, state->irpc);
 	talloc_set_destructor(state->irpc, irpc_destructor);
 
 	/* setup the header */
diff --git a/source4/lib/messaging/messaging_internal.h b/source4/lib/messaging/messaging_internal.h
index ac254c22631..6281bda82a9 100644
--- a/source4/lib/messaging/messaging_internal.h
+++ b/source4/lib/messaging/messaging_internal.h
@@ -19,6 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+struct irpc_request;
+
 struct imessaging_context {
 	struct imessaging_context *prev, *next;
 	struct tevent_context *ev;
@@ -30,6 +32,7 @@ struct imessaging_context {
 	struct idr_context *dispatch_tree;
 	struct irpc_list *irpc;
 	struct idr_context *idr;
+	struct irpc_request *requests;
 	struct server_id_db *names;
 	struct timeval start_time;
 	void *msg_dgm_ref;
diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh
index 75a9b5ec7e3..ba4e997c525 100755
--- a/testprogs/blackbox/subunit.sh
+++ b/testprogs/blackbox/subunit.sh
@@ -121,6 +121,35 @@ testit_grep()
 	return $status
 }
 
+# This returns 0 if the command gave success and the grep value was found
+# num times all other cases return != 0
+testit_grep_count()
+{
+	name="$1"
+	shift
+	grep="$1"
+	shift
+	num="$1"
+	shift
+	cmdline="$@"
+	subunit_start_test "$name"
+	output=$($cmdline 2>&1)
+	status=$?
+	if [ x$status != x0 ]; then
+		printf '%s' "$output" | subunit_fail_test "$name"
+		return $status
+	fi
+	found=$(printf '%s' "$output" | grep -c "$grep")
+	if [ x"$found" = x"$num" ]; then
+	    subunit_pass_test "$name"
+	else
+	    printf 'GREP: "%s" found "%d" times, expected "%d" in output:\n%s'\
+		   "$grep" "$found" "$num" "$output" |
+		subunit_fail_test "$name"
+	fi
+	return $status
+}
+
 testit_expect_failure()
 {
 	name="$1"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list