[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Thu Nov 11 10:00:01 MST 2010


The branch, master has been updated
       via  e7970c0 s3: Make cli_set_ea_fnum return NTSTATUS
       via  ddd33f0 s3: Make cli_set_ea_path return NTSTATUS
       via  1b13a4d s3: Remove two pointless variables
       via  9c664db s3: Convert cli_set_ea() to cli_trans()
       via  1d96161 s3: Convert cli_dfs_get_referral to cli_trans
       via  612ded1 s3: cli_dfs_check_error does not need to depend on cli->inbuf
       via  3a01edd s3: Make split_dfs_path return bool
       via  8a22fac s3: Remove some dead code
       via  d320ae7 s3: Untangle an if-expression
      from  9cdb0b5 s4/test: Expand BindTest

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


- Log -----------------------------------------------------------------
commit e7970c02f345a4a5d63ab43c120277de70624c19
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 15:58:34 2010 +0100

    s3: Make cli_set_ea_fnum return NTSTATUS
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Thu Nov 11 16:59:27 UTC 2010 on sn-devel-104

commit ddd33f035199bce2fc9d8deb3c2c4ad627ad36d4
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 15:51:46 2010 +0100

    s3: Make cli_set_ea_path return NTSTATUS

commit 1b13a4d22b3f0eca6926ab8ce61147784f6e993e
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 15:51:16 2010 +0100

    s3: Remove two pointless variables

commit 9c664dbd8c46e54aae4a4cebfafac61d618dd4f2
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 15:40:06 2010 +0100

    s3: Convert cli_set_ea() to cli_trans()

commit 1d9616113207775916c816708fe442fe84ad0369
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 14:54:25 2010 +0100

    s3: Convert cli_dfs_get_referral to cli_trans

commit 612ded1abf15bfcc3569f061b18764bff66fe9b6
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 14:46:58 2010 +0100

    s3: cli_dfs_check_error does not need to depend on cli->inbuf

commit 3a01edd60764723bccd742707153ab4cdf72c079
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 14:04:06 2010 +0100

    s3: Make split_dfs_path return bool

commit 8a22fac3a01c31732ac843f903689e42cce3a5ae
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 13:45:00 2010 +0100

    s3: Remove some dead code

commit d320ae7cbed565220529fa0da13ce22498d45096
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 11 13:44:28 2010 +0100

    s3: Untangle an if-expression

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

Summary of changes:
 source3/client/client.c   |    8 ++-
 source3/include/proto.h   |   10 +++-
 source3/libsmb/clidfs.c   |  128 +++++++++++++++++++++++++--------------------
 source3/libsmb/clifile.c  |   86 ++++++++++++++----------------
 source3/torture/torture.c |   24 ++++++---
 5 files changed, 141 insertions(+), 115 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 5129268..062809d 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3346,6 +3346,7 @@ static int cmd_setea(void)
 	char *eavalue = NULL;
 	char *targetname = NULL;
 	struct cli_state *targetcli;
+	NTSTATUS status;
 
 	if (!next_token_talloc(ctx, &cmd_ptr, &name, NULL)
 	    || !next_token_talloc(ctx, &cmd_ptr, &eaname, NULL)) {
@@ -3369,9 +3370,10 @@ static int cmd_setea(void)
 		return 1;
 	}
 
-	if (!cli_set_ea_path(targetcli, targetname, eaname, eavalue,
-			     strlen(eavalue))) {
-		d_printf("set_ea %s: %s\n", src, cli_errstr(cli));
+	status =  cli_set_ea_path(targetcli, targetname, eaname, eavalue,
+				  strlen(eavalue));
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("set_ea %s: %s\n", src, nt_errstr(status));
 		return 1;
 	}
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 38c5a6d..10409a4 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1689,7 +1689,7 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
 				int port,
 				int name_type);
 void cli_cm_display(const struct cli_state *c);
