diff options
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r-- | source4/libcli/raw/rawdate.c | 81 | ||||
-rw-r--r-- | source4/libcli/raw/rawfile.c | 27 | ||||
-rw-r--r-- | source4/libcli/raw/rawfileinfo.c | 30 | ||||
-rw-r--r-- | source4/libcli/raw/rawnegotiate.c | 7 | ||||
-rw-r--r-- | source4/libcli/raw/rawreadwrite.c | 3 | ||||
-rw-r--r-- | source4/libcli/raw/rawsearch.c | 21 | ||||
-rw-r--r-- | source4/libcli/raw/rawsetfileinfo.c | 21 |
7 files changed, 153 insertions, 37 deletions
diff --git a/source4/libcli/raw/rawdate.c b/source4/libcli/raw/rawdate.c new file mode 100644 index 0000000000..e80c376bf7 --- /dev/null +++ b/source4/libcli/raw/rawdate.c @@ -0,0 +1,81 @@ +/* + Unix SMB/CIFS implementation. + + raw date handling functions + + Copyright (C) Andrew Tridgell 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/******************************************************************* +put a dos date into a buffer (time/date format) +This takes GMT time and puts local time for zone_offset in the buffer +********************************************************************/ +void raw_push_dos_date(struct cli_transport *transport, + uint8 *buf, int offset, time_t unixdate) +{ + push_dos_date(buf, offset, unixdate, transport->negotiate.server_zone); +} + +/******************************************************************* +put a dos date into a buffer (date/time format) +This takes GMT time and puts local time in the buffer +********************************************************************/ +void raw_push_dos_date2(struct cli_transport *transport, + char *buf, int offset, time_t unixdate) +{ + push_dos_date2(buf, offset, unixdate, transport->negotiate.server_zone); +} + +/******************************************************************* +put a dos 32 bit "unix like" date into a buffer. This routine takes +GMT and converts it to LOCAL time in zone_offset before putting it +********************************************************************/ +void raw_push_dos_date3(struct cli_transport *transport, + char *buf, int offset, time_t unixdate) +{ + push_dos_date3(buf, offset, unixdate, transport->negotiate.server_zone); +} + +/******************************************************************* +convert a dos date +********************************************************************/ +time_t raw_pull_dos_date(struct cli_transport *transport, + const uint8 *date_ptr) +{ + return pull_dos_date(date_ptr, transport->negotiate.server_zone); +} + +/******************************************************************* +like raw_pull_dos_date() but the words are reversed +********************************************************************/ +time_t raw_pull_dos_date2(struct cli_transport *transport, + const uint8 *date_ptr) +{ + return pull_dos_date2(date_ptr, transport->negotiate.server_zone); +} + +/******************************************************************* + create a unix GMT date from a dos date in 32 bit "unix like" format + these arrive in server zone, with corresponding DST + ******************************************************************/ +time_t raw_pull_dos_date3(struct cli_transport *transport, + const uint8 *date_ptr) +{ + return pull_dos_date3(date_ptr, transport->negotiate.server_zone); +} diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index 0dc2a15c11..d1a665ab14 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -240,7 +240,8 @@ static struct cli_request *smb_raw_t2open_send(struct cli_tree *tree, SSVAL(t2.in.params.data, VWV(1), parms->t2open.in.open_mode); SSVAL(t2.in.params.data, VWV(2), 0); /* reserved */ SSVAL(t2.in.params.data, VWV(3), parms->t2open.in.file_attrs); - put_dos_date(t2.in.params.data, VWV(4), parms->t2open.in.write_time); + raw_push_dos_date(tree->session->transport, + t2.in.params.data, VWV(4), parms->t2open.in.write_time); SSVAL(t2.in.params.data, VWV(6), parms->t2open.in.open_func); SIVAL(t2.in.params.data, VWV(7), parms->t2open.in.size); SIVAL(t2.in.params.data, VWV(9), parms->t2open.in.timeout); @@ -278,7 +279,8 @@ static NTSTATUS smb_raw_t2open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx parms->t2open.out.fnum = SVAL(t2.out.params.data, VWV(0)); parms->t2open.out.attrib = SVAL(t2.out.params.data, VWV(1)); - parms->t2open.out.write_time = make_unix_date3(t2.out.params.data + VWV(2)); + parms->t2open.out.write_time = raw_pull_dos_date3(req->transport, + t2.out.params.data + VWV(2)); parms->t2open.out.size = IVAL(t2.out.params.data, VWV(4)); parms->t2open.out.access = SVAL(t2.out.params.data, VWV(6)); parms->t2open.out.ftype = SVAL(t2.out.params.data, VWV(7)); @@ -316,7 +318,8 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SSVAL(req->out.vwv, VWV(3), parms->openx.in.open_mode); SSVAL(req->out.vwv, VWV(4), parms->openx.in.search_attrs); SSVAL(req->out.vwv, VWV(5), parms->openx.in.file_attrs); - put_dos_date3(req->out.vwv, VWV(6), parms->openx.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(6), parms->openx.in.write_time); SSVAL(req->out.vwv, VWV(8), parms->openx.in.open_func); SIVAL(req->out.vwv, VWV(9), parms->openx.in.size); SIVAL(req->out.vwv, VWV(11),parms->openx.in.timeout); @@ -327,21 +330,24 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par case RAW_OPEN_MKNEW: SETUP_REQUEST(SMBmknew, 3, 0); SSVAL(req->out.vwv, VWV(0), parms->mknew.in.attrib); - put_dos_date3(req->out.vwv, VWV(1), parms->mknew.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(1), parms->mknew.in.write_time); cli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE); break; case RAW_OPEN_CREATE: SETUP_REQUEST(SMBcreate, 3, 0); SSVAL(req->out.vwv, VWV(0), parms->create.in.attrib); - put_dos_date3(req->out.vwv, VWV(1), parms->create.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(1), parms->create.in.write_time); cli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE); break; case RAW_OPEN_CTEMP: SETUP_REQUEST(SMBctemp, 3, 0); SSVAL(req->out.vwv, VWV(0), parms->ctemp.in.attrib); - put_dos_date3(req->out.vwv, VWV(1), parms->ctemp.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(1), parms->ctemp.in.write_time); cli_req_append_ascii4(req, parms->ctemp.in.directory, STR_TERMINATE); break; @@ -398,7 +404,8 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s CLI_CHECK_WCT(req, 7); parms->open.out.fnum = SVAL(req->in.vwv, VWV(0)); parms->open.out.attrib = SVAL(req->in.vwv, VWV(1)); - parms->open.out.write_time = make_unix_date3(req->in.vwv + VWV(2)); + parms->open.out.write_time = raw_pull_dos_date3(req->transport, + req->in.vwv + VWV(2)); parms->open.out.size = IVAL(req->in.vwv, VWV(4)); parms->open.out.rmode = SVAL(req->in.vwv, VWV(6)); break; @@ -407,7 +414,8 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s CLI_CHECK_MIN_WCT(req, 15); parms->openx.out.fnum = SVAL(req->in.vwv, VWV(2)); parms->openx.out.attrib = SVAL(req->in.vwv, VWV(3)); - parms->openx.out.write_time = make_unix_date3(req->in.vwv + VWV(4)); + parms->openx.out.write_time = raw_pull_dos_date3(req->transport, + req->in.vwv + VWV(4)); parms->openx.out.size = IVAL(req->in.vwv, VWV(6)); parms->openx.out.access = SVAL(req->in.vwv, VWV(8)); parms->openx.out.ftype = SVAL(req->in.vwv, VWV(9)); @@ -491,7 +499,8 @@ struct cli_request *smb_raw_close_send(struct cli_tree *tree, union smb_close *p case RAW_CLOSE_CLOSE: SETUP_REQUEST(SMBclose, 3, 0); SSVAL(req->out.vwv, VWV(0), parms->close.in.fnum); - put_dos_date3(req->out.vwv, VWV(1), parms->close.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(1), parms->close.in.write_time); break; case RAW_CLOSE_SPLCLOSE: diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index fd66080057..9d715e6104 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -52,9 +52,12 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, case RAW_FILEINFO_STANDARD: FINFO_CHECK_SIZE(22); - parms->standard.out.create_time = make_unix_date2(blob->data + 0); - parms->standard.out.access_time = make_unix_date2(blob->data + 4); - parms->standard.out.write_time = make_unix_date2(blob->data + 8); + parms->standard.out.create_time = raw_pull_dos_date2(session->transport, + blob->data + 0); + parms->standard.out.access_time = raw_pull_dos_date2(session->transport, + blob->data + 4); + parms->standard.out.write_time = raw_pull_dos_date2(session->transport, + blob->data + 8); parms->standard.out.size = IVAL(blob->data, 12); parms->standard.out.alloc_size = IVAL(blob->data, 16); parms->standard.out.attrib = SVAL(blob->data, 20); @@ -62,9 +65,12 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, case RAW_FILEINFO_EA_SIZE: FINFO_CHECK_SIZE(26); - parms->ea_size.out.create_time = make_unix_date2(blob->data + 0); - parms->ea_size.out.access_time = make_unix_date2(blob->data + 4); - parms->ea_size.out.write_time = make_unix_date2(blob->data + 8); + parms->ea_size.out.create_time = raw_pull_dos_date2(session->transport, + blob->data + 0); + parms->ea_size.out.access_time = raw_pull_dos_date2(session->transport, + blob->data + 4); + parms->ea_size.out.write_time = raw_pull_dos_date2(session->transport, + blob->data + 8); parms->ea_size.out.size = IVAL(blob->data, 12); parms->ea_size.out.alloc_size = IVAL(blob->data, 16); parms->ea_size.out.attrib = SVAL(blob->data, 20); @@ -376,7 +382,8 @@ static NTSTATUS smb_raw_getattr_recv(struct cli_request *req, CLI_CHECK_WCT(req, 10); parms->getattr.out.attrib = SVAL(req->in.vwv, VWV(0)); - parms->getattr.out.write_time = make_unix_date3(req->in.vwv + VWV(1)); + parms->getattr.out.write_time = raw_pull_dos_date3(req->transport, + req->in.vwv + VWV(1)); parms->getattr.out.size = IVAL(req->in.vwv, VWV(3)); failed: @@ -416,9 +423,12 @@ static NTSTATUS smb_raw_getattrE_recv(struct cli_request *req, } CLI_CHECK_WCT(req, 11); - parms->getattre.out.create_time = make_unix_date2(req->in.vwv + VWV(0)); - parms->getattre.out.access_time = make_unix_date2(req->in.vwv + VWV(2)); - parms->getattre.out.write_time = make_unix_date2(req->in.vwv + VWV(4)); + parms->getattre.out.create_time = raw_pull_dos_date2(req->transport, + req->in.vwv + VWV(0)); + parms->getattre.out.access_time = raw_pull_dos_date2(req->transport, + req->in.vwv + VWV(2)); + parms->getattre.out.write_time = raw_pull_dos_date2(req->transport, + req->in.vwv + VWV(4)); parms->getattre.out.size = IVAL(req->in.vwv, VWV(6)); parms->getattre.out.alloc_size = IVAL(req->in.vwv, VWV(8)); parms->getattre.out.attrib = SVAL(req->in.vwv, VWV(10)); diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c index 04941f6118..587050bef8 100644 --- a/source4/libcli/raw/rawnegotiate.c +++ b/source4/libcli/raw/rawnegotiate.c @@ -129,8 +129,9 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) transport->negotiate.sesskey = IVAL(req->in.vwv,VWV(6)); transport->negotiate.server_zone = SVALS(req->in.vwv,VWV(10)) * 60; - /* this time is converted to GMT by make_unix_date */ - transport->negotiate.server_time = make_unix_date(req->in.vwv+VWV(8)); + /* this time is converted to GMT by raw_pull_dos_date */ + transport->negotiate.server_time = raw_pull_dos_date(transport, + req->in.vwv+VWV(8)); if ((SVAL(req->in.vwv,VWV(5)) & 0x1)) { transport->negotiate.readbraw_supported = 1; } @@ -144,7 +145,7 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) transport->negotiate.sec_mode = 0; transport->negotiate.server_time = time(NULL); transport->negotiate.max_xmit = ~0; - transport->negotiate.server_zone = TimeDiff(time(NULL)); + transport->negotiate.server_zone = get_time_zone(transport->negotiate.server_time); } /* a way to force ascii SMB */ diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c index 3aa95c35aa..3e3b29d252 100644 --- a/source4/libcli/raw/rawreadwrite.c +++ b/source4/libcli/raw/rawreadwrite.c @@ -223,7 +223,8 @@ struct cli_request *smb_raw_write_send(struct cli_tree *tree, union smb_write *p SSVAL(req->out.vwv, VWV(0), parms->writeclose.in.fnum); SSVAL(req->out.vwv, VWV(1), parms->writeclose.in.count); SIVAL(req->out.vwv, VWV(2), parms->writeclose.in.offset); - put_dos_date3(req->out.vwv, VWV(4), parms->writeclose.in.mtime); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(4), parms->writeclose.in.mtime); SCVAL(req->out.data, 0, 0); if (parms->writeclose.in.count > 0) { memcpy(req->out.data+1, parms->writeclose.in.data, diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c index 4c7da6ec4d..a4236d2dbe 100644 --- a/source4/libcli/raw/rawsearch.c +++ b/source4/libcli/raw/rawsearch.c @@ -44,7 +44,8 @@ static void smb_raw_search_backend(struct cli_request *req, for (i=0; i < count; i++) { search_data.search.search_id = cli_req_pull_blob(req, mem_ctx, p, 21); search_data.search.attrib = CVAL(p, 21); - search_data.search.write_time = make_unix_date(p + 22); + search_data.search.write_time = raw_pull_dos_date(req->transport, + p + 22); search_data.search.size = IVAL(p, 26); cli_req_pull_ascii(req, mem_ctx, &search_data.search.name, p+30, 13, STR_ASCII); if (!callback(private, &search_data)) { @@ -255,9 +256,12 @@ static int parse_trans2_search(struct cli_tree *tree, blob->length -= 4; } if (blob->length < 24) return -1; - data->standard.create_time = make_unix_date2(blob->data + 0); - data->standard.access_time = make_unix_date2(blob->data + 4); - data->standard.write_time = make_unix_date2(blob->data + 8); + data->standard.create_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 0); + data->standard.access_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 4); + data->standard.write_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 8); data->standard.size = IVAL(blob->data, 12); data->standard.alloc_size = IVAL(blob->data, 16); data->standard.attrib = SVAL(blob->data, 20); @@ -274,9 +278,12 @@ static int parse_trans2_search(struct cli_tree *tree, blob->length -= 4; } if (blob->length < 28) return -1; - data->ea_size.create_time = make_unix_date2(blob->data + 0); - data->ea_size.access_time = make_unix_date2(blob->data + 4); - data->ea_size.write_time = make_unix_date2(blob->data + 8); + data->ea_size.create_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 0); + data->ea_size.access_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 4); + data->ea_size.write_time = raw_pull_dos_date2(tree->session->transport, + blob->data + 8); data->ea_size.size = IVAL(blob->data, 12); data->ea_size.alloc_size = IVAL(blob->data, 16); data->ea_size.attrib = SVAL(blob->data, 20); diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c index b82c20176b..9da94f161c 100644 --- a/source4/libcli/raw/rawsetfileinfo.c +++ b/source4/libcli/raw/rawsetfileinfo.c @@ -45,9 +45,12 @@ static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, case RAW_SFILEINFO_STANDARD: NEED_BLOB(12); - put_dos_date2(blob->data, 0, parms->standard.in.create_time); - put_dos_date2(blob->data, 4, parms->standard.in.access_time); - put_dos_date2(blob->data, 8, parms->standard.in.write_time); + raw_push_dos_date2(tree->session->transport, + blob->data, 0, parms->standard.in.create_time); + raw_push_dos_date2(tree->session->transport, + blob->data, 4, parms->standard.in.access_time); + raw_push_dos_date2(tree->session->transport, + blob->data, 8, parms->standard.in.write_time); return True; case RAW_SFILEINFO_EA_SET: @@ -204,7 +207,8 @@ static struct cli_request *smb_raw_setattr_send(struct cli_tree *tree, if (!req) return NULL; SSVAL(req->out.vwv, VWV(0), parms->setattr.in.attrib); - put_dos_date3(req->out.vwv, VWV(1), parms->setattr.in.write_time); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(1), parms->setattr.in.write_time); memset(req->out.vwv + VWV(3), 0, 10); /* reserved */ cli_req_append_ascii4(req, parms->setattr.file.fname, STR_TERMINATE); cli_req_append_ascii4(req, "", STR_TERMINATE); @@ -229,9 +233,12 @@ static struct cli_request *smb_raw_setattrE_send(struct cli_tree *tree, if (!req) return NULL; SSVAL(req->out.vwv, VWV(0), parms->setattre.file.fnum); - put_dos_date2(req->out.vwv, VWV(1), parms->setattre.in.create_time); - put_dos_date2(req->out.vwv, VWV(3), parms->setattre.in.access_time); - put_dos_date2(req->out.vwv, VWV(5), parms->setattre.in.write_time); + raw_push_dos_date2(tree->session->transport, + req->out.vwv, VWV(1), parms->setattre.in.create_time); + raw_push_dos_date2(tree->session->transport, + req->out.vwv, VWV(3), parms->setattre.in.access_time); + raw_push_dos_date2(tree->session->transport, + req->out.vwv, VWV(5), parms->setattre.in.write_time); if (!cli_request_send(req)) { cli_request_destroy(req); |