diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-04-10 20:18:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:11 -0500 |
commit | ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 (patch) | |
tree | bcd9a0afdc2996df4a56479932b7d36d32c50f8d /source4/smb_server | |
parent | 91b30df39bfaec8bfa32be40a13fd62008f66b9e (diff) | |
download | samba-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/smb_server')
-rw-r--r-- | source4/smb_server/config.m4 | 25 | ||||
-rw-r--r-- | source4/smb_server/negprot.c | 15 | ||||
-rw-r--r-- | source4/smb_server/reply.c | 53 | ||||
-rw-r--r-- | source4/smb_server/search.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 2 | ||||
-rw-r--r-- | source4/smb_server/srvtime.c | 81 | ||||
-rw-r--r-- | source4/smb_server/trans2.c | 30 |
7 files changed, 137 insertions, 71 deletions
diff --git a/source4/smb_server/config.m4 b/source4/smb_server/config.m4 index 4ce688850c..e49f610317 100644 --- a/source4/smb_server/config.m4 +++ b/source4/smb_server/config.m4 @@ -1,16 +1,17 @@ dnl # SMB server subsystem SMB_SUBSYSTEM(SMB,smb_server/smb_server.o, - [smb_server/conn.o ]\ - [smb_server/connection.o]\ - [smb_server/negprot.o]\ - [smb_server/nttrans.o]\ - [smb_server/password.o]\ - [smb_server/reply.o]\ - [smb_server/request.o]\ - [smb_server/search.o]\ - [smb_server/service.o]\ - [smb_server/session.o]\ - [smb_server/sesssetup.o]\ - [smb_server/trans2.o], + [smb_server/conn.o \ + smb_server/connection.o \ + smb_server/negprot.o \ + smb_server/nttrans.o \ + smb_server/password.o \ + smb_server/reply.o \ + smb_server/request.o \ + smb_server/search.o \ + smb_server/service.o \ + smb_server/session.o \ + smb_server/sesssetup.o \ + smb_server/srvtime.o \ + smb_server/trans2.o],\ smb_server/smb_server_public_proto.h) diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c index caf3ce33b9..92ce5675ad 100644 --- a/source4/smb_server/negprot.c +++ b/source4/smb_server/negprot.c @@ -119,8 +119,8 @@ static void reply_lanman1(struct request_context *req, uint16 choice) SSVAL(req->out.vwv, VWV(4), 1); SSVAL(req->out.vwv, VWV(5), raw); SIVAL(req->out.vwv, VWV(6), req->smb->pid); - put_dos_date(req->out.vwv, VWV(8), t); - SSVAL(req->out.vwv, VWV(10), TimeDiff(t)/60); + srv_push_dos_date(req->smb, req->out.vwv, VWV(8), t); + SSVAL(req->out.vwv, VWV(10), req->smb->negotiate.zone_offset/60); /* Create a token value and add it to the outgoing packet. */ if (req->smb->negotiate.encrypted_passwords) { @@ -159,8 +159,8 @@ static void reply_lanman2(struct request_context *req, uint16 choice) SSVAL(req->out.vwv, VWV(4), 1); SSVAL(req->out.vwv, VWV(5), raw); SIVAL(req->out.vwv, VWV(6), req->smb->pid); - put_dos_date(req->out.vwv, VWV(8), t); - SSVAL(req->out.vwv, VWV(10), TimeDiff(t)/60); + srv_push_dos_date(req->smb, req->out.vwv, VWV(8), t); + SSVAL(req->out.vwv, VWV(10), req->smb->negotiate.zone_offset/60); /* Create a token value and add it to the outgoing packet. */ if (req->smb->negotiate.encrypted_passwords) { @@ -229,8 +229,11 @@ static void reply_nt1(struct request_context *req, uint16 choice) int capabilities; int secword=0; time_t t = req->request_time.tv_sec; + NTTIME nttime; BOOL negotiate_spnego = False; + unix_to_nt_time(&nttime, t); + capabilities = CAP_NT_FIND | CAP_LOCK_AND_READ | CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS; @@ -303,8 +306,8 @@ static void reply_nt1(struct request_context *req, uint16 choice) SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */ SIVAL(req->out.vwv+1, VWV(7), req->smb->pid); /* session key */ SIVAL(req->out.vwv+1, VWV(9), capabilities); - put_long_date(req->out.vwv + VWV(11) + 1, t); - SSVALS(req->out.vwv+1,VWV(15), TimeDiff(t)/60); + push_nttime(req->out.vwv+1, VWV(11), &nttime); + SSVALS(req->out.vwv+1,VWV(15), req->smb->negotiate.zone_offset/60); if (!negotiate_spnego) { /* Create a token value and add it to the outgoing packet. */ diff --git a/source4/smb_server/reply.c b/source4/smb_server/reply.c index 298b2443d3..8b9bb4fb5e 100644 --- a/source4/smb_server/reply.c +++ b/source4/smb_server/reply.c @@ -62,27 +62,6 @@ /* zero out some reserved fields in a reply */ #define REQ_VWV_RESERVED(start, count) memset(req->out.vwv + VWV(start), 0, (count)*2) -/* - put a NTTIME into a packet -*/ -void push_nttime(void *base, uint16 offset, NTTIME *t) -{ - SIVAL(base, offset, t->low); - SIVAL(base, offset+4, t->high); -} - -/* - pull a NTTIME from a packet -*/ -NTTIME pull_nttime(void *base, uint16 offset) -{ - NTTIME ret; - ret.low = IVAL(base, offset); - ret.high = IVAL(base, offset+4); - return ret; -} - - /**************************************************************************** Reply to a simple request (async send) ****************************************************************************/ @@ -298,7 +277,7 @@ static void reply_getatr_send(struct request_context *req) req_setup_reply(req, 10, 0); SSVAL(req->out.vwv, VWV(0), st->getattr.out.attrib); - put_dos_date3(req->out.vwv, VWV(1), st->getattr.out.write_time); + srv_push_dos_date3(req->smb, req->out.vwv, VWV(1), st->getattr.out.write_time); SIVAL(req->out.vwv, VWV(3), st->getattr.out.size); REQ_VWV_RESERVED(5, 5); @@ -348,7 +327,7 @@ void reply_setatr(struct request_context *req) st->setattr.level = RAW_SFILEINFO_SETATTR; st->setattr.in.attrib = SVAL(req->in.vwv, VWV(0)); - st->setattr.in.write_time = make_unix_date3(req->in.vwv + VWV(1)); + st->setattr.in.write_time = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(1)); req_pull_ascii4(req, &st->setattr.file.fname, req->in.data, STR_TERMINATE); @@ -425,7 +404,7 @@ static void reply_open_send(struct request_context *req) SSVAL(req->out.vwv, VWV(0), oi->open.out.fnum); SSVAL(req->out.vwv, VWV(1), oi->open.out.attrib); - put_dos_date3(req->out.vwv, VWV(2), oi->open.out.write_time); + srv_push_dos_date3(req->smb, req->out.vwv, VWV(2), oi->open.out.write_time); SIVAL(req->out.vwv, VWV(4), oi->open.out.size); SSVAL(req->out.vwv, VWV(6), oi->open.out.rmode); @@ -484,7 +463,7 @@ static void reply_open_and_X_send(struct request_context *req) SSVAL(req->out.vwv, VWV(1), 0); SSVAL(req->out.vwv, VWV(2), oi->openx.out.fnum); SSVAL(req->out.vwv, VWV(3), oi->openx.out.attrib); - put_dos_date3(req->out.vwv, VWV(4), oi->openx.out.write_time); + srv_push_dos_date3(req->smb, req->out.vwv, VWV(4), oi->openx.out.write_time); SIVAL(req->out.vwv, VWV(6), oi->openx.out.size); SSVAL(req->out.vwv, VWV(8), oi->openx.out.access); SSVAL(req->out.vwv, VWV(9), oi->openx.out.ftype); @@ -517,7 +496,7 @@ void reply_open_and_X(struct request_context *req) oi->openx.in.open_mode = SVAL(req->in.vwv, VWV(3)); oi->openx.in.search_attrs = SVAL(req->in.vwv, VWV(4)); oi->openx.in.file_attrs = SVAL(req->in.vwv, VWV(5)); - oi->openx.in.write_time = make_unix_date3(req->in.vwv + VWV(6)); + oi->openx.in.write_time = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(6)); oi->openx.in.open_func = SVAL(req->in.vwv, VWV(8)); oi->openx.in.size = IVAL(req->in.vwv, VWV(9)); oi->openx.in.timeout = IVAL(req->in.vwv, VWV(11)); @@ -570,7 +549,7 @@ void reply_mknew(struct request_context *req) oi->mknew.level = RAW_OPEN_MKNEW; oi->mknew.in.attrib = SVAL(req->in.vwv, VWV(0)); - oi->mknew.in.write_time = make_unix_date3(req->in.vwv + VWV(1)); + oi->mknew.in.write_time = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(1)); req_pull_ascii4(req, &oi->mknew.in.fname, req->in.data, STR_TERMINATE); @@ -621,7 +600,7 @@ void reply_ctemp(struct request_context *req) oi->ctemp.level = RAW_OPEN_CTEMP; oi->ctemp.in.attrib = SVAL(req->in.vwv, VWV(0)); - oi->ctemp.in.write_time = make_unix_date3(req->in.vwv + VWV(1)); + oi->ctemp.in.write_time = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(1)); /* the filename is actually a directory name, the server provides a filename in that directory */ @@ -1224,7 +1203,7 @@ void reply_close(struct request_context *req) io->close.level = RAW_CLOSE_CLOSE; io->close.in.fnum = req_fnum(req, req->in.vwv, VWV(0)); - io->close.in.write_time = make_unix_date3(req->in.vwv + VWV(1)); + io->close.in.write_time = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(1)); req->async.send_fn = reply_simple_send; @@ -1271,7 +1250,7 @@ void reply_writeclose(struct request_context *req) io->writeclose.in.fnum = req_fnum(req, req->in.vwv, VWV(0)); io->writeclose.in.count = SVAL(req->in.vwv, VWV(1)); io->writeclose.in.offset = IVAL(req->in.vwv, VWV(2)); - io->writeclose.in.mtime = make_unix_date3(req->in.vwv + VWV(4)); + io->writeclose.in.mtime = srv_pull_dos_date3(req->smb, req->in.vwv + VWV(4)); io->writeclose.in.data = req->in.data + 1; /* make sure they gave us the data they promised */ @@ -1486,7 +1465,7 @@ void reply_printqueue_send(struct request_context *req) req->out.ptr = req->out.data + 3; for (i=0;i<lpq->retq.out.count;i++) { - put_dos_date2(req->out.ptr, 0 , lpq->retq.out.queue[i].time); + srv_push_dos_date2(req->smb, req->out.ptr, 0 , lpq->retq.out.queue[i].time); SCVAL(req->out.ptr, 4, lpq->retq.out.queue[i].status); SSVAL(req->out.ptr, 5, lpq->retq.out.queue[i].job); SIVAL(req->out.ptr, 7, lpq->retq.out.queue[i].size); @@ -1851,9 +1830,9 @@ void reply_setattrE(struct request_context *req) info->setattre.level = RAW_SFILEINFO_SETATTRE; info->setattre.file.fnum = req_fnum(req, req->in.vwv, VWV(0)); - info->setattre.in.create_time = make_unix_date2(req->in.vwv + VWV(1)); - info->setattre.in.access_time = make_unix_date2(req->in.vwv + VWV(3)); - info->setattre.in.write_time = make_unix_date2(req->in.vwv + VWV(5)); + info->setattre.in.create_time = srv_pull_dos_date2(req->smb, req->in.vwv + VWV(1)); + info->setattre.in.access_time = srv_pull_dos_date2(req->smb, req->in.vwv + VWV(3)); + info->setattre.in.write_time = srv_pull_dos_date2(req->smb, req->in.vwv + VWV(5)); req->async.send_fn = reply_simple_send; @@ -1897,9 +1876,9 @@ static void reply_getattrE_send(struct request_context *req) /* setup reply */ req_setup_reply(req, 11, 0); - put_dos_date2(req->out.vwv, VWV(0), info->getattre.out.create_time); - put_dos_date2(req->out.vwv, VWV(2), info->getattre.out.access_time); - put_dos_date2(req->out.vwv, VWV(4), info->getattre.out.write_time); + srv_push_dos_date2(req->smb, req->out.vwv, VWV(0), info->getattre.out.create_time); + srv_push_dos_date2(req->smb, req->out.vwv, VWV(2), info->getattre.out.access_time); + srv_push_dos_date2(req->smb, req->out.vwv, VWV(4), info->getattre.out.write_time); SIVAL(req->out.vwv, VWV(6), info->getattre.out.size); SIVAL(req->out.vwv, VWV(8), info->getattre.out.alloc_size); SSVAL(req->out.vwv, VWV(10), info->getattre.out.attrib); diff --git a/source4/smb_server/search.c b/source4/smb_server/search.c index 9d01a0e98f..0a6aaa6c25 100644 --- a/source4/smb_server/search.c +++ b/source4/smb_server/search.c @@ -78,7 +78,7 @@ static void find_fill_info(struct request_context *req, p += req_append_bytes(req, file->search.search_id.data, 21); p += req_append_bytes(req, (char*)&file->search.attrib, 1); - put_dos_date((char*)&dos_date, 0, file->search.write_time); + srv_push_dos_date3(req->smb, (uint8 *)&dos_date, 0, file->search.write_time); p += req_append_bytes(req, (char*)&dos_date, 4); p += req_append_bytes(req, (char*)&file->search.size, 4); memset(&search_name[0], ' ', 13); diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index f798accc3f..84209d8670 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -749,6 +749,8 @@ void init_smbsession(struct event_context *ev, struct model_ops *model_ops, int good performance */ smb->negotiate.max_recv = lp_max_xmit(); + smb->negotiate.zone_offset = get_time_zone(time(NULL)); + smb->users.next_vuid = VUID_OFFSET; smb->events = ev; diff --git a/source4/smb_server/srvtime.c b/source4/smb_server/srvtime.c new file mode 100644 index 0000000000..c6a0606e89 --- /dev/null +++ b/source4/smb_server/srvtime.c @@ -0,0 +1,81 @@ +/* + Unix SMB/CIFS implementation. + + server side time handling + + 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 srv_push_dos_date(struct server_context *smb_server, + uint8 *buf, int offset, time_t unixdate) +{ + push_dos_date(buf, offset, unixdate, smb_server->negotiate.zone_offset); +} + +/******************************************************************* +put a dos date into a buffer (date/time format) +This takes GMT time and puts local time in the buffer +********************************************************************/ +void srv_push_dos_date2(struct server_context *smb_server, + char *buf, int offset, time_t unixdate) +{ + push_dos_date2(buf, offset, unixdate, smb_server->negotiate.zone_offset); +} + +/******************************************************************* +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 srv_push_dos_date3(struct server_context *smb_server, + char *buf, int offset, time_t unixdate) +{ + push_dos_date3(buf, offset, unixdate, smb_server->negotiate.zone_offset); +} + +/******************************************************************* +convert a dos date +********************************************************************/ +time_t srv_pull_dos_date(struct server_context *smb_server, + const uint8 *date_ptr) +{ + return pull_dos_date(date_ptr, smb_server->negotiate.zone_offset); +} + +/******************************************************************* +like srv_pull_dos_date() but the words are reversed +********************************************************************/ +time_t srv_pull_dos_date2(struct server_context *smb_server, + const uint8 *date_ptr) +{ + return pull_dos_date2(date_ptr, smb_server->negotiate.zone_offset); +} + +/******************************************************************* + 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 srv_pull_dos_date3(struct server_context *smb_server, + const uint8 *date_ptr) +{ + return pull_dos_date3(date_ptr, smb_server->negotiate.zone_offset); +} diff --git a/source4/smb_server/trans2.c b/source4/smb_server/trans2.c index bc51191aa6..a412d9df3a 100644 --- a/source4/smb_server/trans2.c +++ b/source4/smb_server/trans2.c @@ -420,9 +420,9 @@ static NTSTATUS trans2_fileinfo_fill(struct request_context *req, struct smb_tra trans2_setup_reply(req, trans, 2, 22, 0); SSVAL(trans->out.params.data, 0, 0); - put_dos_date2(trans->out.data.data, 0, st->standard.out.create_time); - put_dos_date2(trans->out.data.data, 4, st->standard.out.access_time); - put_dos_date2(trans->out.data.data, 8, st->standard.out.write_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 0, st->standard.out.create_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 4, st->standard.out.access_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 8, st->standard.out.write_time); SIVAL(trans->out.data.data, 12, st->standard.out.size); SIVAL(trans->out.data.data, 16, st->standard.out.alloc_size); SSVAL(trans->out.data.data, 20, st->standard.out.attrib); @@ -432,9 +432,9 @@ static NTSTATUS trans2_fileinfo_fill(struct request_context *req, struct smb_tra trans2_setup_reply(req, trans, 2, 26, 0); SSVAL(trans->out.params.data, 0, 0); - put_dos_date2(trans->out.data.data, 0, st->ea_size.out.create_time); - put_dos_date2(trans->out.data.data, 4, st->ea_size.out.access_time); - put_dos_date2(trans->out.data.data, 8, st->ea_size.out.write_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 0, st->ea_size.out.create_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 4, st->ea_size.out.access_time); + srv_push_dos_date2(req->smb, trans->out.data.data, 8, st->ea_size.out.write_time); SIVAL(trans->out.data.data, 12, st->ea_size.out.size); SIVAL(trans->out.data.data, 16, st->ea_size.out.alloc_size); SSVAL(trans->out.data.data, 20, st->ea_size.out.attrib); @@ -705,9 +705,9 @@ static NTSTATUS trans2_parse_sfileinfo(struct request_context *req, case RAW_SFILEINFO_STANDARD: CHECK_MIN_BLOB_SIZE(blob, 12); - st->standard.in.create_time = make_unix_date2(blob->data + 0); - st->standard.in.access_time = make_unix_date2(blob->data + 4); - st->standard.in.write_time = make_unix_date2(blob->data + 8); + st->standard.in.create_time = pull_dos_date2(req->smb, blob->data + 0); + st->standard.in.access_time = pull_dos_date2(req->smb, blob->data + 4); + st->standard.in.write_time = pull_dos_date2(req->smb, blob->data + 8); return NT_STATUS_OK; case RAW_SFILEINFO_EA_SET: @@ -896,9 +896,9 @@ static void find_fill_info(struct request_context *req, trans2_grow_data(req, trans, ofs + 23); } data = trans->out.data.data + ofs; - put_dos_date2(data, 0, file->standard.create_time); - put_dos_date2(data, 4, file->standard.access_time); - put_dos_date2(data, 8, file->standard.write_time); + srv_push_dos_date2(req->smb, data, 0, file->standard.create_time); + srv_push_dos_date2(req->smb, data, 4, file->standard.access_time); + srv_push_dos_date2(req->smb, data, 8, file->standard.write_time); SIVAL(data, 12, file->standard.size); SIVAL(data, 16, file->standard.alloc_size); SSVAL(data, 20, file->standard.attrib); @@ -915,9 +915,9 @@ static void find_fill_info(struct request_context *req, trans2_grow_data(req, trans, ofs + 27); } data = trans->out.data.data + ofs; - put_dos_date2(data, 0, file->ea_size.create_time); - put_dos_date2(data, 4, file->ea_size.access_time); - put_dos_date2(data, 8, file->ea_size.write_time); + srv_push_dos_date2(req->smb, data, 0, file->ea_size.create_time); + srv_push_dos_date2(req->smb, data, 4, file->ea_size.access_time); + srv_push_dos_date2(req->smb, data, 8, file->ea_size.write_time); SIVAL(data, 12, file->ea_size.size); SIVAL(data, 16, file->ea_size.alloc_size); SSVAL(data, 20, file->ea_size.attrib); |