From 1b2e8caad3fb01ea3b61bda63965d324de61c815 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 13:08:31 +0000 Subject: r11680: added smb2_close(). This also demonstrates that file handles are 16 bytes, not 20 bytes (metze, you were right!) (This used to be commit d3bcc6628cde9ddedf0fd408cbee573f133ce582) --- source4/libcli/smb2/close.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 source4/libcli/smb2/close.c (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c new file mode 100644 index 0000000000..87220a4200 --- /dev/null +++ b/source4/libcli/smb2/close.c @@ -0,0 +1,85 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client tree handling + + Copyright (C) Andrew Tridgell 2005 + + 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" +#include "libcli/raw/libcliraw.h" +#include "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" + +/* + send a close request +*/ +struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close *io) +{ + struct smb2_request *req; + + req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18); + if (req == NULL) return NULL; + + SIVAL(req->out.body, 0x00, io->in.unknown1); + SIVAL(req->out.body, 0x04, io->in.unknown2); + SBVAL(req->out.body, 0x08, io->in.handle.data[0]); + SBVAL(req->out.body, 0x10, io->in.handle.data[1]); + + smb2_transport_send(req); + + return req; +} + + +/* + recv a close reply +*/ +NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) +{ + if (!smb2_request_receive(req) || + smb2_request_is_error(req)) { + return smb2_request_destroy(req); + } + + if (req->in.body_size < 0x3C) { + return NT_STATUS_BUFFER_TOO_SMALL; + } + + io->out.unknown1 = IVAL(req->in.body, 0x00); + io->out.unknown2 = IVAL(req->in.body, 0x04); + io->out.create_time = smbcli_pull_nttime(req->in.body, 0x08); + io->out.access_time = smbcli_pull_nttime(req->in.body, 0x10); + io->out.write_time = smbcli_pull_nttime(req->in.body, 0x18); + io->out.change_time = smbcli_pull_nttime(req->in.body, 0x20); + io->out.unknown3 = IVAL(req->in.body, 0x24); + io->out.unknown4 = IVAL(req->in.body, 0x28); + io->out.unknown5 = IVAL(req->in.body, 0x2C); + io->out.unknown6 = IVAL(req->in.body, 0x30); + io->out.unknown7 = IVAL(req->in.body, 0x34); + + return smb2_request_destroy(req); +} + +/* + sync close request +*/ +NTSTATUS smb2_close(struct smb2_tree *tree, struct smb2_close *io) +{ + struct smb2_request *req = smb2_close_send(tree, io); + return smb2_close_recv(req, io); +} -- cgit From 222e197b848e2f1e58602d1e709f057a1f8833fd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 21:22:15 +0000 Subject: r11687: filled in 3 more fields in the close reply (This used to be commit 3a0abb3ff0b532179780ed95f8fcb4bca6e040b1) --- source4/libcli/smb2/close.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 87220a4200..4429cd557b 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -66,11 +66,9 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) io->out.access_time = smbcli_pull_nttime(req->in.body, 0x10); io->out.write_time = smbcli_pull_nttime(req->in.body, 0x18); io->out.change_time = smbcli_pull_nttime(req->in.body, 0x20); - io->out.unknown3 = IVAL(req->in.body, 0x24); - io->out.unknown4 = IVAL(req->in.body, 0x28); - io->out.unknown5 = IVAL(req->in.body, 0x2C); - io->out.unknown6 = IVAL(req->in.body, 0x30); - io->out.unknown7 = IVAL(req->in.body, 0x34); + io->out.alloc_size = BVAL(req->in.body, 0x28); + io->out.size = BVAL(req->in.body, 0x30); + io->out.file_attr = IVAL(req->in.body, 0x38); return smb2_request_destroy(req); } -- cgit From 91e1893741741de04b73a098495c697434105803 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 23:27:47 +0000 Subject: r11691: added reply buffer code checks and oplock flags for create request/reply (This used to be commit 26ed781375c03958241d8c93324e04e948944d01) --- source4/libcli/smb2/close.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 4429cd557b..b60c1b3071 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -35,8 +35,9 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18); if (req == NULL) return NULL; - SIVAL(req->out.body, 0x00, io->in.unknown1); - SIVAL(req->out.body, 0x04, io->in.unknown2); + SSVAL(req->out.body, 0x00, io->in.buffer_code); + SSVAL(req->out.body, 0x02, io->in.flags); + SIVAL(req->out.body, 0x04, io->in._pad); SBVAL(req->out.body, 0x08, io->in.handle.data[0]); SBVAL(req->out.body, 0x10, io->in.handle.data[1]); @@ -60,8 +61,9 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) return NT_STATUS_BUFFER_TOO_SMALL; } - io->out.unknown1 = IVAL(req->in.body, 0x00); - io->out.unknown2 = IVAL(req->in.body, 0x04); + io->out.buffer_code = SVAL(req->in.body, 0x00); + io->out.flags = SVAL(req->in.body, 0x02); + io->out._pad = IVAL(req->in.body, 0x04); io->out.create_time = smbcli_pull_nttime(req->in.body, 0x08); io->out.access_time = smbcli_pull_nttime(req->in.body, 0x10); io->out.write_time = smbcli_pull_nttime(req->in.body, 0x18); -- cgit From 67a85b3f1bca7e0590ae97d07a6ef32c418e64d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Nov 2005 07:48:56 +0000 Subject: r11697: - added a generic SMB2 getinfo call - added a SMB2-SCANGETINFO test for scanning for available info levels - added names for the info levels I recognise to smb2.h (This used to be commit fe5986067e2aaca039d70393ccc8761434f18fe6) --- source4/libcli/smb2/close.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index b60c1b3071..2802e2f27e 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - SMB2 client tree handling + SMB2 client close handling Copyright (C) Andrew Tridgell 2005 @@ -61,7 +61,8 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) return NT_STATUS_BUFFER_TOO_SMALL; } - io->out.buffer_code = SVAL(req->in.body, 0x00); + SMB2_CHECK_BUFFER_CODE(req, 0x3C); + io->out.flags = SVAL(req->in.body, 0x02); io->out._pad = IVAL(req->in.body, 0x04); io->out.create_time = smbcli_pull_nttime(req->in.body, 0x08); -- cgit From c6395a30b057c87de8ce410d5ea5ebe2e017093d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 Nov 2005 05:09:26 +0000 Subject: r11715: added SMB2 read and write requests (This used to be commit d3556cbfa38447d2d385b697c1855b3c13d42744) --- source4/libcli/smb2/close.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 2802e2f27e..d5a2c4d422 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -38,8 +38,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * SSVAL(req->out.body, 0x00, io->in.buffer_code); SSVAL(req->out.body, 0x02, io->in.flags); SIVAL(req->out.body, 0x04, io->in._pad); - SBVAL(req->out.body, 0x08, io->in.handle.data[0]); - SBVAL(req->out.body, 0x10, io->in.handle.data[1]); + smb2_put_handle(req->out.body+0x08, io->in.handle); smb2_transport_send(req); -- cgit From 61317df8aab2fe2fd47baba8a137566df7b23395 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Nov 2005 07:06:16 +0000 Subject: r11721: Fix warnings (This used to be commit d760583e388157ff25e317da06c57e5a42f171bd) --- source4/libcli/smb2/close.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index d5a2c4d422..cf1cdbef5f 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -38,7 +38,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * SSVAL(req->out.body, 0x00, io->in.buffer_code); SSVAL(req->out.body, 0x02, io->in.flags); SIVAL(req->out.body, 0x04, io->in._pad); - smb2_put_handle(req->out.body+0x08, io->in.handle); + smb2_put_handle(req->out.body+0x08, &io->in.handle); smb2_transport_send(req); -- cgit From e9eb56068573d89f8ce45f08220ca870b3daa669 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Nov 2005 11:01:15 +0000 Subject: r11741: - the buffer code (first 2 bytes in the SMB2 body) seem to be the length of the fixed body part, and +1 if there's a dynamic part - there're 3 types of dynamic blobs with uint16_t offset/uint16_t size with uint16_t offset/uint32_t size with uint32_t offset/uint32_t size /* aligned to 8 bytes */ - strings are transmitted in UTF-16 with no termination and packet into a uint16/uint16 blob metze (This used to be commit 79103c51e5c752fbdb4d25a0047b65002828df89) --- source4/libcli/smb2/close.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index cf1cdbef5f..c851d60be4 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -32,13 +32,12 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18); + req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, 0); if (req == NULL) return NULL; - SSVAL(req->out.body, 0x00, io->in.buffer_code); SSVAL(req->out.body, 0x02, io->in.flags); SIVAL(req->out.body, 0x04, io->in._pad); - smb2_put_handle(req->out.body+0x08, &io->in.handle); + smb2_push_handle(req->out.body+0x08, &io->in.handle); smb2_transport_send(req); @@ -56,11 +55,7 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) return smb2_request_destroy(req); } - if (req->in.body_size < 0x3C) { - return NT_STATUS_BUFFER_TOO_SMALL; - } - - SMB2_CHECK_BUFFER_CODE(req, 0x3C); + SMB2_CHECK_PACKET_RECV(req, 0x3C, False); io->out.flags = SVAL(req->in.body, 0x02); io->out._pad = IVAL(req->in.body, 0x04); -- cgit From fd7fd22e462ef6cf46e3f63e12ffcd684ea20244 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 2 Dec 2005 03:17:40 +0000 Subject: r12006: don't require callers to fill in pad bytes in SMB2 calls (This used to be commit 6935765fda99a6efb19f6f72358d4d48fc35ad5e) --- source4/libcli/smb2/close.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index c851d60be4..3e559fe893 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -36,7 +36,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.flags); - SIVAL(req->out.body, 0x04, io->in._pad); + SIVAL(req->out.body, 0x04, 0); /* pad */ smb2_push_handle(req->out.body+0x08, &io->in.handle); smb2_transport_send(req); -- cgit From dc86ab3e454d7219608d01879145dec5609acaa3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 May 2006 10:47:37 +0000 Subject: r15532: add a BOOL body_dynamic_present, because the body_dynamic_size can be 0 also if the dynamic flag should be set metze (This used to be commit 7829100e1ee79f4f5d24004af221288e19c09b3e) --- source4/libcli/smb2/close.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 3e559fe893..4483f3c75b 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -32,7 +32,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, 0); + req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.flags); -- cgit From e306c5bf129a981693bd251d45597f1e584ee850 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 10:46:38 +0000 Subject: r15741: move smb2 request structures into the main smb request structs as new levels metze (This used to be commit 91806353174704857dfcc15a730af7232cfde660) --- source4/libcli/smb2/close.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 4483f3c75b..9156e7d10d 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -37,7 +37,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * SSVAL(req->out.body, 0x02, io->in.flags); SIVAL(req->out.body, 0x04, 0); /* pad */ - smb2_push_handle(req->out.body+0x08, &io->in.handle); + smb2_push_handle(req->out.body+0x08, &io->in.file.handle); smb2_transport_send(req); -- cgit From bd1efc1235b647f6845fb7d6218cf2b4068e9f0a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Jun 2006 11:08:27 +0000 Subject: r16669: this calls don't expect any valid error codes than NT_STATUS_OK metze (This used to be commit 429215113bd999466141df0a2e3b3097d677df1f) --- source4/libcli/smb2/close.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 9156e7d10d..1e2ef3afb1 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -51,7 +51,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) { if (!smb2_request_receive(req) || - smb2_request_is_error(req)) { + !smb2_request_is_ok(req)) { return smb2_request_destroy(req); } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/smb2/close.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 1e2ef3afb1..e83f81b630 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -7,7 +7,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ 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. + along with this program. If not, see . */ #include "includes.h" -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/smb2/close.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index e83f81b630..04c0c85499 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -31,7 +31,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close * { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0); + req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, false, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.flags); @@ -54,7 +54,7 @@ NTSTATUS smb2_close_recv(struct smb2_request *req, struct smb2_close *io) return smb2_request_destroy(req); } - SMB2_CHECK_PACKET_RECV(req, 0x3C, False); + SMB2_CHECK_PACKET_RECV(req, 0x3C, false); io->out.flags = SVAL(req->in.body, 0x02); io->out._pad = IVAL(req->in.body, 0x04); -- cgit From afe3e8172ddaa5e4aa811faceecda4f943d6e2ef Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 2 Apr 2008 04:53:27 +0200 Subject: Install public header files again and include required prototypes. (This used to be commit 47ffbbf67435904754469544390b67d34c958343) --- source4/libcli/smb2/close.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/close.c') diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c index 04c0c85499..4e6f33095f 100644 --- a/source4/libcli/smb2/close.c +++ b/source4/libcli/smb2/close.c @@ -21,6 +21,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" -- cgit