[SCM] Samba Shared Repository - branch v3-6-test updated
Volker Lendecke
vlendec at samba.org
Sun Mar 27 12:34:19 MDT 2011
The branch, v3-6-test has been updated
via 23f16a5 s3: Convert cli_raw_tcon to cli_smb
via 6a771ee s3: Fix a memleak
via 00c171d s3: Replace a use of cli_errstr
via 69fe1f1 s3: Replace cli_negprot_sendsync() by cli_negprot_send()
via 30aa8a2 s3: Remove a pointless static
via 3ab85ae s3: Remove a use of cli_send_smb
via 1c76931 s3: Remove two calls to cli_errstr
from 8a58eaa s3: Fix Coverity ID 2296: UNUSED_VALUE
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test
- Log -----------------------------------------------------------------
commit 23f16a5726b4f7cfc908172e430e8ad7be511396
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 18:03:24 2011 +0200
s3: Convert cli_raw_tcon to cli_smb
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Sun Mar 27 19:50:21 CEST 2011 on sn-devel-104
commit 6a771eef1eb94f65734e5a0b2797a58f256c0568
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 17:43:11 2011 +0200
s3: Fix a memleak
commit 00c171dea958263dfc9e21cfaad3aba238e9f58a
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 17:37:24 2011 +0200
s3: Replace a use of cli_errstr
commit 69fe1f1b00b9f00a0f6015d0ae15b67ab3e91b80
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 17:34:36 2011 +0200
s3: Replace cli_negprot_sendsync() by cli_negprot_send()
commit 30aa8a2b0ad77ef1511d2790ea9945168ae5e9f1
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 17:20:28 2011 +0200
s3: Remove a pointless static
commit 3ab85aec684d2a1fea6dbf2493ec1b3b681be61b
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 17:04:56 2011 +0200
s3: Remove a use of cli_send_smb
commit 1c76931f3c4d49a9bec3f45a5e425d9847be088d
Author: Volker Lendecke <vl at samba.org>
Date: Sun Mar 27 11:50:55 2011 +0200
s3: Remove two calls to cli_errstr
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Sun Mar 27 13:17:47 CEST 2011 on sn-devel-104
-----------------------------------------------------------------------
Summary of changes:
source3/client/client.c | 12 ++++--
source3/include/proto.h | 5 +-
source3/libsmb/cliconnect.c | 81 +++++++++++-----------------------------
source3/libsmb/clireadwrite.c | 83 +++++++++++++++++++++++------------------
source3/torture/torture.c | 36 ++++++++++++++---
5 files changed, 108 insertions(+), 109 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/client/client.c b/source3/client/client.c
index a6a7a22..000970e 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1814,12 +1814,15 @@ static int do_put(const char *rname, const char *lname, bool reput)
if (reput) {
status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
if (NT_STATUS_IS_OK(status)) {
- if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
+ if (!NT_STATUS_IS_OK(status = cli_qfileinfo_basic(
targetcli, fnum, NULL,
&start, NULL, NULL,
NULL, NULL, NULL)) &&
- !NT_STATUS_IS_OK(cli_getattrE(targetcli, fnum, NULL, &start, NULL, NULL, NULL))) {
- d_printf("getattrib: %s\n",cli_errstr(cli));
+ !NT_STATUS_IS_OK(status = cli_getattrE(
+ targetcli, fnum, NULL,
+ &start, NULL, NULL,
+ NULL))) {
+ d_printf("getattrib: %s\n", nt_errstr(status));
return 1;
}
}
@@ -1828,7 +1831,8 @@ static int do_put(const char *rname, const char *lname, bool reput)
}
if (!NT_STATUS_IS_OK(status)) {
- d_printf("%s opening remote file %s\n",cli_errstr(targetcli),rname);
+ d_printf("%s opening remote file %s\n", nt_errstr(status),
+ rname);
return 1;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fb752b4..aa0287c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1569,7 +1569,6 @@ struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
struct cli_state *cli);
NTSTATUS cli_tdis_recv(struct tevent_req *req);
NTSTATUS cli_tdis(struct cli_state *cli);
-void cli_negprot_sendsync(struct cli_state *cli);
NTSTATUS cli_negprot(struct cli_state *cli);
struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
@@ -2228,8 +2227,8 @@ ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
ssize_t cli_write(struct cli_state *cli,
uint16_t fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size);
-ssize_t cli_smbwrite(struct cli_state *cli,
- uint16_t fnum, char *buf, off_t offset, size_t size1);
+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,
struct event_context *ev,
struct cli_state *cli, uint16_t fnum,
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 819d835..2fa9e8a 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1913,41 +1913,6 @@ fail:
Send a negprot command.
****************************************************************************/
-void cli_negprot_sendsync(struct cli_state *cli)
-{
- char *p;
- int numprots;
-
- if (cli->protocol < PROTOCOL_NT1)
- cli->use_spnego = False;
-
- memset(cli->outbuf,'\0',smb_size);
-
- /* setup the protocol strings */
- cli_set_message(cli->outbuf,0,0,True);
-
- p = smb_buf(cli->outbuf);
- for (numprots=0; numprots < ARRAY_SIZE(prots); numprots++) {
- if (prots[numprots].prot > cli->protocol) {
- break;
- }
- *p++ = 2;
- p += clistr_push(cli, p, prots[numprots].name, -1, STR_TERMINATE);
- }
-
- SCVAL(cli->outbuf,smb_com,SMBnegprot);
- cli_setup_bcc(cli, p);
- cli_setup_packet(cli);
-
- SCVAL(smb_buf(cli->outbuf),0,2);
-
- cli_send_smb(cli);
-}
-
-/****************************************************************************
- Send a negprot command.
-****************************************************************************/
-
struct cli_negprot_state {
struct cli_state *cli;
};
@@ -2743,7 +2708,10 @@ NTSTATUS cli_raw_tcon(struct cli_state *cli,
const char *service, const char *pass, const char *dev,
uint16 *max_xmit, uint16 *tid)
{
- char *p;
+ struct tevent_req *req;
+ uint16_t *ret_vwv;
+ uint8_t *bytes;
+ NTSTATUS status;
if (!lp_client_plaintext_auth() && (*pass)) {
DEBUG(1, ("Server requested plaintext password but 'client "
@@ -2751,31 +2719,26 @@ NTSTATUS cli_raw_tcon(struct cli_state *cli,
return NT_STATUS_ACCESS_DENIED;
}
- memset(cli->outbuf,'\0',smb_size);
- memset(cli->inbuf,'\0',smb_size);
-
- cli_set_message(cli->outbuf, 0, 0, True);
- SCVAL(cli->outbuf,smb_com,SMBtcon);
- cli_setup_packet(cli);
-
- p = smb_buf(cli->outbuf);
- *p++ = 4; p += clistr_push(cli, p, service, -1, STR_TERMINATE | STR_NOALIGN);
- *p++ = 4; p += clistr_push(cli, p, pass, -1, STR_TERMINATE | STR_NOALIGN);
- *p++ = 4; p += clistr_push(cli, p, dev, -1, STR_TERMINATE | STR_NOALIGN);
-
- cli_setup_bcc(cli, p);
-
- cli_send_smb(cli);
- if (!cli_receive_smb(cli)) {
- return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
- }
-
- if (cli_is_error(cli)) {
- return cli_nt_error(cli);
+ bytes = talloc_array(talloc_tos(), uint8_t, 0);
+ bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ service, strlen(service)+1, NULL);
+ bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ pass, strlen(pass)+1, NULL);
+ bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
+ bytes = smb_bytes_push_str(bytes, cli_ucs2(cli),
+ dev, strlen(dev)+1, NULL);
+
+ status = cli_smb(talloc_tos(), cli, SMBtcon, 0, 0, NULL,
+ talloc_get_size(bytes), bytes, &req,
+ 2, NULL, &ret_vwv, NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- *max_xmit = SVAL(cli->inbuf, smb_vwv0);
- *tid = SVAL(cli->inbuf, smb_vwv1);
+ *max_xmit = SVAL(ret_vwv + 0, 0);
+ *tid = SVAL(ret_vwv + 1, 0);
return NT_STATUS_OK;
}
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index cd95b17..a6620d9 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -856,56 +856,67 @@ ssize_t cli_write(struct cli_state *cli,
write to a file using a SMBwrite and not bypassing 0 byte writes
****************************************************************************/
-ssize_t cli_smbwrite(struct cli_state *cli,
- uint16_t fnum, char *buf, off_t offset, size_t size1)
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+ off_t offset, size_t size1, size_t *ptotal)
{
- char *p;
+ uint8_t *bytes;
ssize_t total = 0;
- do {
- size_t size = MIN(size1, cli->max_xmit - 48);
-
- memset(cli->outbuf,'\0',smb_size);
- memset(cli->inbuf,'\0',smb_size);
-
- cli_set_message(cli->outbuf,5, 0,True);
-
- SCVAL(cli->outbuf,smb_com,SMBwrite);
- SSVAL(cli->outbuf,smb_tid,cli->cnum);
- cli_setup_packet(cli);
-
- SSVAL(cli->outbuf,smb_vwv0,fnum);
- SSVAL(cli->outbuf,smb_vwv1,size);
- SIVAL(cli->outbuf,smb_vwv2,offset);
- SSVAL(cli->outbuf,smb_vwv4,0);
-
- p = smb_buf(cli->outbuf);
- *p++ = 1;
- SSVAL(p, 0, size); p += 2;
- memcpy(p, buf + total, size); p += size;
-
- cli_setup_bcc(cli, p);
+ /*
+ * 3 bytes prefix
+ */
- if (!cli_send_smb(cli))
- return -1;
+ bytes = TALLOC_ARRAY(talloc_tos(), uint8_t, 3);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ bytes[0] = 1;
- if (!cli_receive_smb(cli))
- return -1;
+ do {
+ size_t size = MIN(size1, cli->max_xmit - 48);
+ struct tevent_req *req;
+ uint16_t vwv[5];
+ uint16_t *ret_vwv;
+ NTSTATUS status;
+
+ SSVAL(vwv+0, 0, fnum);
+ SSVAL(vwv+1, 0, size);
+ SIVAL(vwv+2, 0, offset);
+ SSVAL(vwv+4, 0, 0);
+
+ bytes = TALLOC_REALLOC_ARRAY(talloc_tos(), bytes, uint8_t,
+ size+3);
+ if (bytes == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ SSVAL(bytes, 1, size);
+ memcpy(bytes + 3, buf + total, size);
- if (cli_is_error(cli))
- return -1;
+ status = cli_smb(talloc_tos(), cli, SMBwrite, 0, 5, vwv,
+ size+3, bytes, &req, 1, NULL, &ret_vwv,
+ NULL, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(bytes);
+ return status;
+ }
- size = SVAL(cli->inbuf,smb_vwv0);
- if (size == 0)
+ size = SVAL(ret_vwv+0, 0);
+ TALLOC_FREE(req);
+ if (size == 0) {
break;
-
+ }
size1 -= size;
total += size;
offset += size;
} while (size1);
- return total;
+ TALLOC_FREE(bytes);
+
+ if (ptotal != NULL) {
+ *ptotal = total;
+ }
+ return NT_STATUS_OK;
}
/*
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 61cfb9e..66433ec 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -961,7 +961,7 @@ static bool run_readwritelarge_internal(int max_xmit_k)
cli1->max_xmit = 4*1024;
- cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf));
+ cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf), NULL);
if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
cli1, fnum1, NULL, &fsize, NULL, NULL,
@@ -1389,11 +1389,13 @@ static bool run_tcon2_test(int dummy)
status = cli_raw_tcon(cli, service, password, "?????", &max_xmit, &cnum);
+ SAFE_FREE(service);
+
if (!NT_STATUS_IS_OK(status)) {
- printf("tcon2 failed : %s\n", cli_errstr(cli));
+ printf("tcon2 failed : %s\n", nt_errstr(status));
} else {
- printf("tcon OK : max_xmit=%d cnum=%d tid=%d\n",
- (int)max_xmit, (int)cnum, SVAL(cli->inbuf, smb_tid));
+ printf("tcon OK : max_xmit=%d cnum=%d\n",
+ (int)max_xmit, (int)cnum);
}
if (!torture_close_connection(cli)) {
@@ -2776,21 +2778,41 @@ static void rand_buf(char *buf, int len)
/* send smb negprot commands, not reading the response */
static bool run_negprot_nowait(int dummy)
{
+ struct tevent_context *ev;
int i;
- static struct cli_state *cli;
+ struct cli_state *cli;
bool correct = True;
printf("starting negprot nowait test\n");
+ ev = tevent_context_init(talloc_tos());
+ if (ev == NULL) {
+ return false;
+ }
+
if (!(cli = open_nbt_connection())) {
+ TALLOC_FREE(ev);
return False;
}
for (i=0;i<50000;i++) {
- cli_negprot_sendsync(cli);
+ struct tevent_req *req;
+
+ req = cli_negprot_send(ev, ev, cli);
+ if (req == NULL) {
+ TALLOC_FREE(ev);
+ return false;
+ }
+ if (!tevent_req_poll(req, ev)) {
+ d_fprintf(stderr, "tevent_req_poll failed: %s\n",
+ strerror(errno));
+ TALLOC_FREE(ev);
+ return false;
+ }
+ TALLOC_FREE(req);
}
- if (!torture_close_connection(cli)) {
+ if (torture_close_connection(cli)) {
correct = False;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list