svn commit: samba r15934 - in trunk/source: client python rpc_client smbwrapper

jra at samba.org jra at samba.org
Mon May 29 21:34:35 GMT 2006


Author: jra
Date: 2006-05-29 21:34:34 +0000 (Mon, 29 May 2006)
New Revision: 15934

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15934

Log:
Tidy up other users of cli_initialise(&c);
Jeremy.

Modified:
   trunk/source/client/smbctool.c
   trunk/source/client/smbmount.c
   trunk/source/python/py_smb.c
   trunk/source/rpc_client/cli_lsarpc.c
   trunk/source/smbwrapper/smbw.c
   trunk/source/smbwrapper/smbw.h


Changeset:
Modified: trunk/source/client/smbctool.c
===================================================================
--- trunk/source/client/smbctool.c	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/client/smbctool.c	2006-05-29 21:34:34 UTC (rev 15934)
@@ -3471,7 +3471,7 @@
 
 	msg_port = port ? port : 139;
 
-	if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, msg_port) != msg_port) ||
+	if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port) ||
 		!cli_connect(cli, server_name, &ip)) {
 		d_printf("Connection to %s failed\n", desthost);
 		return 1;

Modified: trunk/source/client/smbmount.c
===================================================================
--- trunk/source/client/smbmount.c	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/client/smbmount.c	2006-05-29 21:34:34 UTC (rev 15934)
@@ -149,7 +149,7 @@
 	if (have_ip) ip = dest_ip;
 
 	/* have to open a new connection */
-	if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) ||
+	if (!(c=cli_initialise()) || (cli_set_port(c, smb_port) != smb_port) ||
 	    !cli_connect(c, server_n, &ip)) {
 		DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n));
 		if (c) {

Modified: trunk/source/python/py_smb.c
===================================================================
--- trunk/source/python/py_smb.c	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/python/py_smb.c	2006-05-29 21:34:34 UTC (rev 15934)
@@ -43,7 +43,7 @@
 	if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &server))
 		return NULL;
 
-	if (!(cli = cli_initialise(NULL)))
+	if (!(cli = cli_initialise()))
 		return NULL;
 
 	ZERO_STRUCT(ip);

