summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-08-07 15:01:50 -0700
committerStefan Metzmacher <metze@samba.org>2013-08-15 09:07:06 +0200
commit1229881df6bd22d4b5055ad283061332ba1c9bc8 (patch)
tree057f27ed5fd23898ba5a71847a575320a8fd0c6b
parent00f784ec91d2cfa95b20327ac20f5bc3fa1f400e (diff)
downloadsamba-1229881df6bd22d4b5055ad283061332ba1c9bc8.tar.gz
samba-1229881df6bd22d4b5055ad283061332ba1c9bc8.tar.bz2
samba-1229881df6bd22d4b5055ad283061332ba1c9bc8.zip
libcli/smb: Change smb2cli_create() and smb2cli_create_recv() to return a parameter blob of the newly opened/created file.
Will use in the smb2 client code. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r--libcli/smb/smb2_create_blob.h12
-rw-r--r--libcli/smb/smb2cli_create.c39
-rw-r--r--libcli/smb/smbXcli_base.h7
-rw-r--r--source3/libsmb/cli_np_tstream.c3
-rw-r--r--source3/torture/test_smb2.c48
5 files changed, 69 insertions, 40 deletions
diff --git a/libcli/smb/smb2_create_blob.h b/libcli/smb/smb2_create_blob.h
index 008befe41a..2f915b3afe 100644
--- a/libcli/smb/smb2_create_blob.h
+++ b/libcli/smb/smb2_create_blob.h
@@ -33,6 +33,18 @@ struct smb2_create_blobs {
struct smb2_create_blob *blobs;
};
+struct smb2_create_returns {
+ uint8_t oplock_level;
+ uint32_t create_action;
+ NTTIME creation_time;
+ NTTIME last_access_time;
+ NTTIME last_write_time;
+ NTTIME change_time;
+ uint64_t allocation_size;
+ uint64_t end_of_file;
+ uint32_t file_attributes;
+};
+
/*
parse a set of SMB2 create blobs
*/
diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c
index 627bdcb935..020a4685cb 100644
--- a/libcli/smb/smb2cli_create.c
+++ b/libcli/smb/smb2cli_create.c
@@ -27,17 +27,9 @@
struct smb2cli_create_state {
uint8_t fixed[56];
- uint8_t oplock_level;
- uint32_t create_action;
- NTTIME creation_time;
- NTTIME last_access_time;
- NTTIME last_write_time;
- NTTIME change_time;
- uint64_t allocation_size;
- uint64_t end_of_file;
- uint32_t file_attributes;
uint64_t fid_persistent;
uint64_t fid_volatile;
+ struct smb2_create_returns cr;
struct smb2_create_blobs blobs;
};
@@ -179,15 +171,15 @@ static void smb2cli_create_done(struct tevent_req *subreq)
body = (uint8_t *)iov[1].iov_base;
- state->oplock_level = CVAL(body, 2);
- state->create_action = IVAL(body, 4);
- state->creation_time = BVAL(body, 8);
- state->last_access_time = BVAL(body, 16);
- state->last_write_time = BVAL(body, 24);
- state->change_time = BVAL(body, 32);
- state->allocation_size = BVAL(body, 40);
- state->end_of_file = BVAL(body, 48);
- state->file_attributes = IVAL(body, 56);
+ state->cr.oplock_level = CVAL(body, 2);
+ state->cr.create_action = IVAL(body, 4);
+ state->cr.creation_time = BVAL(body, 8);
+ state->cr.last_access_time = BVAL(body, 16);
+ state->cr.last_write_time = BVAL(body, 24);
+ state->cr.change_time = BVAL(body, 32);
+ state->cr.allocation_size = BVAL(body, 40);
+ state->cr.end_of_file = BVAL(body, 48);
+ state->cr.file_attributes = IVAL(body, 56);
state->fid_persistent = BVAL(body, 64);
state->fid_volatile = BVAL(body, 72);
@@ -213,7 +205,8 @@ static void smb2cli_create_done(struct tevent_req *subreq)
NTSTATUS smb2cli_create_recv(struct tevent_req *req,
uint64_t *fid_persistent,
- uint64_t *fid_volatile)
+ uint64_t *fid_volatile,
+ struct smb2_create_returns *cr)
{
struct smb2cli_create_state *state =
tevent_req_data(req,
@@ -225,6 +218,9 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req,
}
*fid_persistent = state->fid_persistent;
*fid_volatile = state->fid_volatile;
+ if (cr) {
+ *cr = state->cr;
+ }
return NT_STATUS_OK;
}
@@ -242,7 +238,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
uint32_t create_options,
struct smb2_create_blobs *blobs,
uint64_t *fid_persistent,
- uint64_t *fid_volatile)
+ uint64_t *fid_volatile,
+ struct smb2_create_returns *cr)
{
TALLOC_CTX *frame = talloc_stackframe();
struct tevent_context *ev;
@@ -273,7 +270,7 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
goto fail;
}
- status = smb2cli_create_recv(req, fid_persistent, fid_volatile);
+ status = smb2cli_create_recv(req, fid_persistent, fid_volatile, cr);
fail:
TALLOC_FREE(frame);
return status;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 997869ba07..a497e1376f 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -28,6 +28,7 @@ struct smb_trans_enc_state;
struct GUID;
struct iovec;
struct smb2_create_blobs;
+struct smb2_create_returns;
struct smbXcli_conn *smbXcli_conn_create(TALLOC_CTX *mem_ctx,
int fd,
@@ -353,7 +354,8 @@ struct tevent_req *smb2cli_create_send(
struct smb2_create_blobs *blobs);
NTSTATUS smb2cli_create_recv(struct tevent_req *req,
uint64_t *fid_persistent,
- uint64_t *fid_volatile);
+ uint64_t *fid_volatile,
+ struct smb2_create_returns *cr);
NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
uint32_t timeout_msec,
struct smbXcli_session *session,
@@ -368,7 +370,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn,
uint32_t create_options,
struct smb2_create_blobs *blobs,
uint64_t *fid_persistent,
- uint64_t *fid_volatile);
+ uint64_t *fid_volatile,
+ struct smb2_create_returns *cr);
struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/source3/libsmb/cli_np_tstream.c b/source3/libsmb/cli_np_tstream.c
index 07835a5bc2..f3a9962f82 100644
--- a/source3/libsmb/cli_np_tstream.c
+++ b/source3/libsmb/cli_np_tstream.c
@@ -208,7 +208,8 @@ static void tstream_cli_np_open_done(struct tevent_req *subreq)
} else {
status = smb2cli_create_recv(subreq,
&state->fid_persistent,
- &state->fid_volatile);
+ &state->fid_volatile,
+ NULL);
}
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c
index 7ca9f49d1a..3bcd2ed75c 100644
--- a/source3/torture/test_smb2.c
+++ b/source3/torture/test_smb2.c
@@ -83,7 +83,8 @@ bool run_smb2_basic(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create returned %s\n", nt_errstr(status));
return false;
@@ -145,7 +146,8 @@ bool run_smb2_basic(int dummy)
FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create returned %s\n", nt_errstr(status));
return false;
@@ -341,7 +343,8 @@ bool run_smb2_session_reconnect(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create on cli1 %s\n", nt_errstr(status));
return false;
@@ -575,7 +578,8 @@ bool run_smb2_session_reconnect(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
@@ -635,7 +639,8 @@ bool run_smb2_session_reconnect(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED))
{
@@ -662,7 +667,8 @@ bool run_smb2_session_reconnect(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
return false;
@@ -757,7 +763,8 @@ bool run_smb2_tcon_dependence(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create on cli %s\n", nt_errstr(status));
return false;
@@ -1164,7 +1171,8 @@ bool run_smb2_multi_channel(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create on cli2 %s\n", nt_errstr(status));
return false;
@@ -1324,7 +1332,8 @@ bool run_smb2_multi_channel(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;
@@ -1341,7 +1350,8 @@ bool run_smb2_multi_channel(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;
@@ -1358,7 +1368,8 @@ bool run_smb2_multi_channel(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;
@@ -1489,7 +1500,8 @@ bool run_smb2_session_reauth(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;
@@ -1508,7 +1520,8 @@ bool run_smb2_session_reauth(int dummy)
FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&dir_persistent,
- &dir_volatile);
+ &dir_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create returned %s\n", nt_errstr(status));
return false;
@@ -1691,7 +1704,8 @@ bool run_smb2_session_reauth(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;
@@ -1710,7 +1724,8 @@ bool run_smb2_session_reauth(int dummy)
FILE_SYNCHRONOUS_IO_NONALERT|FILE_DIRECTORY_FILE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&dir_persistent,
- &dir_volatile);
+ &dir_volatile,
+ NULL);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
printf("smb2cli_create returned %s\n", nt_errstr(status));
return false;
@@ -1865,7 +1880,8 @@ bool run_smb2_session_reauth(int dummy)
FILE_DELETE_ON_CLOSE, /* create_options, */
NULL, /* smb2_create_blobs *blobs */
&fid_persistent,
- &fid_volatile);
+ &fid_volatile,
+ NULL);
if (!NT_STATUS_IS_OK(status)) {
printf("smb2cli_create %s\n", nt_errstr(status));
return false;