The Samba-Bugzilla – Attachment 15009 Details for
Bug 13793
smbstatus should optionally allow to print usernames for locked files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for 4.10
v4-10-smbstatus_resolve_ids.patch (text/plain), 13.59 KB, created by
Andreas Schneider
on 2019-03-27 15:56:09 UTC
(
hide
)
Description:
patch for 4.10
Filename:
MIME Type:
Creator:
Andreas Schneider
Created:
2019-03-27 15:56:09 UTC
Size:
13.59 KB
patch
obsolete
>From fcd4ae3c76ef6ca801cf833c5ae665ec00312679 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 8 Jan 2019 12:21:36 +0100 >Subject: [PATCH 1/4] s3:utils: Use C99 initializer for poptOption in smbstatus > >Signed-off-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> >(cherry picked from commit 83d25ca9d90897925a4431dd55e68c78244900b3) >--- > source3/utils/status.c | 108 ++++++++++++++++++++++++++++++++++++----- > 1 file changed, 96 insertions(+), 12 deletions(-) > >diff --git a/source3/utils/status.c b/source3/utils/status.c >index 0fe2c820eb2..0acdfd3221a 100644 >--- a/source3/utils/status.c >+++ b/source3/utils/status.c >@@ -511,18 +511,102 @@ int main(int argc, const char *argv[]) > poptContext pc; > struct poptOption long_options[] = { > POPT_AUTOHELP >- {"processes", 'p', POPT_ARG_NONE, NULL, 'p', "Show processes only" }, >- {"verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Be verbose" }, >- {"locks", 'L', POPT_ARG_NONE, NULL, 'L', "Show locks only" }, >- {"shares", 'S', POPT_ARG_NONE, NULL, 'S', "Show shares only" }, >- {"notify", 'N', POPT_ARG_NONE, NULL, 'N', "Show notifies" }, >- {"user", 'u', POPT_ARG_STRING, &username, 'u', "Switch to user" }, >- {"brief", 'b', POPT_ARG_NONE, NULL, 'b', "Be brief" }, >- {"profile", 'P', POPT_ARG_NONE, NULL, 'P', "Do profiling" }, >- {"profile-rates", 'R', POPT_ARG_NONE, NULL, 'R', "Show call rates" }, >- {"byterange", 'B', POPT_ARG_NONE, NULL, 'B', "Include byte range locks"}, >- {"numeric", 'n', POPT_ARG_NONE, NULL, 'n', "Numeric uid/gid"}, >- {"fast", 'f', POPT_ARG_NONE, NULL, 'f', "Skip checks if processes still exist"}, >+ { >+ .longName = "processes", >+ .shortName = 'p', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'p', >+ .descrip = "Show processes only", >+ }, >+ { >+ .longName = "verbose", >+ .shortName = 'v', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'v', >+ .descrip = "Be verbose", >+ }, >+ { >+ .longName = "locks", >+ .shortName = 'L', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'L', >+ .descrip = "Show locks only", >+ }, >+ { >+ .longName = "shares", >+ .shortName = 'S', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'S', >+ .descrip = "Show shares only", >+ }, >+ { >+ .longName = "notify", >+ .shortName = 'N', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'N', >+ .descrip = "Show notifies", >+ }, >+ { >+ .longName = "user", >+ .shortName = 'u', >+ .argInfo = POPT_ARG_STRING, >+ .arg = &username, >+ .val = 'u', >+ .descrip = "Switch to user", >+ }, >+ { >+ .longName = "brief", >+ .shortName = 'b', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'b', >+ .descrip = "Be brief", >+ }, >+ { >+ .longName = "profile", >+ .shortName = 'P', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'P', >+ .descrip = "Do profiling", >+ }, >+ { >+ .longName = "profile-rates", >+ .shortName = 'R', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'R', >+ .descrip = "Show call rates", >+ }, >+ { >+ .longName = "byterange", >+ .shortName = 'B', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'B', >+ .descrip = "Include byte range locks" >+ }, >+ { >+ .longName = "numeric", >+ .shortName = 'n', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'n', >+ .descrip = "Numeric uid/gid" >+ }, >+ { >+ .longName = "fast", >+ .shortName = 'f', >+ .argInfo = POPT_ARG_NONE, >+ .arg = NULL, >+ .val = 'f', >+ .descrip = "Skip checks if processes still exist" >+ }, > POPT_COMMON_SAMBA > POPT_TABLEEND > }; >-- >2.21.0 > > >From bcad15e2d2ce385e553a91bb4d1697dc0beadff9 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Mon, 18 Feb 2019 14:11:32 +0100 >Subject: [PATCH 2/4] 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@samba.org> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >(cherry picked from commit ffad76ae260ac33926db87c61aede5b66d9b09e6) >--- > source3/utils/status.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > >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"); >-- >2.21.0 > > >From 92c09dc990fe3c065f4ee95fbd37756287706893 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Wed, 13 Mar 2019 12:00:11 +0100 >Subject: [PATCH 3/4] selftest: Add smbstatus to testhelper > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13793 > >Signed-off-by: Andreas Schneider <asn@samba.org> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> >(cherry picked from commit 6106b8a053e06699c332fd1a6d7636f550422cc7) >--- > selftest/selftesthelpers.py | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py >index acce6d24cce..39b8a1782c6 100644 >--- a/selftest/selftesthelpers.py >+++ b/selftest/selftesthelpers.py >@@ -208,3 +208,4 @@ smbget = binpath('smbget') > rpcclient = binpath('rpcclient') > smbcacls = binpath('smbcacls') > smbcontrol = binpath('smbcontrol') >+smbstatus = binpath('smbstatus') >-- >2.21.0 > > >From a75b287efc896b70a05f79c5342577ec50cbd5ad Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Wed, 13 Mar 2019 12:00:27 +0100 >Subject: [PATCH 4/4] 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@samba.org> >Reviewed-by: Andrew Bartlett <abartlet@samba.org> > >Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> >Autobuild-Date(master): Wed Mar 27 14:33:35 UTC 2019 on sn-devel-144 > >(cherry picked from commit 2e7f4b1d3701b9da32e03dcee1095711945f22b8) >--- > source3/script/tests/test_smbstatus.sh | 155 +++++++++++++++++++++++++ > source3/selftest/tests.py | 6 +- > 2 files changed, 160 insertions(+), 1 deletion(-) > create mode 100755 source3/script/tests/test_smbstatus.sh > >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 e8d516573dd..1eb220ddcce 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", >-- >2.21.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
asn
:
review?
(
gd
)
ab
:
review+
Actions:
View
Attachments on
bug 13793
: 15009