Remove smbclient globals that bled into clidfs.c. Now we only have
authorJeremy Allison <jra@samba.org>
Thu, 15 Jan 2009 00:08:19 +0000 (16:08 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 15 Jan 2009 00:08:19 +0000 (16:08 -0800)
the connections list and authentication structures to worry about.
Jeremy

source3/client/client.c
source3/include/proto.h
source3/lib/netapi/cm.c
source3/libsmb/cliconnect.c
source3/libsmb/clidfs.c
source3/libsmb/clientgen.c
source3/nmbd/nmbd_synclists.c

index cfe33c46c2fb131f29c7f91d4d9e44a03417535a..7172bf98a954ddd80f2f0ebf2bfd5d70fca6919a 100644 (file)
@@ -4052,7 +4052,7 @@ static int process_command_string(const char *cmd_in)
                cli = cli_cm_open(talloc_tos(), NULL,
                                have_ip ? dest_ss_str : desthost,
                                service, true, smb_encrypt,
-                               max_protocol);
+                               max_protocol, port, name_type);
                if (!cli) {
                        return 1;
                }
@@ -4518,7 +4518,7 @@ static int process(const char *base_directory)
        cli = cli_cm_open(talloc_tos(), NULL,
                        have_ip ? dest_ss_str : desthost,
                        service, true, smb_encrypt,
-                       max_protocol);
+                       max_protocol, port, name_type);
        if (!cli) {
                return 1;
        }
@@ -4551,7 +4551,7 @@ static int do_host_query(const char *query_host)
 
        cli = cli_cm_open(talloc_tos(), NULL,
                        query_host, "IPC$", true, smb_encrypt,
-                       max_protocol);
+                       max_protocol, port, name_type);
        if (!cli)
                return 1;
 
@@ -4569,10 +4569,9 @@ static int do_host_query(const char *query_host)
                   else but port 139... */
 
                cli_cm_shutdown();
-               cli_cm_set_port( 139 );
                cli = cli_cm_open(talloc_tos(), NULL,
                                query_host, "IPC$", true, smb_encrypt,
-                               max_protocol);
+                               max_protocol, 139, name_type);
        }
 
        if (cli == NULL) {
@@ -4600,7 +4599,7 @@ static int do_tar_op(const char *base_directory)
                cli = cli_cm_open(talloc_tos(), NULL,
                        have_ip ? dest_ss_str : desthost,
                        service, true, smb_encrypt,
-                       max_protocol);
+                       max_protocol, port, name_type);
                if (!cli)
                        return 1;
        }
@@ -4650,10 +4649,11 @@ static int do_message_op(struct user_auth_info *auth_info)
 
        msg_port = port ? port : 139;
 
-       if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port)) {
+       if (!(cli=cli_initialise())) {
                d_printf("Connection to %s failed\n", desthost);
                return 1;
        }
+       cli_set_port(cli, msg_port);
 
        status = cli_connect(cli, server_name, &ss);
        if (!NT_STATUS_IS_OK(status)) {
@@ -4791,13 +4791,12 @@ static int do_message_op(struct user_auth_info *auth_info)
                         * to port 139 instead of port 445. srl,crh
                         */
                        name_type = 0x03;
-                       cli_cm_set_dest_name_type( name_type );
                        desthost = talloc_strdup(frame,poptGetOptArg(pc));
                        if (!desthost) {
                                exit(ENOMEM);
                        }
                        if( !port )
-                               cli_cm_set_port( 139 );
+                               port = 139;
                        message = true;
                        break;
                case 'I':
@@ -4893,11 +4892,6 @@ static int do_message_op(struct user_auth_info *auth_info)
                                               poptGetArg(pc));
        }
 
