[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1340-gf3af298

Jeremy Allison jra at samba.org
Thu Apr 30 23:58:28 GMT 2009


The branch, master has been updated
       via  f3af298e5b1457ba8661fd0e3f5304ad3175f3ba (commit)
      from  384c1aaa8ee8879b6cc4bc34dfc4d3c9fa11667b (commit)

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


- Log -----------------------------------------------------------------
commit f3af298e5b1457ba8661fd0e3f5304ad3175f3ba
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Apr 30 16:57:42 2009 -0700

    Cause cli_close to return an NTSTATUS.
    Jeremy.

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

Summary of changes:
 source3/client/client.c               |    6 +-
 source3/client/clitar.c               |    5 +-
 source3/client/smbspool.c             |    2 +-
 source3/include/proto.h               |    2 +-
 source3/libsmb/clifile.c              |   83 +---------------------
 source3/libsmb/libsmb_file.c          |    2 +-
 source3/rpc_client/rpc_transport_np.c |    5 +-
 source3/torture/locktest2.c           |    2 +-
 source3/torture/mangle_test.c         |    4 +-
 source3/torture/nbio.c                |    2 +-
 source3/torture/torture.c             |  126 ++++++++++++++++----------------
 source3/utils/net_rpc_printer.c       |    8 +-
 12 files changed, 84 insertions(+), 163 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index becb066..d3cf08c 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1078,7 +1078,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 		return 1;
 	}
 
-	if (!cli_close(targetcli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(targetcli, fnum))) {
 		d_printf("Error %s closing remote file\n",cli_errstr(cli));
 		rc = 1;
 	}
@@ -1690,7 +1690,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 		d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
 	}
 
-	if (!cli_close(targetcli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(targetcli, fnum))) {
 		d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
 		x_fclose(f);
 		return 1;
@@ -2459,7 +2459,7 @@ static int cmd_close(void)
 
 	fnum = atoi(buf);
 	/* We really should use the targetcli here.... */
-	if (!cli_close(cli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
 		d_printf("close %d: %s\n", fnum, cli_errstr(cli));
 		return 1;
 	}
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 3cc1a25..c7f2819 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -1067,8 +1067,9 @@ static int get_file(file_info2 finfo)
 
 	/* Now close the file ... */
 
-	if (!cli_close(cli, fnum)) {
-		DEBUG(0, ("Error closing remote file\n"));
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
+		DEBUG(0, ("Error %s closing remote file\n",
+			cli_errstr(cli)));
 		return(False);
 	}
 
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 6b099db..07de579 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -602,7 +602,7 @@ smb_print(struct cli_state * cli,	/* I - SMB connection */
 		tbytes += nbytes;
 	}
 
-	if (!cli_close(cli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
 		fprintf(stderr, "ERROR: %s closing remote spool %s\n",
 			cli_errstr(cli), title);
 		return (get_exit_code(cli, cli_nt_error(cli)));
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f60fc9d..0d52e00 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2418,7 +2418,7 @@ struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
 				  struct event_context *ev,
 				  struct cli_state *cli, uint16_t fnum);
 NTSTATUS cli_close_recv(struct tevent_req *req);
-bool cli_close(struct cli_state *cli, uint16_t fnum);
+NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
 bool cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
 		      uint32_t offset, uint32_t len,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 0573041..abc9391 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -1120,70 +1120,6 @@ int cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag)
 	return true;
 }
 
-/****************************************************************************
- Open a file - exposing the full horror of the NT API :-).
- Used in smbtorture.
-****************************************************************************/
-
-#if 0
-int cli_nt_create_full(struct cli_state *cli, const char *fname,
-		       uint32_t CreatFlags, uint32_t DesiredAccess,
-		       uint32_t FileAttributes, uint32_t ShareAccess,
-		       uint32_t CreateDisposition, uint32_t CreateOptions,
-		       uint8_t SecurityFlags)
-{
-	char *p;
-	int len;
-
-	memset(cli->outbuf,'\0',smb_size);
-	memset(cli->inbuf,'\0',smb_size);
-
-	cli_set_message(cli->outbuf,24,0, true);
-
-	SCVAL(cli->outbuf,smb_com,SMBntcreateX);
-	SSVAL(cli->outbuf,smb_tid,cli->cnum);
-	cli_setup_packet(cli);
-
-	SSVAL(cli->outbuf,smb_vwv0,0xFF);
-	if (cli->use_oplocks)
-		CreatFlags |= (REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK);
-
-	SIVAL(cli->outbuf,smb_ntcreate_Flags, CreatFlags);
-	SIVAL(cli->outbuf,smb_ntcreate_RootDirectoryFid, 0x0);
-	SIVAL(cli->outbuf,smb_ntcreate_DesiredAccess, DesiredAccess);
-	SIVAL(cli->outbuf,smb_ntcreate_FileAttributes, FileAttributes);
-	SIVAL(cli->outbuf,smb_ntcreate_ShareAccess, ShareAccess);
-	SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, CreateDisposition);
-	SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, CreateOptions);
-	SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02);
-	SCVAL(cli->outbuf,smb_ntcreate_SecurityFlags, SecurityFlags);
-
-	p = smb_buf(cli->outbuf);
-	/* this alignment and termination is critical for netapp filers. Don't change */
-	p += clistr_align_out(cli, p, 0);
-	len = clistr_push(cli, p, fname,
-			cli->bufsize - PTR_DIFF(p,cli->outbuf), 0);
-	p += len;
-	SSVAL(cli->outbuf,smb_ntcreate_NameLength, len);
-	/* sigh. this copes with broken netapp filer behaviour */
-	p += clistr_push(cli, p, "",
-			cli->bufsize - PTR_DIFF(p,cli->outbuf), STR_TERMINATE);
-
-	cli_setup_bcc(cli, p);
-
-	cli_send_smb(cli);
-	if (!cli_receive_smb(cli)) {
-		return -1;
-	}
-
-	if (cli_is_error(cli)) {
-		return -1;
-	}
-
-	return SVAL(cli->inbuf,smb_vwv2 + 1);
-}
-#endif
-
 struct cli_ntcreate_state {
 	uint16_t vwv[24];
 	uint16_t fnum;
@@ -1346,18 +1282,6 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
 	return status;
 }
 
