The branch, v3-2-test has been updated
       via  b9395cb807b7c2a72ec6ba3cb7429bd2add79c54 (commit)
       via  340c23e150061a20af72e9b9a1762d288660861c (commit)
       via  34bf50b0302ff112af52088b93b40b1bcaf002e8 (commit)
      from  de6f09988d84752e5333cba1fa69c5a685e903b7 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit b9395cb807b7c2a72ec6ba3cb7429bd2add79c54
Author: Stefan Metzmacher <me...@samba.org>
Date:   Fri Apr 3 12:21:17 2009 +0200

    s3:docs: document the --request-timeout option of net
    
    metze
    (cherry picked from commit cdbbc81bad5d53397bf80898cf68d8867cf64cba)
    (cherry picked from commit 1d1e859c4e08fed1775a170ccff459f3a18e13ba)
    (cherry picked from commit 8775968526046f040a2e6ba8697d719b5e3bced8)

commit 340c23e150061a20af72e9b9a1762d288660861c
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Mar 26 20:32:55 2009 +0100

    s3:net: add --request-timeout option
    
    metze
    (cherry picked from commit 257809558bfab3e45703cf8be76357596392a3ea)
    (cherry picked from commit e20b8706401d1a4eee0fe494825deef6ab23ab23)
    (cherry picked from commit d80e02de5714aaa650bef91767ce0775bd2392f5)

commit 34bf50b0302ff112af52088b93b40b1bcaf002e8
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Mar 26 20:29:24 2009 +0100

    s3:net_rpc: don't shutdown a cli_state passed from the caller
    
    This fixes a crash bug if we timeout in net rpc trustdom list.
    
    metze
    
    (cherry picked from commit c0dfe0cf80ee50f395912b7d6aec0d87febd34c0)
    (cherry picked from commit d87563604ca7b1c18c5a84d76726c2a99dc454f8)
    (cherry picked from commit cba4214b963983730bedc792e391b5435889597a)

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages-3/net.8.xml |    9 +++++++++
 source/utils/net.c            |    4 ++++
 source/utils/net.h            |    1 +
 source/utils/net_help.c       |    3 ++-
 source/utils/net_rpc.c        |   17 ++++++++---------
 5 files changed, 24 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/net.8.xml b/docs-xml/manpages-3/net.8.xml
index 876992d..8947bc1 100644
--- a/docs-xml/manpages-3/net.8.xml
+++ b/docs-xml/manpages-3/net.8.xml
@@ -35,6 +35,7 @@
                <arg choice="opt">-P</arg>
                <arg choice="opt">-d debuglevel</arg>
                <arg choice="opt">-V</arg>
+               <arg choice="opt">--request-timeout seconds</arg>
        </cmdsynopsis>
 </refsynopsisdiv>
 
@@ -125,6 +126,14 @@
                </para></listitem>
                </varlistentry>
 
+               <varlistentry>
+               <term>--request-timeout 30</term>
+               <listitem><para>
+               Let client requests timeout after 30 seconds the default is 10
+               seconds.
+               </para></listitem>
+               </varlistentry>
+
                &stdarg.server.debug;
        </variablelist>
 </refsect1>
diff --git a/source/utils/net.c b/source/utils/net.c
index 7c61612..5700511 100644
--- a/source/utils/net.c
+++ b/source/utils/net.c
@@ -72,6 +72,7 @@ const char *opt_comment = "";
 const char *opt_container = NULL;
 int opt_flags = -1;
 int opt_timeout = 0;
+int opt_request_timeout = 0;
 const char *opt_target_workgroup = NULL;
 int opt_machine_pass = 0;
 int opt_localgroup = False;
@@ -571,6 +572,8 @@ NTSTATUS net_make_ipc_connection_ex(const char *domain, 
const char *server,
                d_fprintf(stderr, "Connection failed: %s\n",
                          nt_errstr(nt_status));
                cli = NULL;
+       } else if (opt_request_timeout) {
+               cli_set_timeout(cli, opt_request_timeout * 1000);
        }
 
 done:
