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/getinfo.c | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 source4/libcli/smb2/getinfo.c (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c new file mode 100644 index 0000000000..c8976e4230 --- /dev/null +++ b/source4/libcli/smb2/getinfo.c @@ -0,0 +1,90 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client getinfo calls + + 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 getinfo request +*/ +struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getinfo *io) +{ + struct smb2_request *req; + + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28); + if (req == NULL) return NULL; + + SSVAL(req->out.body, 0x00, io->in.buffer_code); + SSVAL(req->out.body, 0x02, io->in.level); + SIVAL(req->out.body, 0x04, io->in.max_response_size); + SIVAL(req->out.body, 0x08, io->in.unknown1); + SIVAL(req->out.body, 0x0C, io->in.unknown2); + SIVAL(req->out.body, 0x10, io->in.unknown3); + SIVAL(req->out.body, 0x14, io->in.unknown4); + SBVAL(req->out.body, 0x18, io->in.handle.data[0]); + SBVAL(req->out.body, 0x20, io->in.handle.data[1]); + + smb2_transport_send(req); + + return req; +} + + +/* + recv a getinfo reply +*/ +NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, + struct smb2_getinfo *io) +{ + NTSTATUS status; + + if (!smb2_request_receive(req) || + smb2_request_is_error(req)) { + return smb2_request_destroy(req); + } + + if (req->in.body_size < 0x08) { + return NT_STATUS_BUFFER_TOO_SMALL; + } + + SMB2_CHECK_BUFFER_CODE(req, 0x09); + + status = smb2_pull_ofs_blob(req, req->in.body+0x02, &io->out.blob); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + talloc_steal(mem_ctx, io->out.blob.data); + + return smb2_request_destroy(req); +} + +/* + sync getinfo request +*/ +NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, + struct smb2_getinfo *io) +{ + struct smb2_request *req = smb2_getinfo_send(tree, io); + return smb2_getinfo_recv(req, mem_ctx, io); +} -- 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/getinfo.c | 149 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index c8976e4230..a7935526e5 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -39,11 +39,10 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin SSVAL(req->out.body, 0x02, io->in.level); SIVAL(req->out.body, 0x04, io->in.max_response_size); SIVAL(req->out.body, 0x08, io->in.unknown1); - SIVAL(req->out.body, 0x0C, io->in.unknown2); + SIVAL(req->out.body, 0x0C, io->in.flags); SIVAL(req->out.body, 0x10, io->in.unknown3); SIVAL(req->out.body, 0x14, io->in.unknown4); - SBVAL(req->out.body, 0x18, io->in.handle.data[0]); - SBVAL(req->out.body, 0x20, io->in.handle.data[1]); + smb2_put_handle(req->out.body+0x18, io->in.handle); smb2_transport_send(req); @@ -88,3 +87,147 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, struct smb2_request *req = smb2_getinfo_send(tree, io); return smb2_getinfo_recv(req, mem_ctx, io); } + + +/* + parse a returned getinfo data blob +*/ +NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, + uint16_t level, + DATA_BLOB blob, + union smb2_fileinfo *io) +{ + switch (level) { + case SMB2_GETINFO_FILE_BASIC_INFO: + if (blob.length != 0x28) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->basic_info.create_time = smbcli_pull_nttime(blob.data, 0x00); + io->basic_info.access_time = smbcli_pull_nttime(blob.data, 0x08); + io->basic_info.write_time = smbcli_pull_nttime(blob.data, 0x10); + io->basic_info.change_time = smbcli_pull_nttime(blob.data, 0x18); + io->basic_info.file_attr = IVAL(blob.data, 0x20); + io->basic_info.unknown = IVAL(blob.data, 0x24); + break; + + case SMB2_GETINFO_FILE_SIZE_INFO: + if (blob.length != 0x18) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->size_info.alloc_size = BVAL(blob.data, 0x00); + io->size_info.size = BVAL(blob.data, 0x08); + io->size_info.nlink = IVAL(blob.data, 0x10); + io->size_info.unknown = IVAL(blob.data, 0x14); + break; + + case SMB2_GETINFO_FILE_06: + if (blob.length != 0x8) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->unknown06.unknown1 = IVAL(blob.data, 0x00); + io->unknown06.unknown2 = IVAL(blob.data, 0x04); + break; + + case SMB2_GETINFO_FILE_EA_SIZE: + if (blob.length != 0x4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->ea_size.ea_size = IVAL(blob.data, 0x00); + break; + + case SMB2_GETINFO_FILE_ACCESS_INFO: + if (blob.length != 0x4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->access_info.access_mask = IVAL(blob.data, 0x00); + break; + + case SMB2_GETINFO_FILE_0E: + if (blob.length != 0x8) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->unknown0e.unknown1 = IVAL(blob.data, 0x00); + io->unknown0e.unknown2 = IVAL(blob.data, 0x04); + break; + + case SMB2_GETINFO_FILE_ALL_EAS: + return ea_pull_list(&blob, mem_ctx, + &io->all_eas.eas.num_eas, + &io->all_eas.eas.eas); + + case SMB2_GETINFO_FILE_10: + if (blob.length != 0x4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->unknown10.unknown = IVAL(blob.data, 0x00); + break; + + case SMB2_GETINFO_FILE_11: + if (blob.length != 0x4) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->unknown11.unknown = IVAL(blob.data, 0x00); + break; + + case SMB2_GETINFO_FILE_ALL_INFO: { + uint32_t nlen; + ssize_t size; + void *vstr; + if (blob.length != 0x60) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->all_info.create_time = smbcli_pull_nttime(blob.data, 0x00); + io->all_info.access_time = smbcli_pull_nttime(blob.data, 0x08); + io->all_info.write_time = smbcli_pull_nttime(blob.data, 0x10); + io->all_info.change_time = smbcli_pull_nttime(blob.data, 0x18); + io->all_info.file_attr = IVAL(blob.data, 0x20); + io->all_info.unknown1 = IVAL(blob.data, 0x24); + io->all_info.alloc_size = BVAL(blob.data, 0x28); + io->all_info.size = BVAL(blob.data, 0x30); + io->all_info.nlink = IVAL(blob.data, 0x38); + io->all_info.unknown2 = IVAL(blob.data, 0x3C); + io->all_info.unknown3 = IVAL(blob.data, 0x40); + io->all_info.unknown4 = IVAL(blob.data, 0x44); + io->all_info.ea_size = IVAL(blob.data, 0x48); + io->all_info.access_mask = IVAL(blob.data, 0x4C); + io->all_info.unknown5 = BVAL(blob.data, 0x50); + io->all_info.unknown6 = BVAL(blob.data, 0x58); + nlen = IVAL(blob.data, 0x5C); + if (nlen > blob.length - 0x60) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + blob.data+0x60, nlen, &vstr); + if (size == -1) { + return NT_STATUS_ILLEGAL_CHARACTER; + } + io->all_info.fname = vstr; + break; + } + + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + return NT_STATUS_OK; +} + + +/* + recv a getinfo reply and parse the level info +*/ +NTSTATUS smb2_getinfo_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, + uint16_t level, union smb2_fileinfo *io) +{ + struct smb2_getinfo b; + NTSTATUS status; + + status = smb2_getinfo_recv(req, mem_ctx, &b); + NT_STATUS_NOT_OK_RETURN(status); + + status = smb2_getinfo_parse(mem_ctx, level, b.out.blob, io); + data_blob_free(&b.out.blob); + + return status; +} + -- 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/getinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index a7935526e5..ffc2a92daf 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -42,7 +42,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin SIVAL(req->out.body, 0x0C, io->in.flags); SIVAL(req->out.body, 0x10, io->in.unknown3); SIVAL(req->out.body, 0x14, io->in.unknown4); - smb2_put_handle(req->out.body+0x18, io->in.handle); + smb2_put_handle(req->out.body+0x18, &io->in.handle); smb2_transport_send(req); -- cgit From de5d71aebe4e415fcebbfacb852b190498cbf7bf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 14 Nov 2005 12:31:02 +0000 Subject: r11722: make the smb2_push/pull functions take a smb2_request_buffer and the pull ones also a TALLOC_CTX, then we can reuse this functions in the server later metze (This used to be commit 9b616516cae269f0870e9b9a9cecd8ee3f0a9095) --- source4/libcli/smb2/getinfo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index ffc2a92daf..9ad2b77310 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -69,11 +69,10 @@ NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, SMB2_CHECK_BUFFER_CODE(req, 0x09); - status = smb2_pull_ofs_blob(req, req->in.body+0x02, &io->out.blob); + status = smb2_pull_ofs_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob); if (!NT_STATUS_IS_OK(status)) { return status; } - talloc_steal(mem_ctx, io->out.blob.data); return smb2_request_destroy(req); } -- cgit From b51703baf152c309ce325ce573c1683d7e503122 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 Nov 2005 04:38:59 +0000 Subject: r11730: added parsing and tests for a bunch more SMB2 getinfo levels (This used to be commit ca65bf0235cbfab451e5d5ceac9f714acc0cd46c) --- source4/libcli/smb2/getinfo.c | 142 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 27 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 9ad2b77310..7a362b24d9 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -113,18 +113,18 @@ NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, if (blob.length != 0x18) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - io->size_info.alloc_size = BVAL(blob.data, 0x00); - io->size_info.size = BVAL(blob.data, 0x08); - io->size_info.nlink = IVAL(blob.data, 0x10); - io->size_info.unknown = IVAL(blob.data, 0x14); + io->size_info.alloc_size = BVAL(blob.data, 0x00); + io->size_info.size = BVAL(blob.data, 0x08); + io->size_info.nlink = IVAL(blob.data, 0x10); + io->size_info.delete_pending = CVAL(blob.data, 0x14); + io->size_info.directory = CVAL(blob.data, 0x15); break; - case SMB2_GETINFO_FILE_06: + case SMB2_GETINFO_FILE_ID: if (blob.length != 0x8) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - io->unknown06.unknown1 = IVAL(blob.data, 0x00); - io->unknown06.unknown2 = IVAL(blob.data, 0x04); + io->file_id.file_id = BVAL(blob.data, 0x00); break; case SMB2_GETINFO_FILE_EA_SIZE: @@ -172,37 +172,105 @@ NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, uint32_t nlen; ssize_t size; void *vstr; - if (blob.length != 0x60) { + if (blob.length < 0x64) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - io->all_info.create_time = smbcli_pull_nttime(blob.data, 0x00); - io->all_info.access_time = smbcli_pull_nttime(blob.data, 0x08); - io->all_info.write_time = smbcli_pull_nttime(blob.data, 0x10); - io->all_info.change_time = smbcli_pull_nttime(blob.data, 0x18); - io->all_info.file_attr = IVAL(blob.data, 0x20); - io->all_info.unknown1 = IVAL(blob.data, 0x24); - io->all_info.alloc_size = BVAL(blob.data, 0x28); - io->all_info.size = BVAL(blob.data, 0x30); - io->all_info.nlink = IVAL(blob.data, 0x38); - io->all_info.unknown2 = IVAL(blob.data, 0x3C); - io->all_info.unknown3 = IVAL(blob.data, 0x40); - io->all_info.unknown4 = IVAL(blob.data, 0x44); - io->all_info.ea_size = IVAL(blob.data, 0x48); - io->all_info.access_mask = IVAL(blob.data, 0x4C); - io->all_info.unknown5 = BVAL(blob.data, 0x50); - io->all_info.unknown6 = BVAL(blob.data, 0x58); - nlen = IVAL(blob.data, 0x5C); - if (nlen > blob.length - 0x60) { + io->all_info.create_time = smbcli_pull_nttime(blob.data, 0x00); + io->all_info.access_time = smbcli_pull_nttime(blob.data, 0x08); + io->all_info.write_time = smbcli_pull_nttime(blob.data, 0x10); + io->all_info.change_time = smbcli_pull_nttime(blob.data, 0x18); + io->all_info.file_attr = IVAL(blob.data, 0x20); + io->all_info.alloc_size = BVAL(blob.data, 0x28); + io->all_info.size = BVAL(blob.data, 0x30); + io->all_info.nlink = IVAL(blob.data, 0x38); + io->all_info.delete_pending = CVAL(blob.data, 0x3C); + io->all_info.directory = CVAL(blob.data, 0x3D); + io->all_info.file_id = BVAL(blob.data, 0x40); + io->all_info.ea_size = IVAL(blob.data, 0x48); + io->all_info.access_mask = IVAL(blob.data, 0x4C); + io->all_info.unknown5 = BVAL(blob.data, 0x50); + io->all_info.unknown6 = BVAL(blob.data, 0x58); + nlen = IVAL(blob.data, 0x60); + if (nlen > blob.length - 0x64) { return NT_STATUS_INFO_LENGTH_MISMATCH; } size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, - blob.data+0x60, nlen, &vstr); + blob.data+0x64, nlen, &vstr); if (size == -1) { return NT_STATUS_ILLEGAL_CHARACTER; } io->all_info.fname = vstr; break; } + + case SMB2_GETINFO_FILE_SHORT_INFO: { + uint32_t nlen; + ssize_t size; + void *vstr; + if (blob.length < 0x04) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + nlen = IVAL(blob.data, 0x00); + if (nlen > blob.length - 0x04) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + blob.data+0x04, nlen, &vstr); + if (size == -1) { + return NT_STATUS_ILLEGAL_CHARACTER; + } + io->short_info.short_name = vstr; + break; + } + + case SMB2_GETINFO_FILE_STREAM_INFO: + return smbcli_parse_stream_info(blob, mem_ctx, &io->stream_info); + + case SMB2_GETINFO_FILE_EOF_INFO: + if (blob.length != 0x10) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->eof_info.size = BVAL(blob.data, 0x00); + io->eof_info.unknown = BVAL(blob.data, 0x08); + break; + + case SMB2_GETINFO_FILE_STANDARD_INFO: + if (blob.length != 0x38) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->standard_info.create_time = smbcli_pull_nttime(blob.data, 0x00); + io->standard_info.access_time = smbcli_pull_nttime(blob.data, 0x08); + io->standard_info.write_time = smbcli_pull_nttime(blob.data, 0x10); + io->standard_info.change_time = smbcli_pull_nttime(blob.data, 0x18); + io->standard_info.alloc_size = BVAL(blob.data, 0x20); + io->standard_info.size = BVAL(blob.data, 0x28); + io->standard_info.file_attr = IVAL(blob.data, 0x30); + io->standard_info.unknown = IVAL(blob.data, 0x34); + break; + + case SMB2_GETINFO_FILE_ATTRIB_INFO: + if (blob.length != 0x08) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + io->standard_info.file_attr = IVAL(blob.data, 0x00); + io->standard_info.unknown = IVAL(blob.data, 0x04); + break; + + case SMB2_GETINFO_SECURITY: { + struct ndr_pull *ndr; + NTSTATUS status; + ndr = ndr_pull_init_blob(&blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + io->security.sd = talloc(mem_ctx, struct security_descriptor); + if (io->security.sd == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, io->security.sd); + talloc_free(ndr); + return status; + } default: return NT_STATUS_INVALID_INFO_CLASS; @@ -230,3 +298,23 @@ NTSTATUS smb2_getinfo_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, return status; } +/* + level specific getinfo call +*/ +NTSTATUS smb2_getinfo_level(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, + struct smb2_handle handle, + uint16_t level, union smb2_fileinfo *io) +{ + struct smb2_getinfo b; + struct smb2_request *req; + + ZERO_STRUCT(b); + b.in.buffer_code = 0x29; + b.in.max_response_size = 0x10000; + b.in.handle = handle; + b.in.level = level; + + req = smb2_getinfo_send(tree, &b); + + return smb2_getinfo_level_recv(req, mem_ctx, level, io); +} -- cgit From 8dc40d68030396dd22844ff68b260645526e68f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 Nov 2005 05:28:30 +0000 Subject: r11731: fixed typo noticed by metze (This used to be commit e51fb2b44ad524620451807cccb186dd4be704c7) --- source4/libcli/smb2/getinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 7a362b24d9..9599a6c48c 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -252,8 +252,8 @@ NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, if (blob.length != 0x08) { return NT_STATUS_INFO_LENGTH_MISMATCH; } - io->standard_info.file_attr = IVAL(blob.data, 0x00); - io->standard_info.unknown = IVAL(blob.data, 0x04); + io->attrib_info.file_attr = IVAL(blob.data, 0x00); + io->attrib_info.unknown = IVAL(blob.data, 0x04); break; case SMB2_GETINFO_SECURITY: { -- cgit From ab0d0f0623eed2990924580d73c05d6f0b6c8178 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Nov 2005 04:35:10 +0000 Subject: r11735: fixed the ALL_EAS smb2 level parsing (This used to be commit dd24c0e80cf07bda700a0abb84a7a053d817f903) --- source4/libcli/smb2/getinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 9599a6c48c..4817f09d68 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -150,9 +150,9 @@ NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, break; case SMB2_GETINFO_FILE_ALL_EAS: - return ea_pull_list(&blob, mem_ctx, - &io->all_eas.eas.num_eas, - &io->all_eas.eas.eas); + return ea_pull_list_chained(&blob, mem_ctx, + &io->all_eas.num_eas, + &io->all_eas.eas); case SMB2_GETINFO_FILE_10: if (blob.length != 0x4) { -- 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/getinfo.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 4817f09d68..1594b8c1b4 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -32,17 +32,19 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28); + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, 0); if (req == NULL) return NULL; - SSVAL(req->out.body, 0x00, io->in.buffer_code); + /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */ + SSVAL(req->out.body, 0x00, 0x29); + SSVAL(req->out.body, 0x02, io->in.level); SIVAL(req->out.body, 0x04, io->in.max_response_size); SIVAL(req->out.body, 0x08, io->in.unknown1); SIVAL(req->out.body, 0x0C, io->in.flags); SIVAL(req->out.body, 0x10, io->in.unknown3); SIVAL(req->out.body, 0x14, io->in.unknown4); - smb2_put_handle(req->out.body+0x18, &io->in.handle); + smb2_push_handle(req->out.body+0x18, &io->in.handle); smb2_transport_send(req); @@ -63,13 +65,9 @@ NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, return smb2_request_destroy(req); } - if (req->in.body_size < 0x08) { - return NT_STATUS_BUFFER_TOO_SMALL; - } - - SMB2_CHECK_BUFFER_CODE(req, 0x09); + SMB2_CHECK_PACKET_RECV(req, 0x08, True); - status = smb2_pull_ofs_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob); + status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -309,7 +307,6 @@ NTSTATUS smb2_getinfo_level(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, struct smb2_request *req; ZERO_STRUCT(b); - b.in.buffer_code = 0x29; b.in.max_response_size = 0x10000; b.in.handle = handle; b.in.level = level; -- cgit From 7a43b32c3b6aeae3572c810fef243d883fe74f28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Nov 2005 04:03:31 +0000 Subject: r11755: added names for all of the SMB2 qfs info levels (they all map exactly to equivalent SMB qfs levels) (This used to be commit 4ce48d02aa12d6fa699bf8b250b14851870f0096) --- source4/libcli/smb2/getinfo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 1594b8c1b4..fe27cc711b 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -178,6 +178,7 @@ NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, io->all_info.write_time = smbcli_pull_nttime(blob.data, 0x10); io->all_info.change_time = smbcli_pull_nttime(blob.data, 0x18); io->all_info.file_attr = IVAL(blob.data, 0x20); + io->all_info.unknown1 = IVAL(blob.data, 0x24); io->all_info.alloc_size = BVAL(blob.data, 0x28); io->all_info.size = BVAL(blob.data, 0x30); io->all_info.nlink = IVAL(blob.data, 0x38); -- cgit From eedb92ce724e505f94ed49f9b238be617c52ccb4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Nov 2005 11:06:13 +0000 Subject: r11758: unified the parse code for the SMB and SMB2 qfsinfo and qfileinfo calls (This used to be commit ba897e537b9a1544dc214e9d5504c87fee6fced2) --- source4/libcli/smb2/getinfo.c | 257 +++++++++++------------------------------- 1 file changed, 64 insertions(+), 193 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index fe27cc711b..cb8ce76a07 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -41,8 +41,8 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin SSVAL(req->out.body, 0x02, io->in.level); SIVAL(req->out.body, 0x04, io->in.max_response_size); SIVAL(req->out.body, 0x08, io->in.unknown1); - SIVAL(req->out.body, 0x0C, io->in.flags); - SIVAL(req->out.body, 0x10, io->in.unknown3); + SIVAL(req->out.body, 0x0C, io->in.unknown2); + SIVAL(req->out.body, 0x10, io->in.flags); SIVAL(req->out.body, 0x14, io->in.unknown4); smb2_push_handle(req->out.body+0x18, &io->in.handle); @@ -87,203 +87,64 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, /* - parse a returned getinfo data blob + recv a getinfo reply and parse the level info */ -NTSTATUS smb2_getinfo_parse(TALLOC_CTX *mem_ctx, - uint16_t level, - DATA_BLOB blob, - union smb2_fileinfo *io) +NTSTATUS smb2_getinfo_file_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, + union smb_fileinfo *io) { - switch (level) { - case SMB2_GETINFO_FILE_BASIC_INFO: - if (blob.length != 0x28) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->basic_info.create_time = smbcli_pull_nttime(blob.data, 0x00); - io->basic_info.access_time = smbcli_pull_nttime(blob.data, 0x08); - io->basic_info.write_time = smbcli_pull_nttime(blob.data, 0x10); - io->basic_info.change_time = smbcli_pull_nttime(blob.data, 0x18); - io->basic_info.file_attr = IVAL(blob.data, 0x20); - io->basic_info.unknown = IVAL(blob.data, 0x24); - break; - - case SMB2_GETINFO_FILE_SIZE_INFO: - if (blob.length != 0x18) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->size_info.alloc_size = BVAL(blob.data, 0x00); - io->size_info.size = BVAL(blob.data, 0x08); - io->size_info.nlink = IVAL(blob.data, 0x10); - io->size_info.delete_pending = CVAL(blob.data, 0x14); - io->size_info.directory = CVAL(blob.data, 0x15); - break; - - case SMB2_GETINFO_FILE_ID: - if (blob.length != 0x8) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->file_id.file_id = BVAL(blob.data, 0x00); - break; - - case SMB2_GETINFO_FILE_EA_SIZE: - if (blob.length != 0x4) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->ea_size.ea_size = IVAL(blob.data, 0x00); - break; - - case SMB2_GETINFO_FILE_ACCESS_INFO: - if (blob.length != 0x4) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->access_info.access_mask = IVAL(blob.data, 0x00); - break; - - case SMB2_GETINFO_FILE_0E: - if (blob.length != 0x8) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->unknown0e.unknown1 = IVAL(blob.data, 0x00); - io->unknown0e.unknown2 = IVAL(blob.data, 0x04); - break; - - case SMB2_GETINFO_FILE_ALL_EAS: - return ea_pull_list_chained(&blob, mem_ctx, - &io->all_eas.num_eas, - &io->all_eas.eas); - - case SMB2_GETINFO_FILE_10: - if (blob.length != 0x4) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->unknown10.unknown = IVAL(blob.data, 0x00); - break; - - case SMB2_GETINFO_FILE_11: - if (blob.length != 0x4) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->unknown11.unknown = IVAL(blob.data, 0x00); - break; - - case SMB2_GETINFO_FILE_ALL_INFO: { - uint32_t nlen; - ssize_t size; - void *vstr; - if (blob.length < 0x64) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->all_info.create_time = smbcli_pull_nttime(blob.data, 0x00); - io->all_info.access_time = smbcli_pull_nttime(blob.data, 0x08); - io->all_info.write_time = smbcli_pull_nttime(blob.data, 0x10); - io->all_info.change_time = smbcli_pull_nttime(blob.data, 0x18); - io->all_info.file_attr = IVAL(blob.data, 0x20); - io->all_info.unknown1 = IVAL(blob.data, 0x24); - io->all_info.alloc_size = BVAL(blob.data, 0x28); - io->all_info.size = BVAL(blob.data, 0x30); - io->all_info.nlink = IVAL(blob.data, 0x38); - io->all_info.delete_pending = CVAL(blob.data, 0x3C); - io->all_info.directory = CVAL(blob.data, 0x3D); - io->all_info.file_id = BVAL(blob.data, 0x40); - io->all_info.ea_size = IVAL(blob.data, 0x48); - io->all_info.access_mask = IVAL(blob.data, 0x4C); - io->all_info.unknown5 = BVAL(blob.data, 0x50); - io->all_info.unknown6 = BVAL(blob.data, 0x58); - nlen = IVAL(blob.data, 0x60); - if (nlen > blob.length - 0x64) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, - blob.data+0x64, nlen, &vstr); - if (size == -1) { - return NT_STATUS_ILLEGAL_CHARACTER; - } - io->all_info.fname = vstr; - break; - } + struct smb2_getinfo b; + NTSTATUS status; - case SMB2_GETINFO_FILE_SHORT_INFO: { - uint32_t nlen; - ssize_t size; - void *vstr; - if (blob.length < 0x04) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - nlen = IVAL(blob.data, 0x00); - if (nlen > blob.length - 0x04) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, - blob.data+0x04, nlen, &vstr); - if (size == -1) { - return NT_STATUS_ILLEGAL_CHARACTER; - } - io->short_info.short_name = vstr; - break; - } + status = smb2_getinfo_recv(req, mem_ctx, &b); + NT_STATUS_NOT_OK_RETURN(status); - case SMB2_GETINFO_FILE_STREAM_INFO: - return smbcli_parse_stream_info(blob, mem_ctx, &io->stream_info); - - case SMB2_GETINFO_FILE_EOF_INFO: - if (blob.length != 0x10) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->eof_info.size = BVAL(blob.data, 0x00); - io->eof_info.unknown = BVAL(blob.data, 0x08); - break; - - case SMB2_GETINFO_FILE_STANDARD_INFO: - if (blob.length != 0x38) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->standard_info.create_time = smbcli_pull_nttime(blob.data, 0x00); - io->standard_info.access_time = smbcli_pull_nttime(blob.data, 0x08); - io->standard_info.write_time = smbcli_pull_nttime(blob.data, 0x10); - io->standard_info.change_time = smbcli_pull_nttime(blob.data, 0x18); - io->standard_info.alloc_size = BVAL(blob.data, 0x20); - io->standard_info.size = BVAL(blob.data, 0x28); - io->standard_info.file_attr = IVAL(blob.data, 0x30); - io->standard_info.unknown = IVAL(blob.data, 0x34); - break; - - case SMB2_GETINFO_FILE_ATTRIB_INFO: - if (blob.length != 0x08) { - return NT_STATUS_INFO_LENGTH_MISMATCH; - } - io->attrib_info.file_attr = IVAL(blob.data, 0x00); - io->attrib_info.unknown = IVAL(blob.data, 0x04); - break; - - case SMB2_GETINFO_SECURITY: { - struct ndr_pull *ndr; - NTSTATUS status; - ndr = ndr_pull_init_blob(&blob, mem_ctx); - if (!ndr) { - return NT_STATUS_NO_MEMORY; - } - io->security.sd = talloc(mem_ctx, struct security_descriptor); - if (io->security.sd == NULL) { - return NT_STATUS_NO_MEMORY; - } - status = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, io->security.sd); - talloc_free(ndr); - return status; + status = smb_raw_fileinfo_passthru_parse(&b.out.blob, mem_ctx, io->generic.level, io); + data_blob_free(&b.out.blob); + + return status; +} + +/* + level specific getinfo call +*/ +NTSTATUS smb2_getinfo_file(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, + union smb_fileinfo *io) +{ + struct smb2_getinfo b; + struct smb2_request *req; + uint16_t smb2_level; + + if (io->generic.level == RAW_FILEINFO_SEC_DESC) { + smb2_level = SMB2_GETINFO_SECURITY; + } else if ((io->generic.level & 0xFF) == SMB2_GETINFO_FILE) { + smb2_level = io->generic.level; + } else if (io->generic.level > 1000) { + smb2_level = ((io->generic.level-1000)<<8) | SMB2_GETINFO_FILE; + } else { + /* SMB2 only does the passthru levels */ + return NT_STATUS_INVALID_LEVEL; } - - default: - return NT_STATUS_INVALID_INFO_CLASS; + + ZERO_STRUCT(b); + b.in.max_response_size = 0x10000; + b.in.handle = io->generic.in.handle; + b.in.level = smb2_level; + + if (io->generic.level == RAW_FILEINFO_SEC_DESC) { + b.in.flags = io->query_secdesc.secinfo_flags; } - return NT_STATUS_OK; + req = smb2_getinfo_send(tree, &b); + + return smb2_getinfo_file_recv(req, mem_ctx, io); } /* recv a getinfo reply and parse the level info */ -NTSTATUS smb2_getinfo_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, - uint16_t level, union smb2_fileinfo *io) +NTSTATUS smb2_getinfo_fs_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, + union smb_fsinfo *io) { struct smb2_getinfo b; NTSTATUS status; @@ -291,7 +152,7 @@ NTSTATUS smb2_getinfo_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, status = smb2_getinfo_recv(req, mem_ctx, &b); NT_STATUS_NOT_OK_RETURN(status); - status = smb2_getinfo_parse(mem_ctx, level, b.out.blob, io); + status = smb_raw_fsinfo_passthru_parse(b.out.blob, mem_ctx, io->generic.level, io); data_blob_free(&b.out.blob); return status; @@ -300,19 +161,29 @@ NTSTATUS smb2_getinfo_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, /* level specific getinfo call */ -NTSTATUS smb2_getinfo_level(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, - struct smb2_handle handle, - uint16_t level, union smb2_fileinfo *io) +NTSTATUS smb2_getinfo_fs(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, + union smb_fsinfo *io) { struct smb2_getinfo b; struct smb2_request *req; + uint16_t smb2_level; + + if ((io->generic.level & 0xFF) == SMB2_GETINFO_FS) { + smb2_level = io->generic.level; + } else if (io->generic.level > 1000) { + smb2_level = ((io->generic.level-1000)<<8) | SMB2_GETINFO_FS; + } else { + /* SMB2 only does the passthru levels */ + return NT_STATUS_INVALID_LEVEL; + } ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = handle; - b.in.level = level; + b.in.handle = io->generic.handle; + b.in.level = smb2_level; req = smb2_getinfo_send(tree, &b); - return smb2_getinfo_level_recv(req, mem_ctx, level, io); + return smb2_getinfo_fs_recv(req, mem_ctx, io); } + -- cgit From 2ff21db535897eb2a4eae428b7465337bd7cfdd1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 06:28:15 +0000 Subject: r11771: - split out the setinfo blob construction in the libcli/raw code - added a smb2_setinfo call - added smb2_setinfo_file*() calls (This used to be commit da0b6fb93683331134ef2f4abd8707e0c3fc6d9d) --- source4/libcli/smb2/getinfo.c | 98 ++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 42 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index cb8ce76a07..4575ae2a40 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -86,6 +86,44 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, } +/* + map a generic info level to a SMB2 info level +*/ +uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t class) +{ + if ((level & 0xFF) == class) { + return level; + } else if (level > 1000) { + return ((level-1000)<<8) | class; + } + DEBUG(0,("Unable to map SMB2 info level 0x%04x of class %d\n", level, class)); + return 0; +} + +/* + level specific getinfo call - async send +*/ +struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fileinfo *io) +{ + struct smb2_getinfo b; + uint16_t smb2_level = smb2_getinfo_map_level(io->generic.level, SMB2_GETINFO_FILE); + + if (smb2_level == 0) { + return NULL; + } + + ZERO_STRUCT(b); + b.in.max_response_size = 0x10000; + b.in.handle = io->generic.in.handle; + b.in.level = smb2_level; + + if (io->generic.level == RAW_FILEINFO_SEC_DESC) { + b.in.flags = io->query_secdesc.secinfo_flags; + } + + return smb2_getinfo_send(tree, &b); +} + /* recv a getinfo reply and parse the level info */ @@ -110,36 +148,31 @@ NTSTATUS smb2_getinfo_file_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, NTSTATUS smb2_getinfo_file(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, union smb_fileinfo *io) { - struct smb2_getinfo b; - struct smb2_request *req; - uint16_t smb2_level; + struct smb2_request *req = smb2_getinfo_file_send(tree, io); + return smb2_getinfo_file_recv(req, mem_ctx, io); +} - if (io->generic.level == RAW_FILEINFO_SEC_DESC) { - smb2_level = SMB2_GETINFO_SECURITY; - } else if ((io->generic.level & 0xFF) == SMB2_GETINFO_FILE) { - smb2_level = io->generic.level; - } else if (io->generic.level > 1000) { - smb2_level = ((io->generic.level-1000)<<8) | SMB2_GETINFO_FILE; - } else { - /* SMB2 only does the passthru levels */ - return NT_STATUS_INVALID_LEVEL; - } +/* + level specific getinfo call - async send +*/ +struct smb2_request *smb2_getinfo_fs_send(struct smb2_tree *tree, union smb_fsinfo *io) +{ + struct smb2_getinfo b; + uint16_t smb2_level = smb2_getinfo_map_level(io->generic.level, SMB2_GETINFO_FS); + + if (smb2_level == 0) { + return NULL; + } + ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = io->generic.in.handle; + b.in.handle = io->generic.handle; b.in.level = smb2_level; - if (io->generic.level == RAW_FILEINFO_SEC_DESC) { - b.in.flags = io->query_secdesc.secinfo_flags; - } - - req = smb2_getinfo_send(tree, &b); - - return smb2_getinfo_file_recv(req, mem_ctx, io); + return smb2_getinfo_send(tree, &b); } - /* recv a getinfo reply and parse the level info */ @@ -164,26 +197,7 @@ NTSTATUS smb2_getinfo_fs_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, NTSTATUS smb2_getinfo_fs(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, union smb_fsinfo *io) { - struct smb2_getinfo b; - struct smb2_request *req; - uint16_t smb2_level; - - if ((io->generic.level & 0xFF) == SMB2_GETINFO_FS) { - smb2_level = io->generic.level; - } else if (io->generic.level > 1000) { - smb2_level = ((io->generic.level-1000)<<8) | SMB2_GETINFO_FS; - } else { - /* SMB2 only does the passthru levels */ - return NT_STATUS_INVALID_LEVEL; - } - - ZERO_STRUCT(b); - b.in.max_response_size = 0x10000; - b.in.handle = io->generic.handle; - b.in.level = smb2_level; - - req = smb2_getinfo_send(tree, &b); - + struct smb2_request *req = smb2_getinfo_fs_send(tree, io); return smb2_getinfo_fs_recv(req, mem_ctx, io); } -- cgit From 3922b68d13ec79b8ebf55d0624668bf6483930a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 10:07:14 +0000 Subject: r11777: display the security_descriptor in torture_smb2_all_info() (This used to be commit d1067fc25df57b1b6ef59a69f979ed76df5c46cd) --- source4/libcli/smb2/getinfo.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 4575ae2a40..85411fab92 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -91,6 +91,10 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, */ uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t class) { + if (class == SMB2_GETINFO_FILE && + level == RAW_FILEINFO_SEC_DESC) { + return SMB2_GETINFO_SECURITY; + } if ((level & 0xFF) == class) { return level; } else if (level > 1000) { -- cgit From 7d6f36682eab29cb23c40dd915acad61fb5d68cb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 19 Nov 2005 05:55:08 +0000 Subject: r11800: - filled in unknown fields in SMB2 all_info level - allow setting of the ALL_EAS flags bits in SMB2 getinfo (This used to be commit 8c7c54a46dfb91c053d07a5e606892a41213c605) --- source4/libcli/smb2/getinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 85411fab92..62418a05b7 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -43,7 +43,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin SIVAL(req->out.body, 0x08, io->in.unknown1); SIVAL(req->out.body, 0x0C, io->in.unknown2); SIVAL(req->out.body, 0x10, io->in.flags); - SIVAL(req->out.body, 0x14, io->in.unknown4); + SIVAL(req->out.body, 0x14, io->in.flags2); smb2_push_handle(req->out.body+0x18, &io->in.handle); smb2_transport_send(req); @@ -124,6 +124,9 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi if (io->generic.level == RAW_FILEINFO_SEC_DESC) { b.in.flags = io->query_secdesc.secinfo_flags; } + if (io->generic.level == RAW_FILEINFO_SMB2_ALL_EAS) { + b.in.flags2 = io->all_eas.ea_flags; + } return smb2_getinfo_send(tree, &b); } -- cgit From fc04e3e795cebca5723c24e097f5374a23b2247b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 19 Nov 2005 06:39:12 +0000 Subject: r11801: - added basic SMB2 find support - added SMB2-SCANFIND test - cleaned up continue flags in EAs and find requests (This used to be commit 8792bc07d927e6470874230153177748afae3ee8) --- source4/libcli/smb2/getinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 62418a05b7..e406fdf45c 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -125,7 +125,7 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi b.in.flags = io->query_secdesc.secinfo_flags; } if (io->generic.level == RAW_FILEINFO_SMB2_ALL_EAS) { - b.in.flags2 = io->all_eas.ea_flags; + b.in.flags2 = io->all_eas.continue_flags; } return smb2_getinfo_send(tree, &b); -- cgit From 307e43bb5628e8b53a930c2928279af994281ba5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 20:49:20 +0000 Subject: r14173: change smb interface structures to always use a union smb_file, to abtract - const char *path fot qpathinfo and setpathinfo - uint16_t fnum for SMB - smb2_handle handle for SMB2 the idea is to later add a struct ntvfs_handle *ntvfs so that the ntvfs subsystem don't need to know the difference between SMB and SMB2 metze (This used to be commit 2ef3f5970901b5accdb50f0d0115b5d46b0c788f) --- source4/libcli/smb2/getinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index e406fdf45c..3710fdfa08 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -118,14 +118,14 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = io->generic.in.handle; + b.in.handle = io->generic.file.handle; b.in.level = smb2_level; if (io->generic.level == RAW_FILEINFO_SEC_DESC) { - b.in.flags = io->query_secdesc.secinfo_flags; + b.in.flags = io->query_secdesc.in.secinfo_flags; } if (io->generic.level == RAW_FILEINFO_SMB2_ALL_EAS) { - b.in.flags2 = io->all_eas.continue_flags; + b.in.flags2 = io->all_eas.in.continue_flags; } return smb2_getinfo_send(tree, &b); -- cgit From a1b295ed4823ce8d06f830b8db9a5d965c934b54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 22:48:25 +0000 Subject: r14256: - rename smb_file -> smb_handle - move it into the in/out substructs again - allow file.path only on smb_fileinfo/smb_setfileinfo metze (This used to be commit be6d5298a2cdb7e7c61d70471bad445645af5963) --- source4/libcli/smb2/getinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 3710fdfa08..d52ff03922 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -118,7 +118,7 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = io->generic.file.handle; + b.in.handle = io->generic.in.file.handle; b.in.level = smb2_level; if (io->generic.level == RAW_FILEINFO_SEC_DESC) { -- 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/getinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index d52ff03922..57a363b63f 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -32,7 +32,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, 0); + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0); if (req == NULL) return NULL; /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */ -- cgit From d3b3436ce1a71464b0f1a9ffa69643cd5c816004 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Jun 2006 07:03:53 +0000 Subject: r16406: use the generic smb_handle in smb2_getinfo/smb2_setinfo metze (This used to be commit dcc02df8297162a7fd913560194d9e821798dbe0) --- source4/libcli/smb2/getinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 57a363b63f..2af8032938 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -44,7 +44,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin SIVAL(req->out.body, 0x0C, io->in.unknown2); SIVAL(req->out.body, 0x10, io->in.flags); SIVAL(req->out.body, 0x14, io->in.flags2); - smb2_push_handle(req->out.body+0x18, &io->in.handle); + smb2_push_handle(req->out.body+0x18, &io->in.file.handle); smb2_transport_send(req); @@ -118,7 +118,7 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = io->generic.in.file.handle; + b.in.file.handle = io->generic.in.file.handle; b.in.level = smb2_level; if (io->generic.level == RAW_FILEINFO_SEC_DESC) { @@ -174,7 +174,7 @@ struct smb2_request *smb2_getinfo_fs_send(struct smb2_tree *tree, union smb_fsin ZERO_STRUCT(b); b.in.max_response_size = 0x10000; - b.in.handle = io->generic.handle; + b.in.file.handle = io->generic.handle; b.in.level = smb2_level; return smb2_getinfo_send(tree, &b); -- 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/getinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 2af8032938..a9a681ea53 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.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/getinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index a9a681ea53..0665dd441c 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -31,7 +31,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0); + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, false, 0); if (req == NULL) return NULL; /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */ @@ -64,7 +64,7 @@ NTSTATUS smb2_getinfo_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, return smb2_request_destroy(req); } - SMB2_CHECK_PACKET_RECV(req, 0x08, True); + SMB2_CHECK_PACKET_RECV(req, 0x08, true); status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x02, &io->out.blob); if (!NT_STATUS_IS_OK(status)) { -- cgit From b640f475be9b0f83e7812a5c7756344c5891cba3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 17:11:36 +1100 Subject: updated SMB2 code for getinfo according to WSPP docs - Updated getinfo structures and field names - also updated the protocol revision number handling to reflect new docs (This used to be commit 3aaa2e86d94675c6c68d66d75292c3e34bfbc81b) --- source4/libcli/smb2/getinfo.c | 45 ++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 0665dd441c..e9f47140f5 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -30,21 +30,27 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getinfo *io) { struct smb2_request *req; + NTSTATUS status; - req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, false, 0); + req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, true, + io->in.blob.length); if (req == NULL) return NULL; - /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */ - SSVAL(req->out.body, 0x00, 0x29); - - SSVAL(req->out.body, 0x02, io->in.level); - SIVAL(req->out.body, 0x04, io->in.max_response_size); - SIVAL(req->out.body, 0x08, io->in.unknown1); - SIVAL(req->out.body, 0x0C, io->in.unknown2); - SIVAL(req->out.body, 0x10, io->in.flags); - SIVAL(req->out.body, 0x14, io->in.flags2); + SCVAL(req->out.body, 0x02, io->in.info_type); + SCVAL(req->out.body, 0x03, io->in.info_class); + SIVAL(req->out.body, 0x04, io->in.output_buffer_length); + SIVAL(req->out.body, 0x0C, io->in.reserved); + SIVAL(req->out.body, 0x08, io->in.input_buffer_length); + SIVAL(req->out.body, 0x10, io->in.additional_information); + SIVAL(req->out.body, 0x14, io->in.getinfo_flags); smb2_push_handle(req->out.body+0x18, &io->in.file.handle); + /* this blob is used for quota queries */ + status = smb2_push_o32s32_blob(&req->out, 0x08, io->in.blob); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(req); + return NULL; + } smb2_transport_send(req); return req; @@ -116,15 +122,17 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi } ZERO_STRUCT(b); - b.in.max_response_size = 0x10000; - b.in.file.handle = io->generic.in.file.handle; - b.in.level = smb2_level; + b.in.info_type = smb2_level & 0xFF; + b.in.info_class = smb2_level >> 8; + b.in.output_buffer_length = 0x10000; + b.in.input_buffer_length = 0; + b.in.file.handle = io->generic.in.file.handle; if (io->generic.level == RAW_FILEINFO_SEC_DESC) { - b.in.flags = io->query_secdesc.in.secinfo_flags; + b.in.additional_information = io->query_secdesc.in.secinfo_flags; } if (io->generic.level == RAW_FILEINFO_SMB2_ALL_EAS) { - b.in.flags2 = io->all_eas.in.continue_flags; + b.in.getinfo_flags = io->all_eas.in.continue_flags; } return smb2_getinfo_send(tree, &b); @@ -172,9 +180,10 @@ struct smb2_request *smb2_getinfo_fs_send(struct smb2_tree *tree, union smb_fsin } ZERO_STRUCT(b); - b.in.max_response_size = 0x10000; - b.in.file.handle = io->generic.handle; - b.in.level = smb2_level; + b.in.output_buffer_length = 0x10000; + b.in.file.handle = io->generic.handle; + b.in.info_type = smb2_level & 0xFF; + b.in.info_class = smb2_level >> 8; return smb2_getinfo_send(tree, &b); } -- 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/getinfo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/getinfo.c') diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index e9f47140f5..b462bab1de 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.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