[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Wed Aug 4 12:33:39 MDT 2010


The branch, master has been updated
       via  867626a... s3: Convert cli_list() to return NTSTATUS
       via  2ff73f0... s3: Use data_blob_null
      from  dbdef72... s4:LDB modules - remove the "kludge_acl" module code

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


- Log -----------------------------------------------------------------
commit 867626abcad88b84684e9d328abf51d4f410a1cb
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Aug 2 19:22:22 2010 +0200

    s3: Convert cli_list() to return NTSTATUS
    
    If needed, the callback functions can count themselves

commit 2ff73f0df3257c27cb3cdae779e679de3170be17
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Aug 2 15:25:45 2010 +0200

    s3: Use data_blob_null

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

Summary of changes:
 source3/client/client.c       |   15 ++++++++++-----
 source3/include/proto.h       |    6 +++---
 source3/libgpo/gpo_filesync.c |   14 +++++++-------
 source3/libsmb/clilist.c      |   22 +++++++++++++++-------
 source3/libsmb/libsmb_dir.c   |   19 +++++++++++--------
 source3/torture/torture.c     |   28 +++++++++++++++++++++++-----
 source3/utils/net_rpc.c       |    7 +++++--
 7 files changed, 74 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index 7f804bf..d439581 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -865,10 +865,13 @@ void do_list(const char *mask,
 	} else {
 		/* check for dfs */
 		if (cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetpath)) {
-			if (cli_list(targetcli, targetpath, attribute,
-				     do_list_helper, targetcli) == -1) {
+			NTSTATUS status;
+
+			status = cli_list(targetcli, targetpath, attribute,
+					  do_list_helper, targetcli);
+			if (!NT_STATUS_IS_OK(status)) {
 				d_printf("%s listing %s\n",
-					cli_errstr(targetcli), targetpath);
+					 nt_errstr(status), targetpath);
 			}
 			TALLOC_FREE(targetpath);
 		} else {
@@ -4281,6 +4284,7 @@ static char **remote_completion(const char *text, int len)
 	struct cli_state *targetcli = NULL;
 	int i;
 	struct completion_remote info = { NULL, NULL, 1, 0, NULL, 0 };
+	NTSTATUS status;
 
 	/* can't have non-static initialisation on Sun CC, so do it
 	   at run time here */
@@ -4339,8 +4343,9 @@ static char **remote_completion(const char *text, int len)
 	if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
 		goto cleanup;
 	}
-	if (cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
-				completion_remote_filter, (void *)&info) < 0) {
+	status = cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
+			  completion_remote_filter, (void *)&info);
+	if (!NT_STATUS_IS_OK(status)) {
 		goto cleanup;
 	}
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4e3ec7a..f9684ad 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2580,9 +2580,9 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
 int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
 		 void (*fn)(const char *, struct file_info *, const char *,
 			    void *), void *state);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
-	     void (*fn)(const char *, struct file_info *, const char *,
-			void *), void *state);
+NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+		  void (*fn)(const char *, struct file_info *, const char *,
+			     void *), void *state);
 
 /* The following definitions come from libsmb/climessage.c  */
 
diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c
index 461ebb7..d85df1f 100644
--- a/source3/libgpo/gpo_filesync.c
+++ b/source3/libgpo/gpo_filesync.c
@@ -110,15 +110,15 @@ static NTSTATUS gpo_copy_dir(const char *unix_path)
 
 static bool gpo_sync_files(struct sync_context *ctx)
 {
+	NTSTATUS status;
+
 	DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask));
 
-	if (cli_list(ctx->cli,
-		     ctx->mask,
-		     ctx->attribute,
-		     gpo_sync_func,
-		     ctx) == -1) {
-		DEBUG(1,("listing [%s] failed with error: %s\n",
-			ctx->mask, cli_errstr(ctx->cli)));
+	status = cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func,
+			  ctx);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(1, ("listing [%s] failed with error: %s\n",
+			  ctx->mask, nt_errstr(status)));
 		return false;
 	}
 
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 551c0f2..a8e3bd5 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -247,7 +247,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
 	char *param;
 	uint32 resume_key = 0;
 	TALLOC_CTX *frame = talloc_stackframe();
-	DATA_BLOB last_name_raw = data_blob(NULL, 0);
+	DATA_BLOB last_name_raw = data_blob_null;
 
 	/* NT uses SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
 	   OS/2 uses SMB_FIND_EA_SIZE. Both accept SMB_FIND_INFO_STANDARD. */
@@ -677,11 +677,19 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
  This auto-switches between old and new style.
 ****************************************************************************/
 
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
-	     void (*fn)(const char *, struct file_info *, const char *,
-			void *), void *state)
+NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+		  void (*fn)(const char *, struct file_info *, const char *,
+			     void *), void *state)
 {
-	if (cli->protocol <= PROTOCOL_LANMAN1)
-		return cli_list_old(cli, Mask, attribute, fn, state);
-	return cli_list_new(cli, Mask, attribute, fn, state);
+	int rec;
+
+	if (cli->protocol <= PROTOCOL_LANMAN1) {
+		rec = cli_list_old(cli, Mask, attribute, fn, state);
+	} else {
+		rec = cli_list_new(cli, Mask, attribute, fn, state);
+	}
+	if (rec == -1) {
+		return cli_nt_error(cli);
+	}
+	return NT_STATUS_OK;
 }
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 1a1ca68..6d3da1c 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -748,6 +748,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
                          */
 			char *targetpath;
 			struct cli_state *targetcli;
