[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sat May 28 13:58:01 MDT 2011


The branch, master has been updated
       via  797316a s3: Use cli_connect_nb in net_rpc_check
       via  230cb3b s3: Use cli_connect_nb in smbd_running()
       via  54970f9 s3: Use cli_connect_nb in cli_servertime
       via  06eec02 s3: Use cli_connect_nb in remote_password_change
       via  57ae327 s3: Add called name_type param to cli_connect_nb
       via  c430b57 s3: Fix a type-punned warning
       via  649873b s3: Use cli_connect_nb in masktest
       via  1173a4f s3: Fix some nonemtpy blank lines
      from  5df8791 s3: Use cli_connect_nb in locktest

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


- Log -----------------------------------------------------------------
commit 797316ae9797f7567e01f853effbd87d98b2abbb
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 21:01:59 2011 +0200

    s3: Use cli_connect_nb in net_rpc_check
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Sat May 28 21:57:04 CEST 2011 on sn-devel-104

commit 230cb3b90435d951beb62d8dd5230f74e178f921
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:54:33 2011 +0200

    s3: Use cli_connect_nb in smbd_running()

commit 54970f90f6966f8b0c17a7c2badda619c2ebc13a
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:52:06 2011 +0200

    s3: Use cli_connect_nb in cli_servertime

commit 06eec02e746860fb55901b65da44f50c35b48568
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:45:11 2011 +0200

    s3: Use cli_connect_nb in remote_password_change

commit 57ae32794f841365a73f22df3b872eb001c21abc
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:39:54 2011 +0200

    s3: Add called name_type param to cli_connect_nb

commit c430b57ce44e67d3eddc0d2fffaa78b9b0f36af5
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:38:13 2011 +0200

    s3: Fix a type-punned warning

commit 649873bcf374997088da73f85424cbb641e56735
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:26:49 2011 +0200

    s3: Use cli_connect_nb in masktest

commit 1173a4f83d8001d6a00b389133de64f09d1d77a2
Author: Volker Lendecke <vl at samba.org>
Date:   Sat May 28 20:24:01 2011 +0200

    s3: Fix some nonemtpy blank lines

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

Summary of changes:
 source3/libsmb/cliconnect.c   |    8 ++++----
 source3/libsmb/passchange.c   |   39 +++++----------------------------------
 source3/libsmb/proto.h        |    2 +-
 source3/nmbd/nmbd_synclists.c |   11 +++++------
 source3/torture/locktest.c    |    3 ++-
 source3/torture/masktest.c    |   40 +++++++---------------------------------
 source3/utils/net_rpc.c       |   11 +++--------
 source3/utils/net_time.c      |   20 ++------------------
 source3/web/diagnose.c        |   10 +++-------
 9 files changed, 32 insertions(+), 112 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 9ee3b79..3921fbc 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -3151,13 +3151,12 @@ fail:
 }
 
 NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
-			uint16_t port, const char *myname,
+			uint16_t port, int name_type, const char *myname,
 			int signing_state, struct cli_state **pcli)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	struct cli_state *cli;
 	NTSTATUS status = NT_STATUS_NO_MEMORY;
-	int name_type = 0x20;
 	int fd = -1;
 	char *desthost;
 	char *p;
@@ -3194,7 +3193,8 @@ NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
 	cli->port = port;
 
 	length = sizeof(cli->dest_ss);