-#if 0
-/****************************************************************************
- Open a file.
-****************************************************************************/
-
-int cli_nt_create(struct cli_state *cli, const char *fname, uint32_t DesiredAccess)
-{
-	return cli_nt_create_full(cli, fname, 0, DesiredAccess, 0,
-				FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0);
-}
-#endif
-
 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2,
 			    const char *str, size_t str_len,
 			    size_t *pconverted_size)
@@ -1675,13 +1599,12 @@ NTSTATUS cli_close_recv(struct tevent_req *req)
 	return tevent_req_simple_recv_ntstatus(req);
 }
 
-bool cli_close(struct cli_state *cli, uint16_t fnum)
+NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	struct event_context *ev;
 	struct tevent_req *req;
 	NTSTATUS status = NT_STATUS_OK;
-	bool result = false;
 
 	if (cli_has_async_calls(cli)) {
 		/*
@@ -1708,13 +1631,13 @@ bool cli_close(struct cli_state *cli, uint16_t fnum)
 		goto fail;
 	}
 
-	result = NT_STATUS_IS_OK(cli_close_recv(req));
+	status = cli_close_recv(req);
  fail:
 	TALLOC_FREE(frame);
 	if (!NT_STATUS_IS_OK(status)) {
 		cli_set_error(cli, status);
 	}
-	return result;
+	return status;
 }
 
 /****************************************************************************
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 4724658..bf53267 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -477,7 +477,7 @@ SMBC_close_ctx(SMBCCTX *context,
 	}
 	/*d_printf(">>>close: resolved path as %s\n", targetpath);*/
         
-	if (!cli_close(targetcli, file->cli_fd)) {
+	if (!NT_STATUS_IS_OK(cli_close(targetcli, file->cli_fd))) {
                 
 		DEBUG(3, ("cli_close failed on %s. purging server.\n", 
 			  file->fname));
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index dceacf6..73d23d8 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -30,15 +30,12 @@ struct rpc_transport_np_state {
 
 static int rpc_transport_np_state_destructor(struct rpc_transport_np_state *s)
 {
-	bool ret;
-
 	if (s->cli->fd == -1) {
 		DEBUG(10, ("socket was closed, no need to send close request.\n"));
 		return 0;
 	}
 	
-	ret = cli_close(s->cli, s->fnum);
-	if (!ret) {
+	if (!NT_STATUS_IS_OK(cli_close(s->cli, s->fnum))) {
 		DEBUG(1, ("rpc_transport_np_state_destructor: cli_close "
 			  "failed on pipe %s. Error was %s\n", s->pipe_name,
 			  cli_errstr(s->cli)));
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index 9cb5314..93adcb5 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -94,7 +94,7 @@ static bool try_close(struct cli_state *c, int fstype, int fd)
 {
 	switch (fstype) {
 	case FSTYPE_SMB:
-		return cli_close(c, fd);
+		return NT_STATUS_IS_OK(cli_close(c, fd));
 
 	case FSTYPE_NFS:
 		return close(fd) == 0;
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index 6ea6c57..34c908e 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -42,7 +42,7 @@ static bool test_one(struct cli_state *cli, const char *name)
 		return False;
 	}
 
-	if (!cli_close(cli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
 		printf("close of %s failed (%s)\n", name, cli_errstr(cli));
 		return False;
 	}
@@ -66,7 +66,7 @@ static bool test_one(struct cli_state *cli, const char *name)
 		printf("open2 of %s failed (%s)\n", name2, cli_errstr(cli));
 		return False;
 	}
-	if (!cli_close(cli, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
 		printf("close of %s failed (%s)\n", name, cli_errstr(cli));
 		return False;
 	}
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index c5a5388..bef54f7 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -213,7 +213,7 @@ void nb_close(int handle)
 {
 	int i;
 	i = find_handle(handle);
-	if (!cli_close(c, ftable[i].fd)) {
+	if (!NT_STATUS_IS_OK(cli_close(c, ftable[i].fd))) {
 		printf("(%d) close failed on handle %d\n", line_count, handle);
 		exit(1);
 	}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index e06a762..4689d8f 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -482,7 +482,7 @@ static bool rw_torture(struct cli_state *c)
 			correct = False;
 		}
 
-		if (!cli_close(c, fnum)) {
+		if (!NT_STATUS_IS_OK(cli_close(c, fnum))) {
 			printf("close failed (%s)\n", cli_errstr(c));
 			correct = False;
 		}
@@ -618,7 +618,7 @@ static bool rw_torture3(struct cli_state *c, char *lockfname)
 
 	}
 
-	if (!cli_close(c, fnum)) {
+	if (!NT_STATUS_IS_OK(cli_close(c, fnum))) {
 		printf("close failed (%s)\n", cli_errstr(c));
 		correct = False;
 	}
@@ -686,11 +686,11 @@ static bool rw_torture2(struct cli_state *c1, struct cli_state *c2)
 		}
 	}
 
-	if (!cli_close(c2, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(c2, fnum2))) {
 		printf("close failed (%s)\n", cli_errstr(c2));
 		correct = False;
 	}
-	if (!cli_close(c1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(c1, fnum1))) {
 		printf("close failed (%s)\n", cli_errstr(c1));
 		correct = False;
 	}
@@ -796,7 +796,7 @@ static bool run_readwritelarge(int dummy)
 		correct = False;
 	}
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 	}
@@ -843,7 +843,7 @@ static bool run_readwritelarge(int dummy)
 		printf("readwritelarge test 3 (truncate test) succeeded (size = %x)\n", fsize);
 #endif
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 	}
@@ -1050,7 +1050,7 @@ static bool run_locktest1(int dummy)
 	printf("server slept for %u seconds for a %u second timeout\n",
 	       (unsigned int)(t2-t1), lock_timeout);
 
-	if (!cli_close(cli1, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
 		printf("close1 failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
@@ -1063,12 +1063,12 @@ static bool run_locktest1(int dummy)
 				 NT_STATUS_FILE_LOCK_CONFLICT)) return False;
 	}
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close2 failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
 
-	if (!cli_close(cli2, fnum3)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli2, fnum3))) {
 		printf("close3 failed (%s)\n", cli_errstr(cli2));
 		return False;
 	}
@@ -1178,7 +1178,7 @@ static bool run_tcon_test(int dummy)
 	cli->cnum = cnum1;
 	cli->vuid = vuid1;
 
-	if (!cli_close(cli, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum1))) {
 		printf("close failed (%s)\n", cli_errstr(cli));
 		return False;
 	}
@@ -1461,17 +1461,17 @@ static bool run_locktest2(int dummy)
 
 	cli_setpid(cli, 1);
 
-	if (!cli_close(cli, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum1))) {
 		printf("close1 failed (%s)\n", cli_errstr(cli));
 		return False;
 	}
 
-	if (!cli_close(cli, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum2))) {
 		printf("close2 failed (%s)\n", cli_errstr(cli));
 		return False;
 	}
 
-	if (!cli_close(cli, fnum3)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli, fnum3))) {
 		printf("close3 failed (%s)\n", cli_errstr(cli));
 		return False;
 	}
