[PATCH] Add --quiet option to smbclient
Justin Stephenson
jstephen at redhat.com
Tue Jun 26 14:33:58 UTC 2018
Hello,
Please see attached patch to add the --quiet smbclient argument to suppress
the help log message printed automatically after establishing a smbclient
connection.
Thank you.
Kind regards,
Justin Stephenson
-------------- next part --------------
From d07147afecea61c96af52917e348e31cc4de127d Mon Sep 17 00:00:00 2001
From: Justin Stephenson <jstephen at redhat.com>
Date: Mon, 25 Jun 2018 09:58:56 -0400
Subject: [PATCH 1/2] s3:client: Add --quiet option to smbclient
Add quiet command-line argument to allow suppressing the help log
message printed automatically after establishing a smbclient connection
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13485
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
---
source3/client/client.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/source3/client/client.c b/source3/client/client.c
index 8dbf7474d25..f112b8c4ac1 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -52,6 +52,7 @@ static int port = 0;
static char *service;
static char *desthost;
static bool grepable = false;
+static bool quiet = false;
static char *cmdstr = NULL;
const char *cmd_ptr = NULL;
@@ -6066,7 +6067,9 @@ static int process_stdin(void)
{
int rc = 0;
- d_printf("Try \"help\" to get a list of possible commands.\n");
+ if (!quiet) {
+ d_printf("Try \"help\" to get a list of possible commands.\n");
+ }
while (!finished) {
TALLOC_CTX *frame = talloc_stackframe();
@@ -6336,6 +6339,7 @@ int main(int argc,char *argv[])
{ "timeout", 't', POPT_ARG_INT, &io_timeout, 'b', "Changes the per-operation timeout", "SECONDS" },
{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
{ "grepable", 'g', POPT_ARG_NONE, NULL, 'g', "Produce grepable output" },
+ { "quiet", 'q', POPT_ARG_NONE, NULL, 'q', "Suppress help message" },
{ "browse", 'B', POPT_ARG_NONE, NULL, 'B', "Browse SMB servers using DNS" },
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
@@ -6458,6 +6462,9 @@ int main(int argc,char *argv[])
case 'g':
grepable=true;
break;
+ case 'q':
+ quiet=true;
+ break;
case 'e':
smb_encrypt=true;
break;
--
2.14.4
From 65f5ec9bef9cca5f1443895f191f55f25dcf189e Mon Sep 17 00:00:00 2001
From: Justin Stephenson <jstephen at redhat.com>
Date: Mon, 25 Jun 2018 10:29:28 -0400
Subject: [PATCH 2/2] s3:tests: Add test for smbclient --quiet
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13485
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
---
source3/script/tests/test_smbclient_s3.sh | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index 96bd5eb3f31..9a5170ad664 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -1606,6 +1606,36 @@ EOF
return 0
}
+test_server_quiet_message()
+{
+ tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+ cat > $tmpfile <<EOF
+ls
+quit
+EOF
+ cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS --quiet < $tmpfile 2>&1'
+ eval echo "$cmd"
+ out=`eval $cmd`
+ ret=$?
+ rm -f $tmpfile
+
+ if [ $ret -ne 0 ] ; then
+ echo "$out"
+ echo "failed to connect error $ret"
+ return 1
+ fi
+
+ echo "$out" | grep 'Try "help" to get a list of possible commands.'
+ ret=$?
+ if [ $ret -eq 0 ] ; then
+ echo "$out"
+ echo 'failed - quiet should skip this message.'
+ return 1
+ fi
+
+ return 0
+}
+
# Test xattr_stream correctly reports mode.
# BUG: https://bugzilla.samba.org/show_bug.cgi?id=13380
@@ -1797,6 +1827,10 @@ testit "server os message" \
test_server_os_message || \
failed=`expr $failed + 1`
+testit "test server quiet message" \
+ test_server_quiet_message || \
+ failed=`expr $failed + 1`
+
testit "setmode test" \
test_setmode || \
failed=`expr $failed + 1`
--
2.14.4
More information about the samba-technical
mailing list