The branch, master has been updated via 9e9e6955ba9 s3:utils: assign ids to struct to list shares correctly via b108e039ab1 s3:tests: Add a test to check the output of smbstatus. from e9e2aead1e7 s3:rpcclient: Fix crash in rpcclient
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 9e9e6955ba93691545ea35e39ebdc285cd484406 Author: Jule Anger <jan...@samba.org> Date: Fri Mar 4 09:02:28 2022 +0100 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 <jan...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Jule Anger <jan...@samba.org> Autobuild-Date(master): Mon Mar 7 15:27:48 UTC 2022 on sn-devel-184 commit b108e039ab13ee9f8f2c629c5b57085a462d14db Author: Jule Anger <jan...@samba.org> Date: Mon Mar 7 10:13:33 2022 +0100 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 <jan...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/script/tests/test_smbstatus.sh | 98 ++++++++++++++++++++++++++++++++++ source3/utils/conn_tdb.c | 2 + 2 files changed, 100 insertions(+) Changeset truncated at 500 lines: 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 <<EOF +Hello World! +EOF + cat > $cmdfile <<EOF +lcd $PREFIX_ABS +put $file +open $file +!UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $SMBSTATUS --shares > $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 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; -- Samba Shared Repository