summaryrefslogtreecommitdiffstats
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2014-05-21 11:57:16 -0700
committerJeremy Allison <jra@samba.org>2014-05-23 20:16:12 +0200
commitf739480862373444e9cc8e3790dc052a7ecb271e (patch)
tree6846f39e305cbb5d1b35e86b92dd36e3e557ebb3 /source3/smbd
parentce010d00275bb73dea509213d50eb4062312bf55 (diff)
downloadsamba-f739480862373444e9cc8e3790dc052a7ecb271e.tar.gz
samba-f739480862373444e9cc8e3790dc052a7ecb271e.tar.xz
samba-f739480862373444e9cc8e3790dc052a7ecb271e.zip
s3: smb2: Move from using SBVAL to put NTTIMEs on the wire to put_long_date_timespec.
put_long_date_timespec() correctly calls round_timespec() on the time parameters, and is the correct function to use when writing *any* file-based NTTIME on the wire. Move from using NTTIME variables internally in the server to struct timespec variables, which is what all the other server code uses. Only map to NTTIME as the last step of marshalling the output data. The previous SMB2 create code missed the round_timespec() call before marshalling. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/smb2_create.c85
1 files changed, 43 insertions, 42 deletions
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index 52ed171cc0c..4e82e2c553a 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -80,10 +80,10 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
uint8_t *out_oplock_level,
uint32_t *out_create_action,
- NTTIME *out_creation_time,
- NTTIME *out_last_access_time,
- NTTIME *out_last_write_time,
- NTTIME *out_change_time,
+ struct timespec *out_creation_ts,
+ struct timespec *out_last_access_ts,
+ struct timespec *out_last_write_ts,
+ struct timespec *out_change_ts,
uint64_t *out_allocation_size,
uint64_t *out_end_of_file,
uint32_t *out_file_attributes,
@@ -264,10 +264,11 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
DATA_BLOB outdyn;
uint8_t out_oplock_level = 0;
uint32_t out_create_action = 0;
- NTTIME out_creation_time = 0;
- NTTIME out_last_access_time = 0;
- NTTIME out_last_write_time = 0;
- NTTIME out_change_time = 0;
+ connection_struct *conn = smb2req->tcon->compat;
+ struct timespec out_creation_ts = { 0, };
+ struct timespec out_last_access_ts = { 0, };
+ struct timespec out_last_write_ts = { 0, };
+ struct timespec out_change_ts = { 0, };
uint64_t out_allocation_size = 0;
uint64_t out_end_of_file = 0;
uint32_t out_file_attributes = 0;
@@ -283,10 +284,10 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
smb2req,
&out_oplock_level,
&out_create_action,
- &out_creation_time,
- &out_last_access_time,
- &out_last_write_time,
- &out_change_time,
+ &out_creation_ts,
+ &out_last_access_ts,
+ &out_last_write_ts,
+ &out_change_ts,
&out_allocation_size,
&out_end_of_file,
&out_file_attributes,
@@ -335,14 +336,18 @@ static void smbd_smb2_request_create_done(struct tevent_req *tsubreq)
SCVAL(outbody.data, 0x03, 0); /* reserved */
SIVAL(outbody.data, 0x04,
out_create_action); /* create action */
- SBVAL(outbody.data, 0x08,
- out_creation_time); /* creation time */
- SBVAL(outbody.data, 0x10,
- out_last_access_time); /* last access time */
- SBVAL(outbody.data, 0x18,
- out_last_write_time); /* last write time */
- SBVAL(outbody.data, 0x20,
- out_change_time); /* change time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)outbody.data + 0x08,
+ out_creation_ts); /* creation time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)outbody.data + 0x10,
+ out_last_access_ts); /* last access time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)outbody.data + 0x18,
+ out_last_write_ts); /* last write time */
+ put_long_date_timespec(conn->ts_res,
+ (char *)outbody.data + 0x20,
+ out_change_ts); /* change time */
SBVAL(outbody.data, 0x28,
out_allocation_size); /* allocation size */
SBVAL(outbody.data, 0x30,
@@ -380,10 +385,10 @@ struct smbd_smb2_create_state {
DATA_BLOB private_data;
uint8_t out_oplock_level;
uint32_t out_create_action;
- NTTIME out_creation_time;
- NTTIME out_last_access_time;
- NTTIME out_last_write_time;
- NTTIME out_change_time;
+ struct timespec out_creation_ts;
+ struct timespec out_last_access_ts;
+ struct timespec out_last_write_ts;
+ struct timespec out_change_ts;
uint64_t out_allocation_size;
uint64_t out_end_of_file;
uint32_t out_file_attributes;
@@ -1065,16 +1070,12 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
state->out_file_attributes = dos_mode(result->conn,
result->fsp_name);
- unix_timespec_to_nt_time(&state->out_creation_time,
- get_create_timespec(smb1req->conn, result,
- result->fsp_name));
- unix_timespec_to_nt_time(&state->out_last_access_time,
- result->fsp_name->st.st_ex_atime);
- unix_timespec_to_nt_time(&state->out_last_write_time,
- result->fsp_name->st.st_ex_mtime);
- unix_timespec_to_nt_time(&state->out_change_time,
- get_change_timespec(smb1req->conn, result,
- result->fsp_name));
+ state->out_creation_ts = get_create_timespec(smb1req->conn,
+ result, result->fsp_name);
+ state->out_last_access_ts = result->fsp_name->st.st_ex_atime;
+ state->out_last_write_ts = result->fsp_name->st.st_ex_mtime;
+ state->out_change_ts = get_change_timespec(smb1req->conn,
+ result, result->fsp_name);
state->out_allocation_size =
SMB_VFS_GET_ALLOC_SIZE(smb1req->conn, result,
&(result->fsp_name->st));
@@ -1097,10 +1098,10 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
TALLOC_CTX *mem_ctx,
uint8_t *out_oplock_level,
uint32_t *out_create_action,
- NTTIME *out_creation_time,
- NTTIME *out_last_access_time,
- NTTIME *out_last_write_time,
- NTTIME *out_change_time,
+ struct timespec *out_creation_ts,
+ struct timespec *out_last_access_ts,
+ struct timespec *out_last_write_ts,
+ struct timespec *out_change_ts,
uint64_t *out_allocation_size,
uint64_t *out_end_of_file,
uint32_t *out_file_attributes,
@@ -1119,10 +1120,10 @@ static NTSTATUS smbd_smb2_create_recv(struct tevent_req *req,
*out_oplock_level = state->out_oplock_level;
*out_create_action = state->out_create_action;
- *out_creation_time = state->out_creation_time;
- *out_last_access_time = state->out_last_access_time;
- *out_last_write_time = state->out_last_write_time;
- *out_change_time = state->out_change_time;
+ *out_creation_ts = state->out_creation_ts;
+ *out_last_access_ts = state->out_last_access_ts;
+ *out_last_write_ts = state->out_last_write_ts;
+ *out_change_ts = state->out_change_ts;
*out_allocation_size = state->out_allocation_size;
*out_end_of_file = state->out_end_of_file;
*out_file_attributes = state->out_file_attributes;