[SCM] Samba Shared Repository - branch master updated - 907f085296e4c61410a7a0e2cfcd6a9db8176b16

Jeremy Allison jra at samba.org
Thu Jan 15 00:09:31 GMT 2009


The branch, master has been updated
       via  907f085296e4c61410a7a0e2cfcd6a9db8176b16 (commit)
      from  592ee76341de2936b1171ddb391a65a84836c95d (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 907f085296e4c61410a7a0e2cfcd6a9db8176b16
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jan 14 16:08:19 2009 -0800

    Remove smbclient globals that bled into clidfs.c. Now we only have
    the connections list and authentication structures to worry about.
    Jeremy

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

Summary of changes:
 source3/client/client.c       |   23 ++++++-----------
 source3/include/proto.h       |    6 +++-
 source3/lib/netapi/cm.c       |    3 +-
 source3/libsmb/cliconnect.c   |    6 +---
 source3/libsmb/clidfs.c       |   56 ++++++++++++++++++++--------------------
 source3/libsmb/clientgen.c    |    3 +-
 source3/nmbd/nmbd_synclists.c |    5 +---
 7 files changed, 45 insertions(+), 57 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index cfe33c4..7172bf9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -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);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5d70c1c..5d82ef0 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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);
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index dcbf9a0..0e059ed 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -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);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index bf0d270..b446879 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -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) {
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 7ed6661..d649c50 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -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;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index fd5627d..0bec242 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -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;
 }
 
 /****************************************************************************
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index 9e09060..3e672ae 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -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);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list