[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Mar 27 14:34:01 UTC 2019


The branch, master has been updated
       via  2e7f4b1d370 s3:tests: Add test for smbstatus and smbstatus --resolve_uids
       via  6106b8a053e selftest: Add smbstatus to testhelper
       via  ffad76ae260 s3:utils: Add 'smbstatus -L --resolve-uids' to show usernames
       via  991d32a1756 s4/torture: Update winsreplication to only use IPv4 addresses
       via  a4d433aede8 selftest: Restore IPs 12-16 for selftest client
      from  3e1d8ab1255 libsmb: Change cli_posix_readlink to return talloc'ed target

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


- Log -----------------------------------------------------------------
commit 2e7f4b1d3701b9da32e03dcee1095711945f22b8
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Mar 13 12:00:27 2019 +0100

    s3:tests: Add test for smbstatus and smbstatus --resolve_uids
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13793
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Wed Mar 27 14:33:35 UTC 2019 on sn-devel-144

commit 6106b8a053e06699c332fd1a6d7636f550422cc7
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Mar 13 12:00:11 2019 +0100

    selftest: Add smbstatus to testhelper
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13793
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ffad76ae260ac33926db87c61aede5b66d9b09e6
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 18 14:11:32 2019 +0100

    s3:utils: Add 'smbstatus -L --resolve-uids' to show usernames
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13793
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 991d32a1756e92db728abf17e12457fc9ac8c9b1
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Tue Mar 26 18:06:16 2019 +1300

    s4/torture: Update winsreplication to only use IPv4 addresses
    
    This test was failing now that the client had an IPv6 address, however,
    the test was marked as flapping so this failure wasn't obvious.
    
    Use iface_list_n_is_v4() to filter out only the IPv4 addresses, as
    that's all the test cares about.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit a4d433aede8e08c1fec91ddb9ee7754275a13437
Author: Tim Beale <timbeale at catalyst.net.nz>
Date:   Mon Mar 18 17:55:39 2019 +1300

    selftest: Restore IPs 12-16 for selftest client
    
    The assumption that tests only used the .11 IP was wrong. The
    winsreplication test tries to use multiple different IPs - CI doesn't
    fail when we remove the additional IPs, but it starts to skip test
    cases.
    
    + Update get_interfaces_config() and get_ipv4_addr() so we can add
    multiple different IPs for the same host.
    + Update selftest.pl so the client gets 6 IP addresses.
    + Update comments to better reflect this dependency.
    
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 selftest/selftest.pl                   |   5 +-
 selftest/selftesthelpers.py            |   1 +
 selftest/target/Samba.pm               |  33 +++++--
 source3/script/tests/test_smbstatus.sh | 155 +++++++++++++++++++++++++++++++++
 source3/selftest/tests.py              |   6 +-
 source3/utils/status.c                 |  27 +++++-
 source4/torture/nbt/winsreplication.c  |  12 ++-
 7 files changed, 223 insertions(+), 16 deletions(-)
 create mode 100755 source3/script/tests/test_smbstatus.sh


Changeset truncated at 500 lines:

diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 52109e99b6f..228bb29ecfe 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -514,7 +514,10 @@ foreach (@opt_include) {
 	push (@includes, read_test_regexes($_));
 }
 
-my $interfaces = Samba::get_interfaces_config("client");
+# We give the selftest client 6 different IPv4 addresses to use. Most tests
+# only use the first (.11) IP. Note that winsreplication.c is one test that
+# uses the other IPs (search for iface_list_count()).
+my $interfaces = Samba::get_interfaces_config("client", 6);
 
 my $clientdir = "$prefix_abs/client";
 
diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py
index 7513c265d17..1afabf3cdca 100644
--- a/selftest/selftesthelpers.py
+++ b/selftest/selftesthelpers.py
@@ -201,3 +201,4 @@ smbget = binpath('smbget')
 rpcclient = binpath('rpcclient')
 smbcacls = binpath('smbcacls')
 smbcontrol = binpath('smbcontrol')
+smbstatus = binpath('smbstatus')
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm
index f7332da893e..6f28a017b17 100644
--- a/selftest/target/Samba.pm
+++ b/selftest/target/Samba.pm
@@ -437,12 +437,11 @@ sub get_interface($)
 		localnt4dc9       => 9,
 		# 10 is spare
 
-		# 11 is used by selftest.pl for the client interface
+		# 11-16 are used by selftest.pl for the client.conf. Most tests only
+		# use the first .11 IP. However, some tests (like winsreplication) rely
+		# on the client having multiple IPs.
 		client            => 11,
 
-		# 12-16 have been historically reserved for the client, although
-		# aren't actually used
-
 		addc_no_nss       => 17,
 		addc_no_ntlm      => 18,
 		idmapadmember     => 19,
@@ -491,9 +490,15 @@ sub get_interface($)
 
 sub get_ipv4_addr
 {
-	(my $hostname) = @_;
+	my ($hostname, $iface_num) = @_;
 	my $swiface = Samba::get_interface($hostname);
 
+	# Handle testenvs with multiple different addresses, i.e. IP multihoming.
+	# Currently only the selftest client has multiple IPv4 addresses.
+	if (defined($iface_num)) {
+		$swiface += $iface_num;
+	}
+
 	return "127.0.0.$swiface";
 }
 
@@ -509,11 +514,23 @@ sub get_ipv6_addr
 # addresses for testenv
 sub get_interfaces_config
 {
-	(my $hostname) = @_;
-	my $ipv4_addr = Samba::get_ipv4_addr($hostname);
+	my ($hostname, $num_ips) = @_;
+	my $interfaces = "";
+
+	# We give the client.conf multiple different IPv4 addresses.
+	# All other testenvs generally just have one IPv4 address.
+	if (! defined($num_ips)) {
+		$num_ips = 1;
+	}
+	for (my $i = 0; $i < $num_ips; $i++) {
+		my $ipv4_addr = Samba::get_ipv4_addr($hostname, $i);
+		$interfaces .= "$ipv4_addr/8 ";
+	}
+
 	my $ipv6_addr = Samba::get_ipv6_addr($hostname);
+	$interfaces .= "$ipv6_addr/64";
 
-	return "$ipv4_addr/8 $ipv6_addr/64";
+	return $interfaces;
 }
 
 sub cleanup_child($$)
diff --git a/source3/script/tests/test_smbstatus.sh b/source3/script/tests/test_smbstatus.sh
new file mode 100755
index 00000000000..b29ba15c377
--- /dev/null
+++ b/source3/script/tests/test_smbstatus.sh
@@ -0,0 +1,155 @@
+#!/bin/sh
+
+# This runs smbstatus tests
+
+if [ $# -lt 12 ]; then
+    echo "Usage: test_smbstatus.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT CONFIGURATION PROTOCOL"
+    exit 1
+fi
+
+SERVER="${1}"
+SERVER_IP="${2}"
+DOMAIN="${3}"
+USERNAME="${4}"
+PASSWORD="${5}"
+USERID="${6}"
+LOCAL_PATH="${7}"
+PREFIX="${8}"
+SMBCLIENT="${9}"
+SMBSTATUS="${10}"
+CONFIGURATION="${11}"
+PROTOCOL="${12}"
+
+shift 12
+
+RAWARGS="${CONFIGURATION} -m${PROTOCOL}"
+ADDARGS="${RAWARGS} $@"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+test_smbstatus()
+{
+    local cmdfile=$PREFIX/smbclient_commands
+    local tmpfile=$PREFIX/smclient_lock_file
+    local file=smclient_lock_file
+    local cmd=""
+    local ret=0
+    local userid=$(id -u $USERNAME)
+
+    cat > $tmpfile <<EOF
+What a Wurst!
+EOF
+    cat > $cmdfile <<EOF
+lcd $PREFIX_ABS
+put $file
+open $file
+!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS
+close 1
+rm $file
+quit
+EOF
+
+    cmd="CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $cmdfile 2>&1"
+    eval echo "$cmd"
+    out=$(eval $cmd)
+    ret=$?
+    rm -f $cmpfile
+    rm -f $tmpfile
+
+    if [ $ret -ne 0 ] ; then
+       echo "Failed to run smbclient with error $ret"
+       echo "$out"
+       false
+       return
+    fi
+
+    echo "$out" | grep -c 'NT_STATUS_'
+    ret=$?
+    if [ $ret -eq 0 ] ; then
+       echo "Failed: got an NT_STATUS error!"
+       echo "$out"
+       false
+       return
+    fi
+
+    echo "$out" | grep "$userid[ ]*DENY_NONE"
+    ret=$?
+    if [ $ret != 0 ] ; then
+        echo "Failed to find userid in smbstatus locked file output"
+        echo "$out"
+        false
+        return
+    fi
+
+    return 0
+}
+
+test_smbstatus_resolve_uids()
+{
+    local cmdfile=$PREFIX/smbclient_commands
+    local tmpfile=$PREFIX/smclient_lock_file
+    local file=smclient_lock_file
+    local cmd=""
+    local ret=0
+    local userid=$(id -u $USERNAME)
+
+    cat > $tmpfile <<EOF
+What a Wurst!
+EOF
+    cat > $cmdfile <<EOF
+lcd $PREFIX_ABS
+put $file
+open $file
+!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --resolve-uids
+close 1
+rm $file
+quit
+EOF
+
+    cmd="CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $cmdfile 2>&1"
+    eval echo "$cmd"
+    out=$(eval $cmd)
+    ret=$?
+    rm -f $cmpfile
+    rm -f $tmpfile
+
+    if [ $ret -ne 0 ] ; then
+       echo "Failed to run smbclient with error $ret"
+       echo "$out"
+       false
+       return
+    fi
+
+    echo "$out" | grep -c 'NT_STATUS_'
+    ret=$?
+    if [ $ret -eq 0 ] ; then
+       echo "Failed: got an NT_STATUS error!"
+       echo "$out"
+       false
+       return
+    fi
+
+    echo "$out" | grep "$USERNAME[ ]*DENY_NONE"
+    ret=$?
+    if [ $ret != 0 ] ; then
+        echo "Failed to find userid in smbstatus locked file output"
+        echo "$out"
+        false
+        return
+    fi
+
+    return 0
+}
+
+testit "plain" \
+    test_smbstatus || \
+    failed=`expr $failed + 1`
+
+testit "resolve_uids" \
+    test_smbstatus || \
+    failed=`expr $failed + 1`
+
+testok $0 $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index f3fe90fa6ec..147e53da558 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -30,6 +30,7 @@ from selftesthelpers import smbget, smbcacls, smbcquotas, ntlm_auth3
 from selftesthelpers import valgrindify, smbtorture4_testsuites
 from selftesthelpers import smbtorture4_options
 from selftesthelpers import smbcontrol
+from selftesthelpers import smbstatus
 smbtorture4_options.extend([
     '--option=torture:sharedelay=100000',
    '--option=torture:writetimeupdatedelay=500000',
@@ -361,7 +362,10 @@ for env in ["fileserver"]:
                    '-d', '$PREFIX', '-b', smbclient3,
                    '--subunit', '--', configuration, '-mSMB3'])
 
-plantestsuite("samba3.blackbox.net_usershare", "fileserver:local", [os.path.join(samba3srcdir, "script/tests/test_net_usershare.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3])
+for env in ["fileserver:local"]:
+    plantestsuite("samba3.blackbox.net_usershare", env, [os.path.join(samba3srcdir, "script/tests/test_net_usershare.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3])
+
+    plantestsuite("samba3.blackbox.smbstatus", env, [os.path.join(samba3srcdir, "script/tests/test_smbstatus.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$USERID', '$LOCAL_PATH', '$PREFIX', smbclient3, smbstatus, configuration, "SMB3"])
 
 # TODO encrypted against member, with member creds, and with DC creds
 plantestsuite("samba3.blackbox.net.misc", "nt4_dc:local",
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 0acdfd3221a..d18033778dc 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -122,6 +122,7 @@ static int print_share_mode(struct file_id fid,
 			    const struct share_mode_entry *e,
 			    void *private_data)
 {
+	bool resolve_uids = *((bool *)private_data);
 	static int count;
 
 	if (do_checks && !is_valid_share_mode_entry(e)) {
@@ -130,7 +131,7 @@ static int print_share_mode(struct file_id fid,
 
 	if (count==0) {
 		d_printf("Locked files:\n");
-		d_printf("Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time\n");
+		d_printf("Pid          User(ID)   DenyMode   Access      R/W        Oplock           SharePath   Name   Time\n");
 		d_printf("--------------------------------------------------------------------------------------------------\n");
 	}
 	count++;
@@ -143,7 +144,11 @@ static int print_share_mode(struct file_id fid,
 	if (Ucrit_checkPid(e->pid)) {
 		struct server_id_buf tmp;
 		d_printf("%-11s  ", server_id_str_buf(e->pid, &tmp));
-		d_printf("%-9u  ", (unsigned int)e->uid);
+		if (resolve_uids) {
+			d_printf("%-14s  ", uidtoname(e->uid));
+		} else {
+			d_printf("%-9u  ", (unsigned int)e->uid);
+		}
 		switch (map_share_mode_to_deny_mode(e->share_access,
 						    e->private_options)) {
 			case DENY_NONE: d_printf("DENY_NONE  "); break;
@@ -502,12 +507,17 @@ static bool print_notify_rec(const char *path, struct server_id server,
 	return true;
 }
 
+enum {
+	OPT_RESOLVE_UIDS = 1000,
+};
+
 int main(int argc, const char *argv[])
 {
 	int c;
 	int profile_only = 0;
 	bool show_processes, show_locks, show_shares;
 	bool show_notify = false;
+	bool resolve_uids = false;
 	poptContext pc;
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -607,6 +617,14 @@ int main(int argc, const char *argv[])
 			.val        = 'f',
 			.descrip    = "Skip checks if processes still exist"
 		},
+		{
+			.longName   = "resolve-uids",
+			.shortName  = 0,
+			.argInfo    = POPT_ARG_NONE,
+			.arg        = NULL,
+			.val        = OPT_RESOLVE_UIDS,
+			.descrip    = "Try to resolve UIDs to usernames"
+		},
 		POPT_COMMON_SAMBA
 		POPT_TABLEEND
 	};
@@ -674,6 +692,9 @@ int main(int argc, const char *argv[])
 		case 'f':
 			do_checks = false;
 			break;
+		case OPT_RESOLVE_UIDS:
+			resolve_uids = true;
+			break;
 		}
 	}
 
@@ -778,7 +799,7 @@ int main(int argc, const char *argv[])
 			goto done;
 		}
 
-		result = share_entry_forall(print_share_mode, NULL);
+		result = share_entry_forall(print_share_mode, &resolve_uids);
 
 		if (result == 0) {
 			d_printf("No locked files\n");
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index 5d89f711219..60dd4c4cbef 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -555,6 +555,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 	struct socket_address *nbt_srv_addr;
 	NTSTATUS status;
 	uint32_t i;
+	uint32_t num_ifaces;
 	struct interface *ifaces;
 
 	ctx = talloc_zero(tctx, struct test_wrepl_conflict_conn);
@@ -627,6 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 	if (!ctx->myaddr) return NULL;
 
 	for (i = 0; i < iface_list_count(ifaces); i++) {
+		if (!iface_list_n_is_v4(ifaces, i)) continue;
 		if (strcmp(ctx->myaddr->addr, iface_list_n_ip(ifaces, i)) == 0) continue;
 		ctx->myaddr2 = socket_address_from_strings(tctx, ctx->nbtsock->sock->backend_name, iface_list_n_ip(ifaces, i), 0);
 		if (!ctx->myaddr2) return NULL;
@@ -685,12 +687,16 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
 	ctx->addresses_best[0].owner	= ctx->b.address;
 	ctx->addresses_best[0].ip	= ctx->myaddr->addr;
 
-	ctx->addresses_all_num = iface_list_count(ifaces);
-	ctx->addresses_all = talloc_array(ctx, struct wrepl_ip, ctx->addresses_all_num);
+
+	num_ifaces = iface_list_count(ifaces);
+	ctx->addresses_all = talloc_array(ctx, struct wrepl_ip, num_ifaces);
+	ctx->addresses_all_num = 0;
 	if (!ctx->addresses_all) return NULL;
-	for (i=0; i < ctx->addresses_all_num; i++) {
+	for (i=0; i < num_ifaces; i++) {
+		if (!iface_list_n_is_v4(ifaces, i)) continue;
 		ctx->addresses_all[i].owner	= ctx->b.address;
 		ctx->addresses_all[i].ip	= talloc_strdup(ctx->addresses_all, iface_list_n_ip(ifaces, i));
+		ctx->addresses_all_num++;
 		if (!ctx->addresses_all[i].ip) return NULL;
 	}
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list