[SCM] Samba Shared Repository - branch master updated

Simo Sorce idra at samba.org
Thu Feb 16 00:30:02 MST 2012


The branch, master has been updated
       via  b5b2041 Rename obscure defined constants.
      from  95d3096 s3-selftest: Remove .posix_s3 from s3 test names

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


- Log -----------------------------------------------------------------
commit b5b204184aa6d0f14e7d3bd08322a98dc4f432e6
Author: Christopher R. Hertel (crh) <crh at samba.org>
Date:   Tue Feb 14 21:51:35 2012 -0600

    Rename obscure defined constants.
    
    Replaced the undescriptive SMB_PORT1 and SMB_PORT2 defined constants
    with the slightly more descriptive names NBT_SMB_PORT and TCP_SMB_PORT.
    Also replaced several hard-coded references to the well-known port
    numbers (139 and 445, respectively) as appropriate.
    
    Small changes to clarify some comments regarding the two transport
    types.
    
    Signed-off-by: Simo Sorce <idra at samba.org>
    
    Autobuild-User: Simo Sorce <idra at samba.org>
    Autobuild-Date: Thu Feb 16 08:29:41 CET 2012 on sn-devel-104

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

Summary of changes:
 source3/auth/auth_ntlmssp.c      |    4 ++--
 source3/client/client.c          |    9 +++++----
 source3/include/smb.h            |    4 ++--
 source3/lib/util_sock.c          |    5 +++--
 source3/libsmb/libsmb_server.c   |    2 +-
 source3/libsmb/smbsock_connect.c |   14 +++++++-------
 source3/nmbd/nmbd_synclists.c    |    2 +-
 source3/smbd/reply.c             |    4 ++--
 source3/torture/torture.c        |    2 +-
 source3/utils/smbfilter.c        |    4 ++--
 source3/winbindd/winbindd_cm.c   |    2 +-
 11 files changed, 27 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 00a99c3..b5935e6 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -143,8 +143,8 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
 	NTSTATUS nt_status;
 	bool username_was_mapped;
 
-	/* the client has given us its machine name (which we otherwise would not get on port 445).
-	   we need to possibly reload smb.conf if smb.conf includes depend on the machine name */
+	/* The client has given us its machine name (which we only get over NBT transport).
+	   We need to possibly reload smb.conf if smb.conf includes depend on the machine name. */
 
 	set_remote_machine_name(gensec_ntlmssp->ntlmssp_state->client.netbios_name, True);
 
diff --git a/source3/client/client.c b/source3/client/client.c
index 89fd1d4..9d4ef15 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5168,7 +5168,7 @@ static int do_host_query(const char *query_host)
 		}
 	}
 
-	if (port != 139) {
+	if (port != NBT_SMB_PORT) {
 
 		/* Workgroups simply don't make sense over anything
 		   else but port 139... */
@@ -5177,7 +5177,8 @@ static int do_host_query(const char *query_host)
 		status = cli_cm_open(talloc_tos(), NULL,
 				     have_ip ? dest_ss_str : query_host,
 				     "IPC$", auth_info, true, smb_encrypt,
-				     max_protocol, 139, name_type, &cli);
+				     max_protocol, NBT_SMB_PORT, name_type,
+				     &cli);
 		if (!NT_STATUS_IS_OK(status)) {
 			cli = NULL;
 		}
@@ -5242,7 +5243,7 @@ static int do_message_op(struct user_auth_info *a_info)
 	NTSTATUS status;
 
 	status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
-				port ? port : 139, name_type,
+				port ? port : NBT_SMB_PORT, name_type,
 				lp_netbios_name(), SMB_SIGNING_DEFAULT, 0, &cli);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
@@ -5354,7 +5355,7 @@ static int do_message_op(struct user_auth_info *a_info)
 				exit(ENOMEM);
 			}
 			if( !port )
-				port = 139;
+				port = NBT_SMB_PORT;
  			message = true;
  			break;
 		case 'I':
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 22653cd..7dd77ec 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -44,8 +44,8 @@
 
 #define NMB_PORT 137
 #define DGRAM_PORT 138