@@ -1042,6 +1045,7 @@ static struct functable net_func[] = {
                {"force",       'f', POPT_ARG_NONE,   &opt_force},
                {"stdin",       'i', POPT_ARG_NONE,   &opt_stdin},
                {"timeout",     't', POPT_ARG_INT,    &opt_timeout},
+               {"request-timeout",0,POPT_ARG_INT,    &opt_request_timeout},
                {"machine-pass",'P', POPT_ARG_NONE,   &opt_machine_pass},
                {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup},
                {"verbose",     'v', POPT_ARG_NONE,   &opt_verbose},
diff --git a/source/utils/net.h b/source/utils/net.h
index f043668..7786b26 100644
--- a/source/utils/net.h
+++ b/source/utils/net.h
@@ -100,6 +100,7 @@ extern int opt_reboot;
 extern int opt_force;
 extern int opt_machine_pass;
 extern int opt_timeout;
+extern int opt_request_timeout;
 extern const char *opt_host;
 extern const char *opt_user_name;
 extern const char *opt_password;
diff --git a/source/utils/net_help.c b/source/utils/net_help.c
index c4accf0..6554364 100644
--- a/source/utils/net_help.c
+++ b/source/utils/net_help.c
@@ -48,7 +48,8 @@ int net_common_flags_usage(int argc, const char **argv)
        d_printf("\t-l or --long\t\t\tDisplay full information\n");
        d_printf("\t-V or --version\t\t\tPrint samba version information\n");
        d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
-       d_printf("\t-e or --encrypt\t\tEncrypt SMB transport (UNIX extended 
servers only)\n");
+       d_printf("\t-e or --encrypt\t\t\tEncrypt SMB transport (UNIX extended 
servers only)\n");
+       d_printf("\t--request-timeout\t\tThe timeout for smb and rpc requests 
in seconds\n");
        return -1;
 }
 
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index 1eaa1c6..ceeed63 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -118,6 +118,7 @@ int run_rpc_command(struct cli_state *cli_arg,
        NTSTATUS nt_status;
        DOM_SID *domain_sid;
        const char *domain_name;
+       int ret = -1;
 
        /* make use of cli_state handed over as an argument, if possible */
        if (!cli_arg) {
@@ -139,15 +140,13 @@ int run_rpc_command(struct cli_state *cli_arg,
        
        if (!(mem_ctx = talloc_init("run_rpc_command"))) {
                DEBUG(0, ("talloc_init() failed\n"));
-               cli_shutdown(cli);
-               return -1;
+               goto fail;
        }
        
        nt_status = net_get_remote_domain_sid(cli, mem_ctx, &domain_sid,
                                              &domain_name);
        if (!NT_STATUS_IS_OK(nt_status)) {
-               cli_shutdown(cli);
-               return -1;
+               goto fail;
        }
 
        if (!(conn_flags & NET_FLAGS_NO_PIPE)) {
@@ -160,8 +159,7 @@ int run_rpc_command(struct cli_state *cli_arg,
                        if (!pipe_hnd) {
                                DEBUG(0, ("Could not initialise schannel 
netlogon pipe. Error was %s\n",
                                        nt_errstr(nt_status) ));
-                               cli_shutdown(cli);
-                               return -1;
+                               goto fail;
                        }
                } else {
                        pipe_hnd = cli_rpc_pipe_open_noauth(cli, pipe_idx, 
&nt_status);
@@ -169,8 +167,7 @@ int run_rpc_command(struct cli_state *cli_arg,
                                DEBUG(0, ("Could not initialise pipe %s. Error 
was %s\n",
                                        cli_get_pipe_name(pipe_idx),
                                        nt_errstr(nt_status) ));
-                               cli_shutdown(cli);
-                               return -1;
+                               goto fail;
                        }
                }
        }
@@ -180,6 +177,7 @@ int run_rpc_command(struct cli_state *cli_arg,
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(1, ("rpc command function failed! (%s)\n", 
nt_errstr(nt_status)));
        } else {
+               ret = 0;
                DEBUG(5, ("rpc command function succedded\n"));
        }
                
@@ -189,13 +187,14 @@ int run_rpc_command(struct cli_state *cli_arg,
                }
        }
 
+fail:
        /* close the connection only if it was opened here */
        if (!cli_arg) {
                cli_shutdown(cli);
        }
        
        talloc_destroy(mem_ctx);
-       return (!NT_STATUS_IS_OK(nt_status));
+       return ret;
 }
 
 /** 


-- 
Samba Shared Repository

Reply via email to