+			NTSTATUS status;
 
 			/* We connect to the server and list the directory */
 			dir->dir_type = SMBC_FILE_SHARE;
@@ -791,10 +792,10 @@ SMBC_opendir_ctx(SMBCCTX *context,
 				return NULL;
 			}
 
-			if (cli_list(targetcli, targetpath,
-                                     aDIR | aSYSTEM | aHIDDEN,
-                                     dir_list_fn, (void *)dir) < 0) {
-
+			status = cli_list(targetcli, targetpath,
+					  aDIR | aSYSTEM | aHIDDEN,
+					  dir_list_fn, (void *)dir);
+			if (!NT_STATUS_IS_OK(status)) {
 				if (dir) {
 					SAFE_FREE(dir->fname);
 					SAFE_FREE(dir);
@@ -1302,6 +1303,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
                         /* Local storage to avoid buffer overflows */
 			char *lpath;
 			bool smbc_rmdir_dirempty = true;
+			NTSTATUS status;
 
 			lpath = talloc_asprintf(frame, "%s\\*",
 						targetpath);
@@ -1311,11 +1313,12 @@ SMBC_rmdir_ctx(SMBCCTX *context,
 				return -1;
 			}
 
-			if (cli_list(targetcli, lpath,
-                                     aDIR | aSYSTEM | aHIDDEN,
-                                     rmdir_list_fn,
-				     &smbc_rmdir_dirempty) < 0) {
+			status = cli_list(targetcli, lpath,
+					  aDIR | aSYSTEM | aHIDDEN,
+					  rmdir_list_fn,
+					  &smbc_rmdir_dirempty);
 
+			if (!NT_STATUS_IS_OK(status)) {
 				/* Fix errno to ignore latest error ... */
 				DEBUG(5, ("smbc_rmdir: "
                                           "cli_list returned an error: %d\n",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index df8adbd..cea7b8a 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4794,7 +4794,10 @@ static bool run_openattrtest(int dummy)
 static void list_fn(const char *mnt, struct file_info *finfo,
 		    const char *name, void *state)
 {
-
+	int *matched = (int *)state;
+	if (matched != NULL) {
+		*matched += 1;
+	}
 }
 
 /*
@@ -4807,6 +4810,7 @@ static bool run_dirtest(int dummy)
 	uint16_t fnum;
 	struct timeval core_start;
 	bool correct = True;
+	int matched;
 
 	printf("starting directory test\n");
 
@@ -4829,9 +4833,17 @@ static bool run_dirtest(int dummy)
 
 	core_start = timeval_current();
 
-	printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL));
-	printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL));
-	printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL));
+	matched = 0;
+	cli_list(cli, "a*.*", 0, list_fn, &matched);
+	printf("Matched %d\n", matched);
+
+	matched = 0;
+	cli_list(cli, "b*.*", 0, list_fn, &matched);
+	printf("Matched %d\n", matched);
+
+	matched = 0;
+	cli_list(cli, "xyzabc", 0, list_fn, &matched);
+	printf("Matched %d\n", matched);
 
 	printf("dirtest core %g seconds\n", timeval_elapsed(&core_start));
 
@@ -6173,6 +6185,7 @@ static void shortname_del_fn(const char *mnt, struct file_info *finfo,
 }
 
 struct sn_state {
+	int matched;
 	int i;
 	bool val;
 };
@@ -6201,6 +6214,7 @@ static void shortname_list_fn(const char *mnt, struct file_info *finfo,
 			__location__, finfo->short_name, finfo->name);
 		s->val = true;
 	}
+	s->matched += 1;
 }
 
 static bool run_shortname_test(int dummy)
@@ -6255,7 +6269,11 @@ static bool run_shortname_test(int dummy)
 			goto out;
 		}
 		cli_close(cli, fnum);
-		if (cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, &s) != 1) {
+
+		s.matched = 0;
+		cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn,
+			 &s);
+		if (s.matched != 1) {
 			d_printf("(%s) failed to list %s: %s\n",
 				__location__, fname, cli_errstr(cli));
 			correct = false;
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index cafab87..d27545d 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -3452,6 +3452,7 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask)
 {
 	struct cli_state *targetcli;
 	char *targetpath = NULL;
+	NTSTATUS status;
 
 	DEBUG(3,("calling cli_list with mask: %s\n", mask));
 
@@ -3463,9 +3464,11 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask)
 		return false;
 	}
 
-	if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) {
+	status = cli_list(targetcli, targetpath, cp_clistate->attribute,
+			  copy_fn, cp_clistate);
+	if (!NT_STATUS_IS_OK(status)) {
 		d_fprintf(stderr, _("listing %s failed with error: %s\n"),
-			mask, cli_errstr(targetcli));
+			  mask, nt_errstr(status));
 		return false;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list