summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-04-10 20:18:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:11 -0500
commitac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 (patch)
treebcd9a0afdc2996df4a56479932b7d36d32c50f8d /source4/libcli
parent91b30df39bfaec8bfa32be40a13fd62008f66b9e (diff)
downloadsamba-ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5.tar.gz
samba-ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5.tar.bz2
samba-ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5.zip
r152: a quick airport commit ....
added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/config.m43
-rw-r--r--source4/libcli/raw/rawdate.c81
-rw-r--r--source4/libcli/raw/rawfile.c27
-rw-r--r--source4/libcli/raw/rawfileinfo.c30
-rw-r--r--source4/libcli/raw/rawnegotiate.c7
-rw-r--r--source4/libcli/raw/rawreadwrite.c3
-rw-r--r--source4/libcli/raw/rawsearch.c21
-rw-r--r--source4/libcli/raw/rawsetfileinfo.c21
-rw-r--r--source4/libcli/util/smbencrypt.c5
9 files changed, 159 insertions, 39 deletions
diff --git a/source4/libcli/config.m4 b/source4/libcli/config.m4
index ac8e7cbabb..b5273b9bb2 100644
--- a/source4/libcli/config.m4
+++ b/source4/libcli/config.m4
@@ -10,7 +10,8 @@ SMB_SUBSYSTEM(LIBCLI_RAW,[],
libcli/raw/rawtrans.o libcli/raw/clioplock.o \
libcli/raw/rawnegotiate.o libcli/raw/rawfsinfo.o \
libcli/raw/rawfileinfo.o libcli/raw/rawnotify.o \
- libcli/raw/rawioctl.o libcli/raw/rawacl.o],
+ libcli/raw/rawioctl.o libcli/raw/rawacl.o \
+ libcli/raw/rawdate.o ],
libcli/raw/libcli_raw_public_proto.h)
SMB_SUBSYSTEM(LIBCLI_UTILS,[],
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);
diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c
index 39f3803ade..fc3449d767 100644
--- a/source4/libcli/util/smbencrypt.c
+++ b/source4/libcli/util/smbencrypt.c
@@ -342,10 +342,13 @@ static DATA_BLOB NTLMv2_generate_client_data(const DATA_BLOB *names_blob)
uchar client_chal[8];
DATA_BLOB response = data_blob(NULL, 0);
char long_date[8];
+ NTTIME nttime;
+
+ unix_to_nt_time(&nttime, time(NULL));
generate_random_buffer(client_chal, sizeof(client_chal), False);
- put_long_date(long_date, time(NULL));
+ push_nttime(long_date, 0, &nttime);
/* See http://www.ubiqx.org/cifs/SMB.html#SMB.8.5 */