-       /* check for the -P option */
-
-       if ( port != 0 )
-               cli_cm_set_port( port );
-
        /*
         * Don't load debug level from smb.conf. It should be
         * set by cmdline arg or remain default (0)
@@ -5004,7 +4998,6 @@ static int do_message_op(struct user_auth_info *auth_info)
                        *p = 0;
                        p++;
                        sscanf(p, "%x", &name_type);
-                       cli_cm_set_dest_name_type( name_type );
                }
 
                return do_host_query(qhost);
index 5d70c1c2fc8f356f98dc98c85faf86f4b45a3871..5d82ef090d6ef2205517a94a8080a36d65b5bd4f 100644 (file)
@@ -2384,7 +2384,9 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                                const char *share,
                                bool show_hdr,
                                bool force_encrypt,
-                               int max_protocol);
+                               int max_protocol,
+                               int port,
+                               int name_type);
 void cli_cm_shutdown(void);
 void cli_cm_display(void);
 void cli_cm_set_credentials(struct user_auth_info *auth_info);
@@ -2435,7 +2437,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
 
 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
-int cli_set_port(struct cli_state *cli, int port);
+void cli_set_port(struct cli_state *cli, int port);
 bool cli_receive_smb(struct cli_state *cli);
 ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len);
 bool cli_receive_smb_readX_header(struct cli_state *cli);
index dcbf9a0457541aab4eed4f41060f8c95025d0337..0e059edb29e0ebec6ef88cd8cb101ed17f1114c3 100644 (file)
@@ -57,7 +57,8 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
        cli_ipc = cli_cm_open(ctx, NULL,
                              server_name, "IPC$",
                              false, false,
-                             PROTOCOL_NT1);
+                             PROTOCOL_NT1,
+                             0, 0x20);
        if (!cli_ipc) {
                libnetapi_set_error_string(ctx,
                        "Failed to connect to IPC$ share on %s", server_name);
index bf0d270babf44057d982c12c2812aeff9685ad0c..b446879140e24c895e05ef94e465c932f2a33d43 100644 (file)
@@ -1747,11 +1747,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
        make_nmb_name(&calling, my_name, 0x0);
        make_nmb_name(&called , dest_host, 0x20);
 
-       if (cli_set_port(cli, port) != port) {
-               cli_shutdown(cli);
-               return NT_STATUS_UNSUCCESSFUL;
-       }
-
+       cli_set_port(cli, port);
        cli_set_timeout(cli, 10000); /* 10 seconds. */
 
        if (dest_ss) {
index 7ed66611bd1c299e40750b8426464247f0da6656..d649c504b72ed5833ed6b549705eb9053745a063 100644 (file)
@@ -49,9 +49,6 @@ static struct cm_cred_struct {
 
 static void cm_set_password(const char *newpass);
 
-static int port;
-static int name_type = 0x20;
-
 static struct client_connection *connections;
 
 static bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
@@ -109,7 +106,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                                        const char *share,
                                        bool show_sessetup,
                                        bool force_encrypt,
-                                       int max_protocol)
+                                       int max_protocol,
+                                       int port,
+                                       int name_type)
 {
        struct cli_state *c = NULL;
        struct nmb_name called, calling;
@@ -152,13 +151,17 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        zero_sockaddr(&ss);
 
        /* have to open a new connection */
-       if (!(c=cli_initialise()) || (cli_set_port(c, port) != port)) {
+       if (!(c=cli_initialise())) {
                d_printf("Connection to %s failed\n", server_n);
                if (c) {
                        cli_shutdown(c);
                }
                return NULL;
        }
+       if (port) {
+               cli_set_port(c, port);
+       }
+
        status = cli_connect(c, server_n, &ss);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to %s failed (Error %s)\n",
@@ -168,6 +171,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                return NULL;
        }
 
+       if (max_protocol == 0) {
+               max_protocol = PROTOCOL_NT1;
+       }
        c->protocol = max_protocol;
        c->use_kerberos = cm_creds.use_kerberos;
        c->fallback_after_kerberos = cm_creds.fallback_after_kerberos;
@@ -263,7 +269,8 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                cli_shutdown(c);
                return do_connect(ctx, newserver,
                                newshare, false,
-                               force_encrypt, max_protocol);
+                               force_encrypt, max_protocol,
+                               port, name_type);
        }
 
        /* must be a normal share */
@@ -348,7 +355,9 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
                                        const char *share,
                                        bool show_hdr,
                                        bool force_encrypt,
-                                       int max_protocol)
+                                       int max_protocol,
+                                       int port,
+                                       int name_type)
 {
        struct client_connection *node;
 
@@ -359,7 +368,8 @@ static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
        }
 
        node->cli = do_connect(ctx, server, share,
-                               show_hdr, force_encrypt, max_protocol);
+                               show_hdr, force_encrypt, max_protocol,
+                               port, name_type);
 
        if ( !node->cli ) {
                TALLOC_FREE( node );
@@ -413,7 +423,9 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
                                const char *share,
                                bool show_hdr,
                                bool force_encrypt,
-                               int max_protocol)
+                               int max_protocol,
+                               int port,
+                               int name_type)
 {
        struct cli_state *c;
 
@@ -423,7 +435,7 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
        if (!c) {
                c = cli_cm_connect(ctx, referring_cli,
                                server, share, show_hdr, force_encrypt,
-                               max_protocol);
+                               max_protocol, port, name_type);
        }
 
        return c;
@@ -495,22 +507,6 @@ void cli_cm_set_credentials(struct user_auth_info *auth_info)
 /****************************************************************************
 ****************************************************************************/
 
-void cli_cm_set_port(int port_number)
-{
-       port = port_number;
-}
-
-/****************************************************************************
-****************************************************************************/
-
-void cli_cm_set_dest_name_type(int type)
-{
-       name_type = type;
-}
-
-/****************************************************************************
-****************************************************************************/
-
 void cli_cm_set_signing_state(int state)
 {
        cm_creds.signing_state = state;
@@ -904,7 +900,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
                                        rootcli->desthost,
                                        "IPC$", false,
                                        (rootcli->trans_enc_state != NULL),
-                                       rootcli->protocol))) {
+                                       rootcli->protocol,
+                                       0,
+                                       0x20))) {
                return false;
        }
 
@@ -950,7 +948,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
                                        share,
                                        false,
                                        (rootcli->trans_enc_state != NULL),
-                                       rootcli->protocol)) == NULL) {
+                                       rootcli->protocol,
+                                       0,
+                                       0x20)) == NULL) {
                d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
                        server, share );
                return false;
index fd5627d7631d3ff109ca468fc26896370a9d32ae..0bec24202cbb0cdc6e6b3b683a02f87ed88a13a4 100644 (file)
@@ -50,10 +50,9 @@ unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout)
  Change the port number used to call on.
 ****************************************************************************/
 
-int cli_set_port(struct cli_state *cli, int port)
+void cli_set_port(struct cli_state *cli, int port)
 {
        cli->port = port;
-       return port;
 }
 
 /****************************************************************************
index 9e09060f2781ee108a32f855c22ad45b4ddd1ba0..3e672aef252abd3baeaf18f76afdbe92f5066d60 100644 (file)
@@ -80,10 +80,7 @@ static void sync_child(char *name, int nm_type,
                return;
        }
 
-       if (!cli_set_port(cli, 139)) {
-               cli_shutdown(cli);
-               return;
-       }
+       cli_set_port(cli, 139);
 
        in_addr_to_sockaddr_storage(&ss, ip);
        status = cli_connect(cli, name, &ss);