@@ -1580,12 +1580,12 @@ static bool run_locktest3(int dummy)
 		}
 	}
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close1 failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
 
-	if (!cli_close(cli2, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
 		printf("close2 failed (%s)\n", cli_errstr(cli2));
 		return False;
 	}
@@ -1764,8 +1764,8 @@ static bool run_locktest4(int dummy)
 	cli_open(cli1, fname, O_RDWR, DENY_NONE, &f);
 	ret = cli_lock(cli1, fnum1, 0, 8, 0, READ_LOCK) &&
 	      cli_lock(cli1, f, 0, 1, 0, READ_LOCK) &&
-	      cli_close(cli1, fnum1) &&
-	      (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) &&
+	      NT_STATUS_IS_OK(cli_close(cli1, fnum1)) &&
+	      NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1)) &&
 	      cli_lock(cli1, fnum1, 7, 1, 0, WRITE_LOCK);
         cli_close(cli1, f);
 	cli_close(cli1, fnum1);
@@ -2736,7 +2736,7 @@ static bool run_oplock1(int dummy)
 	cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
 	cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close2 failed (%s)\n", cli_errstr(cli1));
 		return False;
 	}
@@ -2815,7 +2815,7 @@ static bool run_oplock2(int dummy)
 
 		sleep(2);
 
