From 6e55f609b9cfb7255a8a8f412e6eb0ad57db8380 Mon Sep 17 00:00:00 2001 From: Jule Anger Date: Mon, 7 Mar 2022 10:13:33 +0100 Subject: [PATCH 1/2] s3:tests: Add a test to check the output of smbstatus. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14999 Signed-off-by: Jule Anger Reviewed-by: Volker Lendecke (cherry picked from commit b108e039ab13ee9f8f2c629c5b57085a462d14db) --- selftest/knownfail.d/smbstatus | 1 + source3/script/tests/test_smbstatus.sh | 98 ++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 selftest/knownfail.d/smbstatus diff --git a/selftest/knownfail.d/smbstatus b/selftest/knownfail.d/smbstatus new file mode 100644 index 00000000000..50ea1c9a1b4 --- /dev/null +++ b/selftest/knownfail.d/smbstatus @@ -0,0 +1 @@ +samba3.blackbox.smbstatus.test_output\(fileserver:local\) diff --git a/source3/script/tests/test_smbstatus.sh b/source3/script/tests/test_smbstatus.sh index b29ba15c377..20846f6d4ed 100755 --- a/source3/script/tests/test_smbstatus.sh +++ b/source3/script/tests/test_smbstatus.sh @@ -144,6 +144,100 @@ EOF return 0 } +test_smbstatus_output() +{ + local cmdfile=$PREFIX/smbclient_commands + local tmpfile=$PREFIX/smbclient_lock_file + local file=smbclient_lock_file + local status_shares=smbstatus_output_shares + local status_processes=smbstatus_output_processes + local status_locks=smbstatus_output_locks + + cat > $tmpfile < $cmdfile < $status_shares +!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --processes > $status_processes +!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --locks > $status_locks +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" + return 1 + fi + + out=$(cat $PREFIX/$status_processes) + echo "$out" | grep -c 'PID *Username' + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: Could not start smbstatus" + echo "$out" + return 1 + fi + echo "$out" | grep -c "$USERNAME" + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: open connection not found" + echo "$out" + return 1 + fi + + out=$(cat $PREFIX/$status_shares) + echo "$out" | grep -c 'Service *pid' + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: Could not start smbstatus" + echo "$out" + return 1 + fi + echo "$out" | grep -c "tmp" + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: shares not found" + echo "$out" + return 1 + fi + + out=$(cat $PREFIX/$status_locks) + echo "$out" | grep -c "Locked files:" + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: locked file not found" + echo "$out" + return 1 + fi + echo "$out" | grep -c "$file" + ret=$? + if [ $ret -eq 1 ] ; then + echo "Failed: wrong file locked" + echo "$out" + return 1 + fi + + rm $PREFIX/$status_shares + rm $PREFIX/$status_processes + rm $PREFIX/$status_locks + + return 0 +} + testit "plain" \ test_smbstatus || \ failed=`expr $failed + 1` @@ -152,4 +246,8 @@ testit "resolve_uids" \ test_smbstatus || \ failed=`expr $failed + 1` +testit "test_output" \ + test_smbstatus_output || \ + failed=`expr $failed + 1` + testok $0 $failed -- 2.32.0 From 068d12f5f2919966d838cbb4487166a811c3ca80 Mon Sep 17 00:00:00 2001 From: Jule Anger Date: Fri, 4 Mar 2022 09:02:28 +0100 Subject: [PATCH 2/2] s3:utils: assign ids to struct to list shares correctly The commit "99d1f1fa10d smbd: Remove unused "struct connections_key"" removes also the assignment of information to connections_data, which are needed to list shares. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14999 Signed-off-by: Jule Anger Reviewed-by: Volker Lendecke Autobuild-User(master): Jule Anger Autobuild-Date(master): Mon Mar 7 15:27:48 UTC 2022 on sn-devel-184 (cherry picked from commit 9e9e6955ba93691545ea35e39ebdc285cd484406) --- selftest/knownfail.d/smbstatus | 1 - source3/utils/conn_tdb.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 selftest/knownfail.d/smbstatus diff --git a/selftest/knownfail.d/smbstatus b/selftest/knownfail.d/smbstatus deleted file mode 100644 index 50ea1c9a1b4..00000000000 --- a/selftest/knownfail.d/smbstatus +++ /dev/null @@ -1 +0,0 @@ -samba3.blackbox.smbstatus.test_output\(fileserver:local\) diff --git a/source3/utils/conn_tdb.c b/source3/utils/conn_tdb.c index 24fd460c081..1d19d04f1aa 100644 --- a/source3/utils/conn_tdb.c +++ b/source3/utils/conn_tdb.c @@ -120,6 +120,8 @@ static int traverse_tcon_fn(struct smbXsrv_tcon_global0 *global, ZERO_STRUCT(data); + data.pid = global->server_id; + data.cnum = global->tcon_global_id; fstrcpy(data.servicename, global->share_name); data.uid = sess.uid; data.gid = sess.gid; -- 2.32.0