Modified: trunk/source/rpc_client/cli_lsarpc.c
===================================================================
--- trunk/source/rpc_client/cli_lsarpc.c	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/rpc_client/cli_lsarpc.c	2006-05-29 21:34:34 UTC (rev 15934)
@@ -1276,43 +1276,43 @@
 BOOL fetch_domain_sid( char *domain, char *remote_machine, DOM_SID *psid)
 {
 	extern pstring global_myname;
-	struct cli_state cli;
+	struct cli_state *cli;
 	NTSTATUS result;
 	POLICY_HND lsa_pol;
 	BOOL ret = False;
  
 	ZERO_STRUCT(cli);
-	if(cli_initialise(&cli) == False) {
+	if((cli = cli_initialise()) == NULL) {
 		DEBUG(0,("fetch_domain_sid: unable to initialize client connection.\n"));
 		return False;
 	}
  
-	if(!resolve_name( remote_machine, &cli.dest_ip, 0x20)) {
+	if(!resolve_name( remote_machine, &cli->dest_ip, 0x20)) {
 		DEBUG(0,("fetch_domain_sid: Can't resolve address for %s\n", remote_machine));
 		goto done;
 	}
  
-	if (!cli_connect(&cli, remote_machine, &cli.dest_ip)) {
+	if (!cli_connect(cli, remote_machine, &cli->dest_ip)) {
 		DEBUG(0,("fetch_domain_sid: unable to connect to SMB server on \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
+machine %s. Error was : %s.\n", remote_machine, cli_errstr(cli) ));
 		goto done;
 	}
 
-	if (!attempt_netbios_session_request(&cli, global_myname, remote_machine, &cli.dest_ip)) {
+	if (!attempt_netbios_session_request(cli, global_myname, remote_machine, &cli->dest_ip)) {
 		DEBUG(0,("fetch_domain_sid: machine %s rejected the NetBIOS session request.\n", 
 			remote_machine));
 		goto done;
 	}
  
-	cli.protocol = PROTOCOL_NT1;
+	cli->protocol = PROTOCOL_NT1;
  
-	if (!cli_negprot(&cli)) {
+	if (!cli_negprot(cli)) {
 		DEBUG(0,("fetch_domain_sid: machine %s rejected the negotiate protocol. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(cli) ));
 		goto done;
 	}
  
-	if (cli.protocol != PROTOCOL_NT1) {
+	if (cli->protocol != PROTOCOL_NT1) {
 		DEBUG(0,("fetch_domain_sid: machine %s didn't negotiate NT protocol.\n",
 			remote_machine));
 		goto done;
@@ -1322,39 +1322,39 @@
 	 * Do an anonymous session setup.
 	 */
  
-	if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
+	if (!cli_session_setup(cli, "", "", 0, "", 0, "")) {
 		DEBUG(0,("fetch_domain_sid: machine %s rejected the session setup. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(cli) ));
 		goto done;
 	}
  
-	if (!(cli.sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
+	if (!(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
 		DEBUG(0,("fetch_domain_sid: machine %s isn't in user level security mode\n",
 			remote_machine));
 		goto done;
 	}
 
-	if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
+	if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) {
 		DEBUG(0,("fetch_domain_sid: machine %s rejected the tconX on the IPC$ share. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
+Error was : %s.\n", remote_machine, cli_errstr(cli) ));
 		goto done;
 	}
 
 	/* Fetch domain sid */
  
-	if (!cli_nt_session_open(&cli, PI_LSARPC)) {
+	if (!cli_nt_session_open(cli, PI_LSARPC)) {
 		DEBUG(0, ("fetch_domain_sid: Error connecting to SAM pipe\n"));
 		goto done;
 	}
  
-	result = cli_lsa_open_policy(&cli, cli.mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
+	result = cli_lsa_open_policy(cli, cli->mem_ctx, True, SEC_RIGHTS_QUERY_VALUE, &lsa_pol);
 	if (!NT_STATUS_IS_OK(result)) {
 		DEBUG(0, ("fetch_domain_sid: Error opening lsa policy handle. %s\n",
 			nt_errstr(result) ));
 		goto done;
 	}
  
-	result = cli_lsa_query_info_policy(&cli, cli.mem_ctx, &lsa_pol, 5, domain, psid);
+	result = cli_lsa_query_info_policy(cli, cli->mem_ctx, &lsa_pol, 5, domain, psid);
 	if (!NT_STATUS_IS_OK(result)) {
 		DEBUG(0, ("fetch_domain_sid: Error querying lsa policy handle. %s\n",
 			nt_errstr(result) ));
@@ -1365,7 +1365,7 @@
 
   done:
 
-	cli_shutdown(&cli);
+	cli_shutdown(cli);
 	return ret;
 }
 

Modified: trunk/source/smbwrapper/smbw.c
===================================================================
--- trunk/source/smbwrapper/smbw.c	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/smbwrapper/smbw.c	2006-05-29 21:34:34 UTC (rev 15934)
@@ -432,7 +432,7 @@
 struct smbw_server *smbw_server(char *server, char *share)
 {
 	struct smbw_server *srv=NULL;
-	struct cli_state c;
+	struct cli_state *c;
 	char *username;
 	char *password;
 	char *workgroup;
@@ -499,13 +499,13 @@
 	}
 
 	/* have to open a new connection */
-	if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) {
+	if (((c = cli_initialise()) == NULL) || !cli_connect(c, server_n, &ip)) {
 		errno = ENOENT;
 		return NULL;
 	}
 
-	if (!cli_session_request(&c, &calling, &called)) {
-		cli_shutdown(&c);
+	if (!cli_session_request(c, &calling, &called)) {
+		cli_shutdown(c);
 		if (strcmp(called.name, "*SMBSERVER")) {
 			make_nmb_name(&called , "*SMBSERVER", 0x20);
 			goto again;
@@ -516,29 +516,29 @@
 
 	DEBUG(4,(" session request ok\n"));
 
-	if (!cli_negprot(&c)) {
-		cli_shutdown(&c);
+	if (!cli_negprot(c)) {
+		cli_shutdown(c);
 		errno = ENOENT;
 		return NULL;
 	}
 
-	if (!cli_session_setup(&c, username, 
+	if (!cli_session_setup(c, username, 
 			       password, strlen(password),
 			       password, strlen(password),
 			       workgroup) &&
 	    /* try an anonymous login if it failed */
-	    !cli_session_setup(&c, "", "", 1,"", 0, workgroup)) {
-		cli_shutdown(&c);
+	    !cli_session_setup(c, "", "", 1,"", 0, workgroup)) {
+		cli_shutdown(c);
 		errno = EPERM;
 		return NULL;
 	}
 
 	DEBUG(4,(" session setup ok\n"));
 
-	if (!cli_send_tconX(&c, share, "?????",
+	if (!cli_send_tconX(c, share, "?????",
 			    password, strlen(password)+1)) {
-		errno = smbw_errno(&c);
-		cli_shutdown(&c);
+		errno = smbw_errno(c);
+		cli_shutdown(c);
 		return NULL;
 	}
 
@@ -584,11 +584,11 @@
 
 	/* some programs play with file descriptors fairly intimately. We
 	   try to get out of the way by duping to a high fd number */
-	if (fcntl(SMBW_CLI_FD + srv->cli.fd, F_GETFD) && errno == EBADF) {
-		if (dup2(srv->cli.fd,SMBW_CLI_FD+srv->cli.fd) == 
-		    srv->cli.fd+SMBW_CLI_FD) {
-			close(srv->cli.fd);
-			srv->cli.fd += SMBW_CLI_FD;
+	if (fcntl(SMBW_CLI_FD + srv->cli->fd, F_GETFD) && errno == EBADF) {
+		if (dup2(srv->cli->fd,SMBW_CLI_FD+srv->cli->fd) == 
+		    srv->cli->fd+SMBW_CLI_FD) {
+			close(srv->cli->fd);
+			srv->cli->fd += SMBW_CLI_FD;
 		}
 	}
 
@@ -597,7 +597,7 @@
 	return srv;
 
  failed:
-	cli_shutdown(&c);
+	cli_shutdown(c);
 	if (!srv) return NULL;
 
 	SAFE_FREE(srv->server_name);

Modified: trunk/source/smbwrapper/smbw.h
===================================================================
--- trunk/source/smbwrapper/smbw.h	2006-05-29 16:50:22 UTC (rev 15933)
+++ trunk/source/smbwrapper/smbw.h	2006-05-29 21:34:34 UTC (rev 15934)
@@ -32,7 +32,7 @@
 
 struct smbw_server {
 	struct smbw_server *next, *prev;
-	struct cli_state cli;
+	struct cli_state *cli;
 	char *server_name;
 	char *share_name;
 	char *workgroup;



More information about the samba-cvs mailing list