-	ret = getpeername(fd, (struct sockaddr *)&cli->dest_ss, &length);
+	ret = getpeername(fd, (struct sockaddr *)(void *)&cli->dest_ss,
+			  &length);
 	if (ret == -1) {
 		status = map_nt_error_from_unix(errno);
 		cli_shutdown(cli);
@@ -3228,7 +3228,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
 	NTSTATUS nt_status;
 	struct cli_state *cli;
 
-	nt_status = cli_connect_nb(dest_host, dest_ss, port, my_name,
+	nt_status = cli_connect_nb(dest_host, dest_ss, port, 0x20, my_name,
 				   signing_state, &cli);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(10, ("cli_connect_nb failed: %s\n",
diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c
index 37496bd..bf2103d 100644
--- a/source3/libsmb/passchange.c
+++ b/source3/libsmb/passchange.c
@@ -2,17 +2,17 @@
    Unix SMB/CIFS implementation.
    SMB client password change routine
    Copyright (C) Andrew Tridgell 1994-1998
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -33,10 +33,8 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 				const char *old_passwd, const char *new_passwd,
 				char **err_str)
 {
-	struct nmb_name calling, called;
 	struct cli_state *cli = NULL;
 	struct rpc_pipe_client *pipe_hnd = NULL;
-	struct sockaddr_storage ss;
 	char *user, *domain, *p;
 
 	NTSTATUS result;
@@ -57,41 +55,14 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
 
 	*err_str = NULL;
 
-	if(!resolve_name( remote_machine, &ss, 0x20, false)) {
-		if (asprintf(err_str, "Unable to find an IP address for machine "
-			 "%s.\n", remote_machine) == -1) {
-			*err_str = NULL;
-		}
-		return NT_STATUS_UNSUCCESSFUL;
-	}
-
-	cli = cli_initialise();
-	if (!cli) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	result = cli_connect(cli, remote_machine, &ss);
+	result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
+				Undefined, &cli);
 	if (!NT_STATUS_IS_OK(result)) {
 		if (asprintf(err_str, "Unable to connect to SMB server on "
 			 "machine %s. Error was : %s.\n",
 			 remote_machine, nt_errstr(result))==-1) {
 			*err_str = NULL;
 		}
-		cli_shutdown(cli);
-		return result;
-	}
-
-	make_nmb_name(&calling, global_myname() , 0x0);
-	make_nmb_name(&called , remote_machine, 0x20);
-
-	if (!cli_session_request(cli, &calling, &called)) {
-		result = cli_nt_error(cli);
-		if (asprintf(err_str, "machine %s rejected the session setup. "
-			 "Error was : %s.\n",
-			 remote_machine, nt_errstr(result)) == -1) {
-			*err_str = NULL;
-		}
-		cli_shutdown(cli);
 		return result;
 	}
 
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 3a34486..7a8f567 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -74,7 +74,7 @@ NTSTATUS cli_connect(struct cli_state *cli,
 		const char *host,
 		struct sockaddr_storage *dest_ss);
 NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
-			uint16_t port, const char *myname,
+			uint16_t port, int name_type, const char *myname,
 			int signing_state, struct cli_state **pcli);
 NTSTATUS cli_start_connection(struct cli_state **output_cli,
 			      const char *my_name,
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index e160a82..243222b 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -4,20 +4,19 @@
    Copyright (C) Andrew Tridgell 1994-1998
    Copyright (C) Luke Kenneth Casson Leighton 1994-1998
    Copyright (C) Jeremy Allison 1994-1998
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-   
 */
 
 /* this file handles asynchronous browse synchronisation requests. The
@@ -127,7 +126,7 @@ static void sync_child(char *name, int nm_type,
 	cli_NetServerEnum(cli, unix_workgroup,
 			  local_type|SV_TYPE_DOMAIN_ENUM, 
 			  callback, NULL);
-	
+
 	/* Now fetch a server list. */
 	if (servers) {
 		fstrcpy(unix_workgroup, workgroup);
@@ -135,7 +134,7 @@ static void sync_child(char *name, int nm_type,
 				  local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL,
 				  callback, NULL);
 	}
-	
+
 	cli_shutdown(cli);
 }
 
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 38f05f1..d27eb5f 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -182,7 +182,8 @@ static struct cli_state *connect_one(char *share, int snum)
 
 	/* have to open a new connection */
 
-	status = cli_connect_nb(server_n, NULL, 0, myname, Undefined, &c);
+	status = cli_connect_nb(server_n, NULL, 0, 0x20, myname, Undefined,
+				&c);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("Connection to %s failed. Error %s\n", server_n,
 			  nt_errstr(status)));
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index 37cb43e..6eca1da 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -2,17 +2,17 @@
    Unix SMB/CIFS implementation.
    mask_match tester
    Copyright (C) Andrew Tridgell 1999
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -167,10 +167,8 @@ return a connection to a server
 static struct cli_state *connect_one(char *share)
 {
 	struct cli_state *c;
-	struct nmb_name called, calling;
 	char *server_n;
 	char *server;
-	struct sockaddr_storage ss;
 	NTSTATUS status;
 
 	server = share+2;
@@ -181,40 +179,16 @@ static struct cli_state *connect_one(char *share)
 
 	server_n = server;
 
-	zero_sockaddr(&ss);
-
-	make_nmb_name(&calling, "masktest", 0x0);
-	make_nmb_name(&called , server, 0x20);
-
- again:
-        zero_sockaddr(&ss);
-
-	/* have to open a new connection */
-	if (!(c=cli_initialise())) {
-		DEBUG(0,("Connection to %s failed\n", server_n));
-		return NULL;
-	}
-
-	status = cli_connect(c, server_n, &ss);
+	status = cli_connect_nb(server, NULL, 0, 0x20, "masktest", Undefined,
+				&c);
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
+		DEBUG(0,("Connection to %s failed. Error %s\n", server_n,
+			 nt_errstr(status)));
 		return NULL;
 	}
 
 	c->protocol = max_protocol;
 
-	if (!cli_session_request(c, &calling, &called)) {
-		DEBUG(0,("session request to %s failed\n", called.name));
-		cli_shutdown(c);
-		if (strcmp(called.name, "*SMBSERVER")) {
-			make_nmb_name(&called , "*SMBSERVER", 0x20);
-			goto again;
-		}
-		return NULL;
-	}
-
-	DEBUG(4,(" session request ok\n"));
-
 	status = cli_negprot(c);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("protocol negotiation failed: %s\n",
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index b705f6a..a3ce531 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -7091,16 +7091,11 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
 	if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
 		return false;
 
-	if ((cli = cli_initialise()) == NULL) {
+	status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
+				global_myname(), Undefined, &cli);
+	if (!NT_STATUS_IS_OK(status)) {
 		return false;
 	}
-
-	status = cli_connect(cli, server_name, &server_ss);
-	if (!NT_STATUS_IS_OK(status))
-		goto done;
-	if (!attempt_netbios_session_request(&cli, global_myname(),
-					     server_name, &server_ss))
-		goto done;
 	status = cli_negprot(cli);
 	if (!NT_STATUS_IS_OK(status))
 		goto done;
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 0edb58c..46ce558 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -26,34 +26,18 @@
 */
 static time_t cli_servertime(const char *host, struct sockaddr_storage *pss, int *zone)
 {
-	struct nmb_name calling, called;
 	time_t ret = 0;
 	struct cli_state *cli = NULL;
 	NTSTATUS status;
 
-	cli = cli_initialise();
-	if (!cli) {
-		goto done;
-	}
-
-	status = cli_connect(cli, host, pss);
+	status = cli_connect_nb(host, pss, 0, 0x20, global_myname(),
+				Undefined, &cli);
 	if (!NT_STATUS_IS_OK(status)) {
 		fprintf(stderr, _("Can't contact server %s. Error %s\n"),
 			host, nt_errstr(status));
 		goto done;
 	}
 
-	make_nmb_name(&calling, global_myname(), 0x0);
-	if (host) {
-		make_nmb_name(&called, host, 0x20);
-	} else {
-		make_nmb_name(&called, "*SMBSERVER", 0x20);
-	}
-
-	if (!cli_session_request(cli, &calling, &called)) {
-		fprintf(stderr, _("Session request failed\n"));
-		goto done;
-	}
 	status = cli_negprot(cli);
 	if (!NT_STATUS_IS_OK(status)) {
 		fprintf(stderr, _("Protocol negotiation failed: %s\n"),
diff --git a/source3/web/diagnose.c b/source3/web/diagnose.c
index d5c5e90..d73337c 100644
--- a/source3/web/diagnose.c
+++ b/source3/web/diagnose.c
@@ -70,15 +70,11 @@ bool smbd_running(void)
 	loopback_ip.s_addr = htonl(INADDR_LOOPBACK);
 	in_addr_to_sockaddr_storage(&ss, loopback_ip);
 
-	if ((cli = cli_initialise()) == NULL)
-		return False;
-
-	status = cli_connect(cli, global_myname(), &ss);
+	status = cli_connect_nb("localhost", &ss, 0, 0x20, global_myname(),
+				Undefined, &cli);
 	if (!NT_STATUS_IS_OK(status)) {
-		cli_shutdown(cli);
-		return False;
+		return false;
 	}
-
 	cli_shutdown(cli);
 	return True;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list