Files
bpfire/src/patches/samba/samba-3.6.99-add_timeout_option_to_smbclient.patch
Arne Fitzenreiter 1d13e6373a samba: add current RHEL6 patches
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
2017-05-28 10:40:09 +02:00

148 lines
5.3 KiB
Diff

commit e8f6a7df1b5ae7f7275ac59b8c21b82de1922c3b
Author: Jeremy Allison <jra@samba.org>
AuthorDate: Fri Aug 16 13:49:39 2013 -0700
Commit: Andreas Schneider <asn@samba.org>
CommitDate: Wed Feb 5 11:50:28 2014 +0100
Add new "timeout" command and -t option to smbclient to set the per-operation timeout.
This is needed as once SMB3 encryption is selected the server
response time can be very slow when requesting large numbers
(256) of large encrypted packets (1MB) from a Windows 2012
virtual machine. This allows clients to tune their allowable
wait time.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit d9c88a56dc451be09e8c9fc9aa8857e312fcb444)
---
source3/client/client.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/source3/client/client.c b/source3/client/client.c
index f6e42f6..aa16b14 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -54,7 +54,12 @@ static bool grepable = false;
static char *cmdstr = NULL;
const char *cmd_ptr = NULL;
+/* 30 second timeout on most commands */
+#define CLIENT_TIMEOUT (30*1000)
+#define SHORT_TIMEOUT (5*1000)
+
static int io_bufsize = 524288;
+static int io_timeout = (CLIENT_TIMEOUT/1000); /* Per operation timeout (in seconds). */
static int name_type = 0x20;
static int max_protocol = PROTOCOL_NT1;
@@ -64,10 +69,6 @@ static int cmd_help(void);
#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
-/* 30 second timeout on most commands */
-#define CLIENT_TIMEOUT (30*1000)
-#define SHORT_TIMEOUT (5*1000)
-
/* value for unused fid field in trans2 secondary request */
#define FID_UNUSED (0xFFFF)
@@ -4264,6 +4265,31 @@ int cmd_iosize(void)
}
/****************************************************************************
+ timeout command
+***************************************************************************/
+
+static int cmd_timeout(void)
+{
+ TALLOC_CTX *ctx = talloc_tos();
+ char *buf;
+
+ if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
+ unsigned int old_timeout = cli_set_timeout(cli, 0);
+ cli_set_timeout(cli, old_timeout);
+ d_printf("timeout <n> (per-operation timeout "
+ "in seconds - currently %u).\n",
+ old_timeout/1000);
+ return 1;
+ }
+
+ io_timeout = strtol(buf,NULL,0);
+ cli_set_timeout(cli, io_timeout*1000);
+ d_printf("io_timeout per operation is now %d\n", io_timeout);
+ return 0;
+}
+
+
+/****************************************************************************
history
****************************************************************************/
static int cmd_history(void)
@@ -4369,6 +4395,7 @@ static struct {
{"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
{"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
{"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
+ {"timeout",cmd_timeout,"timeout <number> - set the per-operation timeout in seconds (default 20)",{COMPL_NONE,COMPL_NONE}},
{"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
{"unlock",cmd_unlock,"unlock <fnum> <hex-start> <hex-len> : remove a POSIX lock",{COMPL_REMOTE,COMPL_REMOTE}},
{"volume",cmd_volume,"print the volume name",{COMPL_NONE,COMPL_NONE}},
@@ -4465,6 +4492,7 @@ static int process_command_string(const char *cmd_in)
if (!cli) {
return 1;
}
+ cli_set_timeout(cli, io_timeout*1000);
}
while (cmd[0] != '\0') {
@@ -4942,6 +4970,8 @@ static int process(const char *base_directory)
return 1;
}
+ cli_set_timeout(cli, io_timeout*1000);
+
if (base_directory && *base_directory) {
rc = do_cd(base_directory);
if (rc) {
@@ -4972,6 +5002,7 @@ static int do_host_query(const char *query_host)
if (!cli)
return 1;
+ cli_set_timeout(cli, io_timeout*1000);
browse_host(true);
/* Ensure that the host can do IPv4 */
@@ -5003,6 +5034,7 @@ static int do_host_query(const char *query_host)
return 1;
}
+ cli_set_timeout(cli, io_timeout*1000);
list_servers(lp_workgroup());
cli_shutdown(cli);
@@ -5026,6 +5058,7 @@ static int do_tar_op(const char *base_directory)
max_protocol, port, name_type);
if (!cli)
return 1;
+ cli_set_timeout(cli, io_timeout*1000);
}
recurse=true;
@@ -5091,6 +5124,8 @@ static int do_message_op(struct user_auth_info *a_info)
return 1;
}
+ cli_set_timeout(cli, io_timeout*1000);
+
send_message(get_cmdline_auth_info_username(a_info));
cli_shutdown(cli);
@@ -5127,6 +5162,7 @@ static int do_message_op(struct user_auth_info *a_info)
{ "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
{ "send-buffer", 'b', POPT_ARG_INT, &io_bufsize, 'b', "Changes the transmit/send buffer", "BYTES" },
+ { "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" },
{ "browse", 'B', POPT_ARG_NONE, NULL, 'B', "Browse SMB servers using DNS" },