From fb183ebd9207cac7b98aff9f672c06b0b50609ce Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 16 Oct 2006 23:27:38 +0000 Subject: r19353: Add "timeout" command for rpcclient. Guenther (This used to be commit 4106a56d3f4edb2e07e876204743a1cb028c950a) --- source3/rpcclient/cmd_netlogon.c | 4 ++-- source3/rpcclient/cmd_samr.c | 2 +- source3/rpcclient/rpcclient.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 5ae449a68c..a1093d693f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -59,7 +59,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); @@ -90,7 +90,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 4ce613bde1..a899efb64b 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -787,7 +787,7 @@ static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli, goto done; /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol, &num_members, &group_rids, diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 6e9bc81884..ae04f197ed 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -27,6 +27,7 @@ DOM_SID domain_sid; static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; static enum pipe_auth_level pipe_default_auth_level = PIPE_AUTH_LEVEL_NONE; +static unsigned int timeout = 0; /* List to hold groups of commands. * @@ -398,6 +399,39 @@ static NTSTATUS cmd_seal(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, return cmd_set_ss_level(); } +static NTSTATUS cmd_timeout(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + struct cmd_list *tmp; + + if (argc > 2) { + printf("Usage: %s timeout\n", argv[0]); + return NT_STATUS_OK; + } + + if (argc == 2) { + timeout = atoi(argv[1]); + + for (tmp = cmd_list; tmp; tmp = tmp->next) { + + struct cmd_set *tmp_set; + + for (tmp_set = tmp->cmd_set; tmp_set->name; tmp_set++) { + if (tmp_set->rpc_pipe == NULL) { + continue; + } + + cli_set_timeout(tmp_set->rpc_pipe->cli, timeout); + } + } + } + + printf("timeout is %d\n", timeout); + + return NT_STATUS_OK; +} + + static NTSTATUS cmd_none(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -445,6 +479,7 @@ static struct cmd_set rpcclient_commands[] = { { "seal", RPC_RTYPE_NTSTATUS, cmd_seal, NULL, -1, NULL, "Force RPC pipe connections to be sealed", "" }, { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL, -1, NULL, "Force RPC pipe connections to be sealed with 'schannel'. Assumes valid machine account to this domain controller.", "" }, { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL, -1, NULL, "Force RPC pipe connections to be signed (not sealed) with 'schannel'. Assumes valid machine account to this domain controller.", "" }, + { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL, -1, NULL, "Set timeout for RPC operations", "" }, { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL, -1, NULL, "Force RPC pipe connections to have no special properties", "" }, { NULL } @@ -813,6 +848,8 @@ out_free: /* Load command lists */ + timeout = cli_set_timeout(cli, 10000); + cmd_set = rpcclient_command_list; while(*cmd_set) { -- cgit