-		if (!cli_close(cli2, fnum2)) {
+		if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
 			printf("close2 failed (%s)\n", cli_errstr(cli1));
 			*shared_correct = False;
 		}
@@ -2863,7 +2863,7 @@ static bool run_oplock2(int dummy)
 	}
 #endif
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("close1 failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 	}
@@ -2991,7 +2991,7 @@ static bool run_deletetest(int dummy)
         }
 #endif
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("[1] close failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 		goto fail;
@@ -3024,7 +3024,7 @@ static bool run_deletetest(int dummy)
 		goto fail;
 	}
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("[2] close failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 		goto fail;
@@ -3032,7 +3032,7 @@ static bool run_deletetest(int dummy)
 
 	if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
 		printf("[2] open of %s succeeded should have been deleted on close !\n", fname);
-		if (!cli_close(cli1, fnum1)) {
+		if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 			printf("[2] close failed (%s)\n", cli_errstr(cli1));
 			correct = False;
 			goto fail;
@@ -3077,13 +3077,13 @@ static bool run_deletetest(int dummy)
 		goto fail;
 	}
 
-	if (!cli_close(cli1, fnum1)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 		printf("[3] close 1 failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 		goto fail;
 	}
 
-	if (!cli_close(cli1, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
 		printf("[3] close 2 failed (%s)\n", cli_errstr(cli1));
 		correct = False;
 		goto fail;
@@ -3093,7 +3093,7 @@ static bool run_deletetest(int dummy)
 
 	if (NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDONLY, DENY_NONE, &fnum1))) {
 		printf("[3] open of %s succeeded should have been deleted on close !\n", fname);
-		if (!cli_close(cli1, fnum1)) {
+		if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
 			printf("[3] close failed (%s)\n", cli_errstr(cli1));
 		}
 		cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
@@ -3121,7 +3121,7 @@ static bool run_deletetest(int dummy)
 		goto fail;
 	}
 
-	if (!cli_close(cli1, fnum2)) {
+	if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) {
 		printf("[4] close - 1 failed (%s)\n", cli_errstr(cli1));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list