[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu Dec 29 21:15:01 UTC 2022


The branch, master has been updated
       via  f28553105be s3:rpc_server/srvsvc: make sure we (re-)load all shares as root.
       via  a00c7395fbc selftest: add samba3.blackbox.registry_share
      from  08be04bb930 s4:setup:tests: Use system ldbdump if we build with system ldb

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


- Log -----------------------------------------------------------------
commit f28553105be7465026bcc0fcbbed6a1a8c2133dd
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

commit a00c7395fbc7974a61a70ae54ea6ae6349933de2
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>

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

Summary of changes:
 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 +++
 4 files changed, 89 insertions(+), 12 deletions(-)
 create mode 100755 source3/script/tests/test_registry_share.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index a20f2fa3365..917c2957b97 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 8a0c63fd50e..7ca35856d96 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -644,30 +644,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 82038321d1b..a40316ef532 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -1497,6 +1497,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),


-- 
Samba Shared Repository



More information about the samba-cvs mailing list