From d9c88a56dc451be09e8c9fc9aa8857e312fcb444 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Aug 2013 13:49:39 -0700 Subject: 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 Reviewed-by: Michael Adam --- source3/client/client.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'source3/client') diff --git a/source3/client/client.c b/source3/client/client.c index ad4a87547e..581b9c6115 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -56,6 +56,7 @@ static char *cmdstr = NULL; const char *cmd_ptr = NULL; static int io_bufsize = 0; /* we use the default size */ +static int io_timeout = (CLIENT_TIMEOUT/1000); /* Per operation timeout (in seconds). */ static int name_type = 0x20; static int max_protocol = -1; @@ -4564,6 +4565,31 @@ int cmd_iosize(void) return 0; } +/**************************************************************************** + 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 (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 ****************************************************************************/ @@ -4672,6 +4698,7 @@ static struct { {"symlink",cmd_symlink," create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}}, {"tar",cmd_tar,"tar [IXFqbgNan] current directory to/from ",{COMPL_NONE,COMPL_NONE}}, {"tarmode",cmd_tarmode," tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}}, + {"timeout",cmd_timeout,"timeout - 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 : remove a POSIX lock",{COMPL_REMOTE,COMPL_REMOTE}}, {"volume",cmd_volume,"print the volume name",{COMPL_NONE,COMPL_NONE}}, @@ -4775,6 +4802,7 @@ static int process_command_string(const char *cmd_in) if (!NT_STATUS_IS_OK(status)) { return 1; } + cli_set_timeout(cli, io_timeout*1000); } while (cmd[0] != '\0') { @@ -5202,6 +5230,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) { @@ -5236,6 +5266,7 @@ static int do_host_query(const char *query_host) return 1; } + cli_set_timeout(cli, io_timeout*1000); browse_host(true); /* Ensure that the host can do IPv4 */ @@ -5271,6 +5302,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); @@ -5297,6 +5329,7 @@ static int do_tar_op(const char *base_directory) if (!NT_STATUS_IS_OK(status)) { return 1; } + cli_set_timeout(cli, io_timeout*1000); } recurse=true; @@ -5332,6 +5365,7 @@ 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); @@ -5368,6 +5402,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" }, -- cgit