-bool cli_dfs_get_referral(TALLOC_CTX *ctx,
+NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
 			struct cli_state *cli,
 			const char *path,
 			struct client_dfs_referral **refs,
@@ -2077,8 +2077,12 @@ NTSTATUS cli_ctemp(struct cli_state *cli,
 			uint16_t *pfnum,
 			char **out_path);
 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
-bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_name, const char *ea_val, size_t ea_len);
-bool cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum, const char *ea_name, const char *ea_val, size_t ea_len);
+NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
+			 const char *ea_name, const char *ea_val,
+			 size_t ea_len);
+NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
+			 const char *ea_name, const char *ea_val,
+			 size_t ea_len);
 struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
 					     struct tevent_context *ev,
 					     struct cli_state *cli,
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index f4b5268..1c87988 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -127,11 +127,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
 	zero_sockaddr(&ss);
 
 	/* have to open a new connection */
-	if (!(c=cli_initialise_ex(get_cmdline_auth_info_signing_state(auth_info)))) {
+	c = cli_initialise_ex(get_cmdline_auth_info_signing_state(auth_info));
+	if (c == NULL) {
 		d_printf("Connection to %s failed\n", server_n);
-		if (c) {
-			cli_shutdown(c);
-		}
 		return NULL;
 	}
 	if (port) {
@@ -452,7 +450,7 @@ void cli_cm_set_credentials(struct user_auth_info *auth_info)
  split a dfs path into the server, share name, and extrapath components
 **********************************************************************/
 
-static void split_dfs_path(TALLOC_CTX *ctx,
+static bool split_dfs_path(TALLOC_CTX *ctx,
 				const char *nodepath,
 				char **pp_server,
 				char **pp_share,
@@ -467,16 +465,16 @@ static void split_dfs_path(TALLOC_CTX *ctx,
 
 	path = talloc_strdup(ctx, nodepath);
 	if (!path) {
-		return;
+		goto fail;
 	}
 
 	if ( path[0] != '\\' ) {
-		return;
+		goto fail;
 	}
 
 	p = strchr_m( path + 1, '\\' );
 	if ( !p ) {
-		return;
+		goto fail;
 	}
 
 	*p = '\0';
@@ -491,9 +489,28 @@ static void split_dfs_path(TALLOC_CTX *ctx,
 	} else {
 		*pp_extrapath = talloc_strdup(ctx, "");
 	}
+	if (*pp_extrapath == NULL) {
+		goto fail;
+	}
 
 	*pp_share = talloc_strdup(ctx, p);
+	if (*pp_share == NULL) {
+		goto fail;
+	}
+
 	*pp_server = talloc_strdup(ctx, &path[1]);
+	if (*pp_server == NULL) {
+		goto fail;
+	}
+
+	TALLOC_FREE(path);
+	return true;
+
+fail:
+	TALLOC_FREE(*pp_share);
+	TALLOC_FREE(*pp_extrapath);
+	TALLOC_FREE(path);
+	return false;
 }
 
 /****************************************************************************
@@ -580,19 +597,20 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
  check for dfs referral
 ********************************************************************/
 
-static bool cli_dfs_check_error( struct cli_state *cli, NTSTATUS status )
+static bool cli_dfs_check_error(struct cli_state *cli, NTSTATUS expected,
+				NTSTATUS status)
 {
-	uint32 flgs2 = SVAL(cli->inbuf,smb_flg2);
-
 	/* only deal with DS when we negotiated NT_STATUS codes and UNICODE */
 
-	if (!((flgs2&FLAGS2_32_BIT_ERROR_CODES) &&
-				(flgs2&FLAGS2_UNICODE_STRINGS)))
+	if (!(cli->capabilities & CAP_UNICODE)) {
 		return false;
-
-	if (NT_STATUS_EQUAL(status, NT_STATUS(IVAL(cli->inbuf,smb_rcls))))
+	}
+	if (!(cli->capabilities & CAP_STATUS32)) {
+		return false;
+	}
+	if (NT_STATUS_EQUAL(status, expected)) {
 		return true;
-
+	}
 	return false;
 }
 
@@ -600,7 +618,7 @@ static bool cli_dfs_check_error( struct cli_state *cli, NTSTATUS status )
  Get the dfs referral link.
 ********************************************************************/
 
-bool cli_dfs_get_referral(TALLOC_CTX *ctx,
+NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
 			struct cli_state *cli,
 			const char *path,
 			struct client_dfs_referral **refs,
@@ -609,9 +627,9 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
 {
 	unsigned int data_len = 0;
 	unsigned int param_len = 0;
-	uint16 setup = TRANSACT2_GET_DFS_REFERRAL;
-	char *param = NULL;
-	char *rparam=NULL, *rdata=NULL;
+	uint16 setup[1];
+	uint8_t *param = NULL;
+	uint8_t *rdata = NULL;
 	char *p;
 	char *endp;
 	size_t pathlen = 2*(strlen(path)+1);
@@ -620,43 +638,42 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
 	uint16_t consumed_ucs;
 	uint16 num_referrals;
 	struct client_dfs_referral *referrals = NULL;
-	bool ret = false;
+	NTSTATUS status;
 
 	*num_refs = 0;
 	*refs = NULL;
 
-	param = SMB_MALLOC_ARRAY(char, 2+pathlen+2);
+	SSVAL(setup, 0, TRANSACT2_GET_DFS_REFERRAL);
+
+	param = SMB_MALLOC_ARRAY(uint8_t, 2+pathlen+2);
 	if (!param) {
+		status = NT_STATUS_NO_MEMORY;
 		goto out;
 	}
 	SSVAL(param, 0, 0x03);	/* max referral level */
-	p = &param[2];
+	p = (char *)(&param[2]);
 
 	path_ucs = (smb_ucs2_t *)p;
 	p += clistr_push(cli, p, path, pathlen, STR_TERMINATE);
 	param_len = PTR_DIFF(p, param);
 
-	if (!cli_send_trans(cli, SMBtrans2,
-			NULL,                        /* name */
-			-1, 0,                          /* fid, flags */
-			&setup, 1, 0,                   /* setup, length, max */
-			param, param_len, 2,            /* param, length, max */
-			NULL, 0, cli->max_xmit /* data, length, max */
-			)) {
-		goto out;
-	}
-
-	if (!cli_receive_trans(cli, SMBtrans2,
-		&rparam, &param_len,
-		&rdata, &data_len)) {
+	status = cli_trans(talloc_tos(), cli, SMBtrans2,
+			   NULL, 0xffff, 0, 0,
+			   setup, 1, 0,
+			   param, param_len, 2,
+			   NULL, 0, cli->max_xmit,
+			   NULL,
+			   NULL, 0, NULL, /* rsetup */
+			   NULL, 0, NULL,
+			   &rdata, 4, &data_len);
+	if (!NT_STATUS_IS_OK(status)) {
 		goto out;
 	}
-
 	if (data_len < 4) {
 		goto out;
 	}
 
-	endp = rdata + data_len;
+	endp = (char *)rdata + data_len;
 
 	consumed_ucs  = SVAL(rdata, 0);
 	num_referrals = SVAL(rdata, 2);
@@ -696,7 +713,7 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
 		}
 		/* start at the referrals array */
 
-		p = rdata+8;
+		p = (char *)rdata+8;
 		for (i=0; i<num_referrals && p < endp; i++) {
 			if (p + 18 > endp) {
 				goto out;
@@ -732,8 +749,6 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
 		}
 	}
 
-	ret = true;
-
 	*num_refs = num_referrals;
 	*refs = referrals;
 
@@ -741,9 +756,8 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
 
 	TALLOC_FREE(consumed_path);
 	SAFE_FREE(param);
-	SAFE_FREE(rdata);
-	SAFE_FREE(rparam);
-	return ret;
+	TALLOC_FREE(rdata);
+	return status;
 }
 
 /********************************************************************
@@ -817,7 +831,8 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
 
 	/* Special case where client asked for a path that does not exist */
 
-	if (cli_dfs_check_error(rootcli, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+	if (cli_dfs_check_error(rootcli, NT_STATUS_OBJECT_NAME_NOT_FOUND,
+				status)) {
 		*targetcli = rootcli;
 		*pp_targetpath = talloc_strdup(ctx, path);
 		if (!*pp_targetpath) {
@@ -828,7 +843,8 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
 
 	/* We got an error, check for DFS referral. */
 
-	if (!cli_dfs_check_error(rootcli, NT_STATUS_PATH_NOT_COVERED)) {
+	if (!cli_dfs_check_error(rootcli, NT_STATUS_PATH_NOT_COVERED,
+				 status)) {
 		return false;
 	}
 
@@ -847,8 +863,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
 		return false;
 	}
 
-	if (!cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs,
-			&num_refs, &consumed) || !num_refs) {
+	status = cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs,
+				      &num_refs, &consumed);
+	if (!NT_STATUS_IS_OK(status) || !num_refs) {
 		return false;
 	}
 
@@ -857,9 +874,8 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
 	if (!refs[0].dfspath) {
 		return false;
 	}
-	split_dfs_path(ctx, refs[0].dfspath, &server, &share, &extrapath );
-
-	if (!server || !share) {
+	if (!split_dfs_path(ctx, refs[0].dfspath, &server, &share,
+			    &extrapath)) {
 		return false;
 	}
 
@@ -1035,7 +1051,9 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 		}
 	}
 
-	res = cli_dfs_get_referral(ctx, cli, fullpath, &refs, &num_refs, &consumed);
+	status = cli_dfs_get_referral(ctx, cli, fullpath, &refs,
+				      &num_refs, &consumed);
+	res = NT_STATUS_IS_OK(status);
 
 	status = cli_tdis(cli);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -1052,10 +1070,8 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 		return false;
 	}
 
-	split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
-			pp_newshare, &newextrapath );
-
-	if ((*pp_newserver == NULL) || (*pp_newshare == NULL)) {
+	if (!split_dfs_path(ctx, refs[0].dfspath, pp_newserver,
+			    pp_newshare, &newextrapath)) {
 		return false;
 	}
 
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 2ebe7e7..20babbd 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -4066,30 +4066,35 @@ NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA
  Set an extended attribute utility fn.
 *********************************************************/
 
-static bool cli_set_ea(struct cli_state *cli, uint16_t setup, char *param, unsigned int param_len,
-			const char *ea_name, const char *ea_val, size_t ea_len)
+static NTSTATUS cli_set_ea(struct cli_state *cli, uint16_t setup_val,
+			   uint8_t *param, unsigned int param_len,
+			   const char *ea_name,
+			   const char *ea_val, size_t ea_len)
 {
+	uint16_t setup[0];
 	unsigned int data_len = 0;
-	char *data = NULL;
-	char *rparam=NULL, *rdata=NULL;
+	uint8_t *data = NULL;
 	char *p;
 	size_t ea_namelen = strlen(ea_name);
+	NTSTATUS status;
+
+	SSVAL(setup, 0, setup_val);
 
 	if (ea_namelen == 0 && ea_len == 0) {
 		data_len = 4;
-		data = (char *)SMB_MALLOC(data_len);
+		data = (uint8_t *)SMB_MALLOC(data_len);
 		if (!data) {
-			return False;
+			return NT_STATUS_NO_MEMORY;
 		}
-		p = data;
+		p = (char *)data;
 		SIVAL(p,0,data_len);
 	} else {
 		data_len = 4 + 4 + ea_namelen + 1 + ea_len;
-		data = (char *)SMB_MALLOC(data_len);
+		data = (uint8_t *)SMB_MALLOC(data_len);
 		if (!data) {
-			return False;
+			return NT_STATUS_NO_MEMORY;
 		}
-		p = data;
+		p = (char *)data;
 		SIVAL(p,0,data_len);
 		p += 4;
 		SCVAL(p, 0, 0); /* EA flags. */
@@ -4099,74 +4104,65 @@ static bool cli_set_ea(struct cli_state *cli, uint16_t setup, char *param, unsig
 		memcpy(p+4+ea_namelen+1, ea_val, ea_len);
 	}
 
-	if (!cli_send_trans(cli, SMBtrans2,
-			NULL,                        /* name */
-			-1, 0,                          /* fid, flags */
-			&setup, 1, 0,                   /* setup, length, max */
-			param, param_len, 2,            /* param, length, max */
-			data,  data_len, cli->max_xmit /* data, length, max */
-			)) {
-		SAFE_FREE(data);
-		return False;
-	}
-
-	if (!cli_receive_trans(cli, SMBtrans2,
-			&rparam, &param_len,
-			&rdata, &data_len)) {
-			SAFE_FREE(data);
-		return false;
-	}
-
+	status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, -1, 0, 0,
+			   setup, 1, 0,
+			   param, param_len, 2,
+			   data,  data_len, cli->max_xmit,
+			   NULL,
+			   NULL, 0, NULL, /* rsetup */
+			   NULL, 0, NULL, /* rparam */
+			   NULL, 0, NULL); /* rdata */
 	SAFE_FREE(data);
-	SAFE_FREE(rdata);
-	SAFE_FREE(rparam);
-
-	return True;
+	return status;
 }
 
 /*********************************************************
  Set an extended attribute on a pathname.
 *********************************************************/
 
-bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_name, const char *ea_val, size_t ea_len)
+NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
+			 const char *ea_name, const char *ea_val,
+			 size_t ea_len)
 {
-	uint16_t setup = TRANSACT2_SETPATHINFO;
 	unsigned int param_len = 0;
-	char *param;
+	uint8_t *param;
 	size_t srclen = 2*(strlen(path)+1);
 	char *p;
-	bool ret;
+	NTSTATUS status;
 
-	param = SMB_MALLOC_ARRAY(char, 6+srclen+2);
+	param = SMB_MALLOC_ARRAY(uint8_t, 6+srclen+2);
 	if (!param) {
-		return false;
+		return NT_STATUS_NO_MEMORY;
 	}
 	memset(param, '\0', 6);
 	SSVAL(param,0,SMB_INFO_SET_EA);
-	p = &param[6];
+	p = (char *)(&param[6]);
 
 	p += clistr_push(cli, p, path, srclen, STR_TERMINATE);
 	param_len = PTR_DIFF(p, param);
 
-	ret = cli_set_ea(cli, setup, param, param_len, ea_name, ea_val, ea_len);
+	status = cli_set_ea(cli, TRANSACT2_SETPATHINFO, param, param_len,
+			    ea_name, ea_val, ea_len);
 	SAFE_FREE(param);
-	return ret;
+	return status;
 }
 
 /*********************************************************
  Set an extended attribute on an fnum.
 *********************************************************/
 
-bool cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum, const char *ea_name, const char *ea_val, size_t ea_len)
+NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
+			 const char *ea_name, const char *ea_val,
+			 size_t ea_len)
 {
-	char param[6];
-	uint16_t setup = TRANSACT2_SETFILEINFO;
+	uint8_t param[6];
 
 	memset(param, 0, 6);
 	SSVAL(param,0,fnum);
 	SSVAL(param,2,SMB_INFO_SET_EA);
 
-	return cli_set_ea(cli, setup, param, 6, ea_name, ea_val, ea_len);
+	return cli_set_ea(cli, TRANSACT2_SETFILEINFO, param, 6,
+			  ea_name, ea_val, ea_len);
 }
 
 /*********************************************************
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index f69d734..24c7d7b 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5209,8 +5209,10 @@ static bool run_eatest(int dummy)
 
 		slprintf(ea_name, sizeof(ea_name), "EA_%d", i);
 		memset(ea_val, (char)i+1, i+1);
-		if (!cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list