-#define SMB_PORT1 445
-#define SMB_PORT2 139
+#define NBT_SMB_PORT  139   /* Port for SMB over NBT transport (IETF STD#19). */
+#define TCP_SMB_PORT  445   /* Port for SMB over naked TCP transport.         */
 #define SMB_PORTS "445 139"
 
 #define Undefined (-1)
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 9ade23c..dcc41bb 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -482,8 +482,9 @@ int open_socket_in(int type,
 
 	/* now we've got a socket - we need to bind it */
 	if (bind(res, (struct sockaddr *)&sock, slen) == -1 ) {
-		if( DEBUGLVL(dlevel) && (port == SMB_PORT1 ||
-				port == SMB_PORT2 || port == NMB_PORT) ) {
+		if( DEBUGLVL(dlevel) && (port == NMB_PORT ||
+					 port == NBT_SMB_PORT ||
+					 port == TCP_SMB_PORT) ) {
 			char addr[INET6_ADDRSTRLEN];
 			print_sockaddr(addr, sizeof(addr),
 					&sock);
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 570b7ae..f5fcaea 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -420,7 +420,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 		/*
 		 * Try 139 first for IPC$
 		 */
-		status = cli_connect_nb(server_n, NULL, 139, 0x20,
+		status = cli_connect_nb(server_n, NULL, NBT_SMB_PORT, 0x20,
 					smbc_getNetbiosName(context),
 					SMB_SIGNING_DEFAULT, flags, &c);
 	}
diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c
index 1926445..d9d3b92 100644
--- a/source3/libsmb/smbsock_connect.c
+++ b/source3/libsmb/smbsock_connect.c
@@ -191,7 +191,7 @@ static struct tevent_req *nb_connect_send(TALLOC_CTX *mem_ctx,
 
 	talloc_set_destructor(state, nb_connect_state_destructor);
 
-	subreq = open_socket_out_send(state, ev, addr, 139, 5000);
+	subreq = open_socket_out_send(state, ev, addr, NBT_SMB_PORT, 5000);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -276,7 +276,7 @@ static void nb_connect_done(struct tevent_req *subreq)
 		make_nmb_name(&state->called, state->called_name, 0x20);
 
 		subreq = open_socket_out_send(state, state->ev, state->addr,
-					      139, 5000);
+					      NBT_SMB_PORT, 5000);
 		if (tevent_req_nomem(subreq, req)) {
 			return;
 		}
@@ -351,7 +351,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
 
 	talloc_set_destructor(state, smbsock_connect_state_destructor);
 
-	if (port == 139) {
+	if (port == NBT_SMB_PORT) {
 		subreq = tevent_wakeup_send(state, ev, timeval_set(0, 0));
 		if (tevent_req_nomem(subreq, req)) {
 			return tevent_req_post(req, ev);
@@ -374,7 +374,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
 	 * port==0, try both
 	 */
 
-	state->req_445 = open_socket_out_send(state, ev, addr, 445, 5000);
+	state->req_445 = open_socket_out_send(state, ev, addr, TCP_SMB_PORT, 5000);
 	if (tevent_req_nomem(state->req_445, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -382,7 +382,7 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
 				req);
 
 	/*
-	 * After 5 msecs, fire the 139 request
+	 * After 5 msecs, fire the 139 (NBT) request
 	 */
 	state->req_139 = tevent_wakeup_send(
 		state, ev, timeval_current_ofs(0, 5000));
@@ -445,14 +445,14 @@ static void smbsock_connect_connected(struct tevent_req *subreq)
 		status = open_socket_out_recv(subreq, &state->sock);
 		TALLOC_FREE(state->req_445);
 		unfinished_req = state->req_139;
-		state->port = 445;
+		state->port = TCP_SMB_PORT;
 
 	} else if (subreq == state->req_139) {
 
 		status = nb_connect_recv(subreq, &state->sock);
 		TALLOC_FREE(state->req_139);
 		unfinished_req = state->req_445;
-		state->port = 139;
+		state->port = NBT_SMB_PORT;
 
 	} else {
 		tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index e015f7b..1adccbd 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -81,7 +81,7 @@ static void sync_child(char *name, int nm_type,
 
 	in_addr_to_sockaddr_storage(&ss, ip);
 
-	status = cli_connect_nb(name, &ss, 139, nm_type,
+	status = cli_connect_nb(name, &ss, NBT_SMB_PORT, nm_type,
 				get_local_machine_name(), SMB_SIGNING_DEFAULT,
 				0, &cli);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 5b0f7cf..557a32f 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -410,13 +410,13 @@ static bool netbios_session_retarget(struct smbd_server_connection *sconn,
 	char *retarget;
 	char *p;
 	int retarget_type = 0x20;
-	int retarget_port = 139;
+	int retarget_port = NBT_SMB_PORT;
 	struct sockaddr_storage retarget_addr;
 	struct sockaddr_in *in_addr;
 	bool ret = false;
 	uint8_t outbuf[10];
 
-	if (get_socket_port(sconn->sock) != 139) {
+	if (get_socket_port(sconn->sock) != NBT_SMB_PORT) {
 		return false;
 	}
 
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index b14f9ed..0b2727c 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3094,7 +3094,7 @@ static bool run_bad_nbt_session(int dummy)
 		return false;
 	}
 
-	status = open_socket_out(&ss, 139, 10000, &fd);
+	status = open_socket_out(&ss, NBT_SMB_PORT, 10000, &fd);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_fprintf(stderr, "open_socket_out failed: %s\n",
 			  nt_errstr(status));
diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
index 23f4755..33f1a90 100644
--- a/source3/utils/smbfilter.c
+++ b/source3/utils/smbfilter.c
@@ -180,7 +180,7 @@ static void filter_child(int c, struct sockaddr_storage *dest_ss)
 	int s = -1;
 
 	/* we have a connection from a new client, now connect to the server */
-	status = open_socket_out(dest_ss, 445, LONG_CONNECT_TIMEOUT, &s);
+	status = open_socket_out(dest_ss, TCP_SMB_PORT, LONG_CONNECT_TIMEOUT, &s);
 
 	if (s == -1) {
 		char addr[INET6_ADDRSTRLEN];
@@ -278,7 +278,7 @@ static void start_filter(char *desthost)
 	/* start listening on port 445 locally */
 
 	zero_sockaddr(&my_ss);
-	s = open_socket_in(SOCK_STREAM, 445, 0, &my_ss, True);
+	s = open_socket_in(SOCK_STREAM, TCP_SMB_PORT, 0, &my_ss, True);
 
 	if (s == -1) {
 		d_printf("bind failed\n");
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 3373d96..020a092 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -1331,7 +1331,7 @@ static bool find_new_dc(TALLOC_CTX *mem_ctx,
 				    &dcnames, &num_dcnames)) {
 			return False;
 		}
-		if (!add_sockaddr_to_array(mem_ctx, &dcs[i].ss, 445,
+		if (!add_sockaddr_to_array(mem_ctx, &dcs[i].ss, TCP_SMB_PORT,
 				      &addrs, &num_addrs)) {
 			return False;
 		}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list