[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Wed Jul 20 15:23:03 MDT 2011


The branch, master has been updated
       via  d622cad s3-torture: run_simple_posix_open_test(): replace cli_read_old() with cli_read()
       via  c53e2ad s3-torture: rw_torture2(): replace cli_read_old() with cli_read()
       via  ea4c448 s3-torture: rw_torture3(): replace cli_read_old() with cli_read()
       via  b10fa4b s3-torture: rw_torture(): replace cli_read_old() with cli_read()
       via  8c360d7 s3-libsmb: introduce new NTSTATUS cli_read()
       via  9b168e1 s3-libsmb: replace cli_read() with cli_read_old()
       via  8f41e54 s3:libsmb: move cli->cnum to cli->smb1.tid and hide it behind cli_state_[g|s]et_tid()
       via  1e38221 s3:libsmb: move cli->pid to cli->smb1.pid and hide it behind cli_[g|s]etpid()
       via  9fb7e22 s3:libsmb: add cli->smb1.vc_num and hide it behind cli_state_get_vc_num()
       via  6c31b61 s3:libsmb: move cli->mid to cli->smb1.mid
       via  21a6bdc s3:libsmb: smb_bytes_talloc_string() doesn't need a cli_state
      from  8d159e9 s4:kdc: restore the behavior before the last heimdal import

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


- Log -----------------------------------------------------------------
commit d622cadd34e268a7348cb1c06b3e3ca01013a0bf
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 16:15:52 2011 +0200

    s3-torture: run_simple_posix_open_test(): replace cli_read_old() with
    cli_read()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Wed Jul 20 23:22:09 CEST 2011 on sn-devel-104

commit c53e2ad4de17a7f7ddaa80d79dfe99e3578c2ab7
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 16:01:42 2011 +0200

    s3-torture: rw_torture2(): replace cli_read_old() with cli_read()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit ea4c4480b483a90d194dfded586cba1917b8825d
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 15:49:03 2011 +0200

    s3-torture: rw_torture3(): replace cli_read_old() with cli_read()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit b10fa4bbcd49b313154ab59309d046aa35dd9ef7
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 15:29:14 2011 +0200

    s3-torture: rw_torture(): replace cli_read_old() with cli_read()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 8c360d7f76c7c054781ac41c4d823d0529af1577
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 11:11:27 2011 +0200

    s3-libsmb: introduce new NTSTATUS cli_read()
    
    Replacement for cli_read_old()
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 9b168e128a74b7e816a6eea73d1b8db8b915b701
Author: Björn Baumbach <bb at sernet.de>
Date:   Tue Jul 19 10:48:16 2011 +0200

    s3-libsmb: replace cli_read() with cli_read_old()
    
    Will introduce new cli_read() function.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 8f41e54d538896a929ef8ebf224ddcfea7982ba8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 19 16:25:52 2011 +0200

    s3:libsmb: move cli->cnum to cli->smb1.tid and hide it behind cli_state_[g|s]et_tid()
    
    metze

commit 1e3822115c3b466632044fe64c908b6f2de5803a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 19 12:56:51 2011 +0200

    s3:libsmb: move cli->pid to cli->smb1.pid and hide it behind cli_[g|s]etpid()
    
    metze

commit 9fb7e228f5a6e39dd22e1c56733c61178ee0be49
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 19 12:52:10 2011 +0200

    s3:libsmb: add cli->smb1.vc_num and hide it behind cli_state_get_vc_num()
    
    This makes it clearer, why we send the pid value in the session setup.
    
    metze

commit 6c31b610e4c44105ddeb9a5ffd8e64ef3954e79e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 19 11:34:35 2011 +0200

    s3:libsmb: move cli->mid to cli->smb1.mid
    
    metze

commit 21a6bdc680311d58625c4e46c8126b38700fac52
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Jul 19 16:02:31 2011 +0200

    s3:libsmb: smb_bytes_talloc_string() doesn't need a cli_state
    
    metze

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

Summary of changes:
 source3/client/clitar.c         |    2 +-
 source3/include/client.h        |   10 ++-
 source3/libgpo/gpo_filesync.c   |    2 +-
 source3/libsmb/async_smb.c      |    4 +-
 source3/libsmb/cliconnect.c     |   21 +++----
 source3/libsmb/clidfs.c         |    4 +-
 source3/libsmb/clientgen.c      |   49 +++++++++++++---
 source3/libsmb/clifile.c        |   10 ++--
 source3/libsmb/clireadwrite.c   |   22 +++++++-
 source3/libsmb/libsmb_file.c    |    2 +-
 source3/libsmb/libsmb_server.c  |    2 +-
 source3/libsmb/proto.h          |   10 +++-
 source3/torture/denytest.c      |    4 +-
 source3/torture/nbio.c          |    2 +-
 source3/torture/torture.c       |  118 ++++++++++++++++++++++----------------
 source3/torture/utable.c        |    2 +-
 source3/utils/net_rpc.c         |    4 +-
 source3/utils/net_rpc_printer.c |    2 +-
 source3/utils/smbcacls.c        |    8 +-
 19 files changed, 178 insertions(+), 100 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 3fff081..8882461 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -693,7 +693,7 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
 
 			DEBUG(3,("nread=%.0f\n",(double)nread));
 
-			datalen = cli_read(cli, fnum, data, nread, read_size);
+			datalen = cli_read_old(cli, fnum, data, nread, read_size);
 
 			if (datalen == -1) {
 				status = cli_nt_error(cli);
diff --git a/source3/include/client.h b/source3/include/client.h
index dfd457b..5e4e0a3 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -52,9 +52,6 @@ struct cli_state {
 	 */
         struct cli_state *prev, *next;
 	int fd;
-	uint16 cnum;
-	uint16 pid;
-	uint16 mid;
 	uint16 vuid;
 	int protocol;
 	int sec_mode;
@@ -134,6 +131,13 @@ struct cli_state {
 	struct tevent_req **pending;
 
 	struct {
+		uint16_t mid;
+		uint16_t pid;
+		uint16_t vc_num;
+		uint16_t tid;
+	} smb1;
+
+	struct {
 		uint64_t mid;
 		uint32_t pid;
 		uint32_t tid;
diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c
index 91e1c27..cdcdcfb 100644
--- a/source3/libgpo/gpo_filesync.c
+++ b/source3/libgpo/gpo_filesync.c
@@ -67,7 +67,7 @@ NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
 
 	while (1) {
 
-		int n = cli_read(cli, fnum, data, nread, read_size);
+		int n = cli_read_old(cli, fnum, data, nread, read_size);
 
 		if (n <= 0)
 			break;
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 0493a52..b621919 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -99,7 +99,7 @@ static uint16_t cli_alloc_mid(struct cli_state *cli)
 	while (true) {
 		int i;
 
-		result = cli->mid++;
+		result = cli->smb1.mid++;
 		if ((result == 0) || (result == 0xffff)) {
 			continue;
 		}
@@ -317,7 +317,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
 
 	cli_setup_packet_buf(cli, (char *)state->header);
 	SCVAL(state->header, smb_com, smb_command);
-	SSVAL(state->header, smb_tid, cli->cnum);
+	SSVAL(state->header, smb_tid, cli->smb1.tid);
 	SCVAL(state->header, smb_wct, wct);
 
 	state->vwv = vwv;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index e5d8700..4e3e47f 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -59,14 +59,14 @@ static const struct {
  strings.
 *******************************************************/
 
-static NTSTATUS smb_bytes_talloc_string(struct cli_state *cli,
+static NTSTATUS smb_bytes_talloc_string(TALLOC_CTX *mem_ctx,
 					char *inbuf,
 					char **dest,
 					uint8_t *src,
 					size_t srclen,
 					ssize_t *destlen)
 {
-	*destlen = clistr_pull_talloc(cli,
+	*destlen = clistr_pull_talloc(mem_ctx,
 				inbuf,
 				SVAL(inbuf, smb_flg2),
 				dest,
@@ -78,7 +78,7 @@ static NTSTATUS smb_bytes_talloc_string(struct cli_state *cli,
 	}
 
 	if (*dest == NULL) {
-		*dest = talloc_strdup(cli, "");
+		*dest = talloc_strdup(mem_ctx, "");
 		if (*dest == NULL) {
 			return NT_STATUS_NO_MEMORY;
 		}
@@ -418,7 +418,7 @@ struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
 	SSVAL(vwv+1, 0, 0);
 	SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
 	SSVAL(vwv+3, 0, 2);
-	SSVAL(vwv+4, 0, cli->pid);
+	SSVAL(vwv+4, 0, cli_state_get_vc_num(cli));
 	SIVAL(vwv+5, 0, cli->sesskey);
 	SSVAL(vwv+7, 0, 0);
 	SSVAL(vwv+8, 0, 0);
@@ -637,7 +637,7 @@ static struct tevent_req *cli_session_setup_plain_send(
 	SSVAL(vwv+1, 0, 0);
 	SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
 	SSVAL(vwv+3, 0, 2);
-	SSVAL(vwv+4, 0, cli->pid);
+	SSVAL(vwv+4, 0, cli_state_get_vc_num(cli));
 	SIVAL(vwv+5, 0, cli->sesskey);
 	SSVAL(vwv+7, 0, 0);
 	SSVAL(vwv+8, 0, 0);
@@ -985,7 +985,7 @@ static struct tevent_req *cli_session_setup_nt1_send(
 	SSVAL(vwv+1, 0, 0);
 	SSVAL(vwv+2, 0, CLI_BUFFER_SIZE);
 	SSVAL(vwv+3, 0, 2);
-	SSVAL(vwv+4, 0, cli->pid);
+	SSVAL(vwv+4, 0, cli_state_get_vc_num(cli));
 	SIVAL(vwv+5, 0, cli->sesskey);
 	SSVAL(vwv+7, 0, lm_response.length);
 	SSVAL(vwv+8, 0, nt_response.length);
@@ -2405,7 +2405,7 @@ static void cli_tcon_andx_done(struct tevent_req *subreq)
 		cli->dfsroot = ((SVAL(vwv+2, 0) & SMB_SHARE_IN_DFS) != 0);
 	}
 
-	cli->cnum = SVAL(inbuf,smb_tid);
+	cli->smb1.tid = SVAL(inbuf,smb_tid);
 	tevent_req_done(req);
 }
 
@@ -2498,7 +2498,7 @@ static void cli_tdis_done(struct tevent_req *subreq)
 		tevent_req_nterror(req, status);
 		return;
 	}
-	state->cli->cnum = -1;
+	state->cli->smb1.tid = UINT16_MAX;
 	tevent_req_done(req);
 }
 
@@ -2551,7 +2551,6 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
 	struct cli_negprot_state *state;
 	uint8_t *bytes = NULL;
 	int numprots;
-	uint16_t cnum;
 
 	req = tevent_req_create(mem_ctx, &state, struct cli_negprot_state);
 	if (req == NULL) {
@@ -2582,12 +2581,8 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
 		}
 	}
 
-	cnum = cli->cnum;
-
-	cli->cnum = 0;
 	subreq = cli_smb_send(state, ev, cli, SMBnegprot, 0, 0, NULL,
 			      talloc_get_size(bytes), bytes);
-	cli->cnum = cnum;
 
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index a0d503a..d677f9e 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -1031,7 +1031,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 		return false;
 	}
 
-	cnum = cli->cnum;
+	cnum = cli_state_get_tid(cli);
 
 	/* special case.  never check for a referral on the IPC$ share */
 
@@ -1072,7 +1072,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 		return false;
 	}
 
-	cli->cnum = cnum;
+	cli_state_set_tid(cli, cnum);
 
 	if (!res || !num_refs) {
 		return false;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index d6c7d64..0ee361f 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -68,10 +68,10 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf)
 	uint16 flags2;
 	cli->rap_error = 0;
 	SIVAL(buf,smb_rcls,0);
-	SSVAL(buf,smb_pid,cli->pid);
+	SSVAL(buf,smb_pid,cli->smb1.pid);
 	memset(buf+smb_pidhigh, 0, 12);
 	SSVAL(buf,smb_uid,cli->vuid);
-	SSVAL(buf,smb_mid,cli->mid);
+	SSVAL(buf,smb_mid,cli->smb1.mid);
 
 	if (cli->protocol <= PROTOCOL_CORE) {
 		return;
@@ -184,9 +184,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
 	}
 	cli->fd = -1;
 	cli->raw_status = NT_STATUS_INTERNAL_ERROR;
-	cli->cnum = -1;
-	cli->pid = (uint16)sys_getpid();
-	cli->mid = 1;
 	cli->vuid = UID_FIELD_INVALID;
 	cli->protocol = PROTOCOL_NT1;
 	cli->timeout = 20000; /* Timeout is in milliseconds. */
@@ -240,6 +237,11 @@ struct cli_state *cli_initialise_ex(int signing_state)
 
 	cli->initialised = 1;
 
+	cli->smb1.mid = 1;
+	cli->smb1.pid = (uint16_t)sys_getpid();
+	cli->smb1.vc_num = cli->smb1.pid;
+	cli->smb1.tid = UINT16_MAX;
+
 	return cli;
 
         /* Clean up after malloc() error */
@@ -285,7 +287,7 @@ static void _cli_shutdown(struct cli_state *cli)
 	 * later.  This tree disconnect forces the peer to clean up, since the
 	 * connection will be going away.
 	 */
-	if (cli->cnum != (uint16)-1) {
+	if (cli_state_has_tcon(cli)) {
 		cli_tdis(cli);
 	}
         
@@ -341,14 +343,45 @@ void cli_sockopt(struct cli_state *cli, const char *options)
 	set_socket_options(cli->fd, options);
 }
 
+uint16_t cli_state_get_vc_num(struct cli_state *cli)
+{
+	return cli->smb1.vc_num;
+}
+
 /****************************************************************************
  Set the PID to use for smb messages. Return the old pid.
 ****************************************************************************/
 
 uint16 cli_setpid(struct cli_state *cli, uint16 pid)
 {
-	uint16 ret = cli->pid;
-	cli->pid = pid;
+	uint16_t ret = cli->smb1.pid;
+	cli->smb1.pid = pid;
+	return ret;
+}
+
+uint16_t cli_getpid(struct cli_state *cli)
+{
+	return cli->smb1.pid;
+}
+
+bool cli_state_has_tcon(struct cli_state *cli)
+{
+	if (cli->smb1.tid == UINT16_MAX) {
+		return false;
+	}
+
+	return true;
+}
+
+uint16_t cli_state_get_tid(struct cli_state *cli)
+{
+	return cli->smb1.tid;
+}
+
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid)
+{
+	uint16_t ret = cli->smb1.tid;
+	cli->smb1.tid = tid;
 	return ret;
 }
 
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 8cf60de..6503e23 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -2556,7 +2556,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
 	SSVAL(vwv + 6, 0, 0);
 	SSVAL(vwv + 7, 0, 1);
 
-	SSVAL(bytes, 0, cli->pid);
+	SSVAL(bytes, 0, cli_getpid(cli));
 	SIVAL(bytes, 2, offset);
 	SIVAL(bytes, 6, len);
 
@@ -2626,7 +2626,7 @@ struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
 	SSVAL(state->vwv+6, 0, 1);
 	SSVAL(state->vwv+7, 0, 0);
 
-	SSVAL(state->data, 0, cli->pid);
+	SSVAL(state->data, 0, cli_getpid(cli));
 	SIVAL(state->data, 2, offset);
 	SIVAL(state->data, 6, len);
 
@@ -2732,7 +2732,7 @@ NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum,
 	SSVAL(vwv + 6, 0, 0);
 	SSVAL(vwv + 7, 0, 1);
 
-	SIVAL(bytes, 0, cli->pid);
+	SIVAL(bytes, 0, cli_getpid(cli));
 	SOFF_T_R(bytes, 4, offset);
 	SOFF_T_R(bytes, 12, len);
 
@@ -2786,7 +2786,7 @@ struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
 	SSVAL(state->vwv+6, 0, 1);
 	SSVAL(state->vwv+7, 0, 0);
 
-	SIVAL(state->data, 0, cli->pid);
+	SIVAL(state->data, 0, cli_getpid(cli));
 	SOFF_T_R(state->data, 4, offset);
 	SOFF_T_R(state->data, 12, len);
 
@@ -2932,7 +2932,7 @@ static struct tevent_req *cli_posix_lock_internal_send(TALLOC_CTX *mem_ctx,
 				POSIX_LOCK_FLAG_NOWAIT);
 	}
 
-	SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli->pid);
+	SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli_getpid(cli));
 	SOFF_T(&state->data, POSIX_LOCK_START_OFFSET, offset);
 	SOFF_T(&state->data, POSIX_LOCK_LEN_OFFSET, len);
 
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 64bdb48..5406007 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -691,7 +691,7 @@ static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv)
 	return NT_STATUS_OK;
 }
 
-ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
+ssize_t cli_read_old(struct cli_state *cli, uint16_t fnum, char *buf,
 		 off_t offset, size_t size)
 {
 	NTSTATUS status;
@@ -705,6 +705,26 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
 	return ret;
 }
 
+NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
+		 char *buf, off_t offset, size_t size,
+		 size_t *nread)
+{
+	NTSTATUS status;
+	SMB_OFF_T ret;
+
+	status = cli_pull(cli, fnum, offset, size, size,
+			  cli_read_sink, &buf, &ret);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (nread) {
+		*nread = ret;
+	}
+
+	return NT_STATUS_OK;
+}
+
 /****************************************************************************
   write to a file using a SMBwrite and not bypassing 0 byte writes
 ****************************************************************************/
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 4517a36..ebf4925 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -296,7 +296,7 @@ SMBC_read_ctx(SMBCCTX *context,
 	}
 	/*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/
 
-	ret = cli_read(targetcli, file->cli_fd, (char *)buf, offset, count);
+	ret = cli_read_old(targetcli, file->cli_fd, (char *)buf, offset, count);
 
 	if (ret < 0) {
 		errno = SMBC_errno(context, targetcli);
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 49018a8..760bd9a 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -289,7 +289,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
 		 * i.e., a normal share or a referred share from
 		 * 'msdfs proxy' share.
 		 */
-                if (srv->cli->cnum == (uint16) -1) {
+                if (!cli_state_has_tcon(srv->cli)) {
                         /* Ensure we have accurate auth info */
 			SMBC_call_auth_fn(ctx, context,
 					  srv->cli->desthost,
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 070b4b1..127983d 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -164,7 +164,12 @@ struct cli_state *cli_initialise_ex(int signing_state);
 void cli_nt_pipes_close(struct cli_state *cli);
 void cli_shutdown(struct cli_state *cli);
 void cli_sockopt(struct cli_state *cli, const char *options);
+uint16_t cli_state_get_vc_num(struct cli_state *cli);
 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+uint16_t cli_getpid(struct cli_state *cli);
+bool cli_state_has_tcon(struct cli_state *cli);
+uint16_t cli_state_get_tid(struct cli_state *cli);
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 				 struct cli_state *cli, uint16_t num_echos,
@@ -733,8 +738,11 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
 		  off_t start_offset, SMB_OFF_T size, size_t window_size,
 		  NTSTATUS (*sink)(char *buf, size_t n, void *priv),
 		  void *priv, SMB_OFF_T *received);
-ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
+ssize_t cli_read_old(struct cli_state *cli, uint16_t fnum, char *buf,
 		 off_t offset, size_t size);
+NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
+		  char *buf, off_t offset, size_t size,
+		  size_t *nread);
 NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
 		      off_t offset, size_t size1, size_t *ptotal);
 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c
index be01e82..9fea7c5 100644
--- a/source3/torture/denytest.c
+++ b/source3/torture/denytest.c
@@ -1451,7 +1451,7 @@ bool torture_denytest1(int dummy)
 		} else {
 			char x = 1;
 			res = A_0;
-			if (cli_read(cli1, fnum2, (char *)&x, 0, 1) == 1) {
+			if (cli_read_old(cli1, fnum2, (char *)&x, 0, 1) == 1) {
 				res += A_R;
 			}
 			if (NT_STATUS_IS_OK(cli_writeall(cli1, fnum2, 0,
@@ -1543,7 +1543,7 @@ bool torture_denytest2(int dummy)
 		} else {
 			char x = 1;
 			res = A_0;
-			if (cli_read(cli2, fnum2, (char *)&x, 0, 1) == 1) {
+			if (cli_read_old(cli2, fnum2, (char *)&x, 0, 1) == 1) {
 				res += A_R;
 			}
 			if (NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0,
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index 0da6bc0..e6caf74 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -215,7 +215,7 @@ void nb_readx(int handle, int offset, int size, int ret_size)
 	int i, ret;
 
 	i = find_handle(handle);
-	if ((ret=cli_read(c, ftable[i].fd, buf, offset, size)) != ret_size) {
+	if ((ret=cli_read_old(c, ftable[i].fd, buf, offset, size)) != ret_size) {
 		printf("(%d) ERROR: read failed on handle %d ofs=%d size=%d res=%d fd %d errno %d (%s)\n",
 			line_count, handle, offset, size, ret, ftable[i].fd, errno, strerror(errno));
 		exit(1);
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 39d7ad3..6317d0e 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -569,6 +569,7 @@ static bool rw_torture(struct cli_state *c)
 	int i, j;
 	char buf[1024];
 	bool correct = True;
+	size_t nread = 0;
 	NTSTATUS status;
 
 	memset(buf, '\0', sizeof(buf));
@@ -624,9 +625,16 @@ static bool rw_torture(struct cli_state *c)
 
 		pid2 = 0;
 
-		if (cli_read(c, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
-			printf("read failed (%s)\n", cli_errstr(c));
-			correct = False;
+		status = cli_read(c, fnum, (char *)&pid2, 0, sizeof(pid),
+				  &nread);
+		if (!NT_STATUS_IS_OK(status)) {
+			printf("read failed (%s)\n", nt_errstr(status));
+			correct = false;
+		} else if (nread != sizeof(pid)) {
+			printf("read/write compare failed: "
+			       "recv %ld req %ld\n", (unsigned long)nread,
+			       (unsigned long)sizeof(pid));
+			correct = false;
 		}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list