The branch, master has been updated via 0876712ce8f libsmb: Make cli_posix_chown/chmod proper tevent_req functions via c05ff617ccb libsmb: Make "struct smb2_lock_element" generally usable via aac203907f1 libsmb: Rename InfoType from [MS-SMB2] according to the spec from f1a1c300e19 ctdb-scripts: Do not "correct" number of nfsd threads when it is 0
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 0876712ce8f40735a45c4bea7653d7b5beb2ddda Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 29 09:50:31 2019 +0100 libsmb: Make cli_posix_chown/chmod proper tevent_req functions This prepares for making them smb2-aware Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Mon Apr 1 19:00:11 UTC 2019 on sn-devel-144 commit c05ff617ccb38ef07d31a5840d93c804faf4faa9 Author: Volker Lendecke <v...@samba.org> Date: Mon Mar 25 15:43:49 2019 +0100 libsmb: Make "struct smb2_lock_element" generally usable This struct will be of interest when we add locking capabilities to libcli/smb/smb2cli* Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit aac203907f1be6e58c1ff2dc7c55f602e755ddd3 Author: Volker Lendecke <v...@samba.org> Date: Fri Mar 29 11:08:12 2019 +0100 libsmb: Rename InfoType from [MS-SMB2] according to the spec This makes it easier to find this via internet search Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: libcli/smb/smb2_constants.h | 10 +-- examples/fuse/clifuse.h => libcli/smb/smb2_lock.h | 17 +++-- libcli/smb/smb_common.h | 1 + source3/libsmb/cli_smb2_fnum.c | 4 +- source3/libsmb/clifile.c | 82 ++++++++++++++++++++--- source3/smbd/smb2_getinfo.c | 8 +-- source3/smbd/smb2_setinfo.c | 8 +-- source3/torture/test_smb2.c | 14 ++-- source4/libcli/raw/interfaces.h | 7 +- source4/libcli/smb2/getinfo.c | 10 +-- source4/libcli/smb2/setinfo.c | 3 +- source4/smb_server/smb2/fileinfo.c | 16 ++--- source4/torture/smb2/compound.c | 4 +- source4/torture/smb2/getinfo.c | 6 +- 14 files changed, 128 insertions(+), 62 deletions(-) copy examples/fuse/clifuse.h => libcli/smb/smb2_lock.h (74%) Changeset truncated at 500 lines: diff --git a/libcli/smb/smb2_constants.h b/libcli/smb/smb2_constants.h index f6edf6ba109..3dd462cdd69 100644 --- a/libcli/smb/smb2_constants.h +++ b/libcli/smb/smb2_constants.h @@ -259,11 +259,11 @@ #define SMB2_CONTINUE_FLAG_INDEX 0x04 #define SMB2_CONTINUE_FLAG_REOPEN 0x10 -/* getinfo classes */ -#define SMB2_GETINFO_FILE 0x01 -#define SMB2_GETINFO_FS 0x02 -#define SMB2_GETINFO_SECURITY 0x03 -#define SMB2_GETINFO_QUOTA 0x04 +/* get/setinfo classes, see [MS-SMB2] 2.2.37 and 2.2.39 */ +#define SMB2_0_INFO_FILE 0x01 +#define SMB2_0_INFO_FILESYSTEM 0x02 +#define SMB2_0_INFO_SECURITY 0x03 +#define SMB2_0_INFO_QUOTA 0x04 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (0x01) diff --git a/examples/fuse/clifuse.h b/libcli/smb/smb2_lock.h similarity index 74% copy from examples/fuse/clifuse.h copy to libcli/smb/smb2_lock.h index 62a2666906c..f0e05355232 100644 --- a/examples/fuse/clifuse.h +++ b/libcli/smb/smb2_lock.h @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. - * fusermount smb2 client - * Copyright (C) Volker Lendecke 2016 + * + * Copyright (C) Volker Lendecke 2019 * * 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 @@ -17,11 +17,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __EXAMPLES_FUSE_CLIFUSE_H__ -#define __EXAMPLES_FUSE_CLIFUSE_H__ +#ifndef __LIBCLI_SMB_SMB2_LOCK_H__ +#define __LIBCLI_SMB_SMB2_LOCK_H__ -struct cli_state; +#include "replace.h" -int do_mount(struct cli_state *cli, const char *mountpoint); +struct smb2_lock_element { + uint64_t offset; + uint64_t length; + uint32_t flags; + uint32_t reserved; +}; #endif diff --git a/libcli/smb/smb_common.h b/libcli/smb/smb_common.h index 2f66b0a8360..0117570b537 100644 --- a/libcli/smb/smb_common.h +++ b/libcli/smb/smb_common.h @@ -26,6 +26,7 @@ #include "libcli/smb/smb2_constants.h" #include "libcli/smb/smb2_create_blob.h" #include "libcli/smb/smb2_lease.h" +#include "libcli/smb/smb2_lock.h" #include "libcli/smb/smb2_signing.h" #include "libcli/smb/smb_util.h" #include "libcli/smb/smb_unix_ext.h" diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 33bc31592a4..6a725cb1537 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -2675,7 +2675,7 @@ NTSTATUS cli_smb2_get_fs_full_size_info(struct cli_state *cli, status = cli_smb2_query_info_fnum( cli, fnum, - SMB2_GETINFO_FS, /* in_info_type */ + SMB2_0_INFO_FILESYSTEM, /* in_info_type */ SMB_FS_FULL_SIZE_INFORMATION - 1000, /* in_file_info_class */ 0xFFFF, /* in_max_output_length */ NULL, /* in_input_buffer */ @@ -2846,7 +2846,7 @@ NTSTATUS cli_smb2_get_fs_volume_info(struct cli_state *cli, status = cli_smb2_query_info_fnum( cli, fnum, - SMB2_GETINFO_FS, /* in_info_type */ + SMB2_0_INFO_FILESYSTEM, /* in_info_type */ /* in_file_info_class */ SMB_FS_VOLUME_INFORMATION - 1000, 0xFFFF, /* in_max_output_length */ diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index dec0dd01609..b0d02395273 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -934,21 +934,54 @@ static void cli_posix_chown_chmod_internal_done(struct tevent_req *subreq) tevent_req_simple_finish_ntstatus(subreq, status); } +static NTSTATUS cli_posix_chown_chmod_internal_recv(struct tevent_req *req) +{ + return tevent_req_simple_recv_ntstatus(req); +} + /**************************************************************************** chmod a file (UNIX extensions). ****************************************************************************/ +struct cli_posix_chmod_state { + uint8_t dummy; +}; + +static void cli_posix_chmod_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, const char *fname, mode_t mode) { - return cli_posix_chown_chmod_internal_send(mem_ctx, ev, cli, - fname, - unix_perms_to_wire(mode), - SMB_UID_NO_CHANGE, - SMB_GID_NO_CHANGE); + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_chmod_state *state = NULL; + + req = tevent_req_create(mem_ctx, &state, struct cli_posix_chmod_state); + if (req == NULL) { + return NULL; + } + + subreq = cli_posix_chown_chmod_internal_send( + state, + ev, + cli, + fname, + unix_perms_to_wire(mode), + SMB_UID_NO_CHANGE, + SMB_GID_NO_CHANGE); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_chmod_done, req); + return req; +} + +static void cli_posix_chmod_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_chown_chmod_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_chmod_recv(struct tevent_req *req) @@ -1002,6 +1035,12 @@ NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode) chown a file (UNIX extensions). ****************************************************************************/ +struct cli_posix_chown_state { + uint8_t dummy; +}; + +static void cli_posix_chown_done(struct tevent_req *subreq); + struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, @@ -1009,11 +1048,34 @@ struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx, uid_t uid, gid_t gid) { - return cli_posix_chown_chmod_internal_send(mem_ctx, ev, cli, - fname, - SMB_MODE_NO_CHANGE, - (uint32_t)uid, - (uint32_t)gid); + struct tevent_req *req = NULL, *subreq = NULL; + struct cli_posix_chown_state *state = NULL; + + req = tevent_req_create( + mem_ctx, &state, struct cli_posix_chown_state); + if (req == NULL) { + return NULL; + } + + subreq = cli_posix_chown_chmod_internal_send( + state, + ev, + cli, + fname, + SMB_MODE_NO_CHANGE, + (uint32_t)uid, + (uint32_t)gid); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, cli_posix_chown_done, req); + return req; +} + +static void cli_posix_chown_done(struct tevent_req *subreq) +{ + NTSTATUS status = cli_posix_chown_chmod_internal_recv(subreq); + tevent_req_simple_finish_ntstatus(subreq, status); } NTSTATUS cli_posix_chown_recv(struct tevent_req *req) diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c index cd92db18619..9ec252c172b 100644 --- a/source3/smbd/smb2_getinfo.c +++ b/source3/smbd/smb2_getinfo.c @@ -288,7 +288,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, } switch (in_info_type) { - case SMB2_GETINFO_FILE: + case SMB2_0_INFO_FILE: { uint16_t file_info_level; char *data = NULL; @@ -428,7 +428,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, break; } - case SMB2_GETINFO_FS: + case SMB2_0_INFO_FILESYSTEM: { uint16_t file_info_level; char *data = NULL; @@ -481,7 +481,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, break; } - case SMB2_GETINFO_SECURITY: + case SMB2_0_INFO_SECURITY: { uint8_t *p_marshalled_sd = NULL; size_t sd_size = 0; @@ -528,7 +528,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, break; } - case SMB2_GETINFO_QUOTA: { + case SMB2_0_INFO_QUOTA: { #ifdef HAVE_SYS_QUOTAS struct smb2_query_quota_info info; enum ndr_err_code err; diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index 92e06f8c7d2..7fdcbd7a8d2 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -389,7 +389,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, } switch (in_info_type) { - case 0x01:/* SMB2_SETINFO_FILE */ + case SMB2_0_INFO_FILE: { uint16_t file_info_level; char *data; @@ -530,7 +530,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, break; } - case 0x02:/* SMB2_SETINFO_FS */ + case SMB2_0_INFO_FILESYSTEM: { uint16_t file_info_level = in_file_info_class + 1000; @@ -548,7 +548,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, break; } - case 0x03:/* SMB2_SETINFO_SECURITY */ + case SMB2_0_INFO_SECURITY: { if (!CAN_WRITE(conn)) { tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); @@ -567,7 +567,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx, break; } - case 0x04:/* SMB2_SETINFO_QUOTA */ + case SMB2_0_INFO_QUOTA: { #ifdef HAVE_SYS_QUOTAS struct file_quota_information info = {0}; diff --git a/source3/torture/test_smb2.c b/source3/torture/test_smb2.c index 094a9b84d6e..0cfb68cbbef 100644 --- a/source3/torture/test_smb2.c +++ b/source3/torture/test_smb2.c @@ -1617,7 +1617,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_SECURITY, + SMB2_0_INFO_SECURITY, 0, /* in_file_info_class */ 1024, /* in_max_output_length */ NULL, /* in_input_buffer */ @@ -1637,7 +1637,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_FILE, + SMB2_0_INFO_FILE, in_file_info_class, 1024, /* in_max_output_length */ NULL, /* in_input_buffer */ @@ -1660,7 +1660,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_FILE, + SMB2_0_INFO_FILE, in_file_info_class, &in_input_buffer, 0, /* in_additional_info */ @@ -1766,7 +1766,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_SECURITY, + SMB2_0_INFO_SECURITY, 0, /* in_file_info_class */ 1024, /* in_max_output_length */ NULL, /* in_input_buffer */ @@ -1786,7 +1786,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_FILE, + SMB2_0_INFO_FILE, in_file_info_class, 1024, /* in_max_output_length */ NULL, /* in_input_buffer */ @@ -1809,7 +1809,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_FILE, + SMB2_0_INFO_FILE, in_file_info_class, &in_input_buffer, 0, /* in_additional_info */ @@ -1825,7 +1825,7 @@ bool run_smb2_session_reauth(int dummy) cli->timeout, cli->smb2.session, cli->smb2.tcon, - SMB2_GETINFO_FILE, + SMB2_0_INFO_FILE, in_file_info_class, 1024, /* in_max_output_length */ NULL, /* in_input_buffer */ diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index d44c451f650..19b29197e16 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -2086,12 +2086,7 @@ union smb_lock { uint16_t lock_count; uint32_t lock_sequence; /* struct smb2_handle handle; */ - struct smb2_lock_element { - uint64_t offset; - uint64_t length; - uint32_t flags; - uint32_t reserved; - } *locks; + struct smb2_lock_element *locks; } in; struct { /* static body buffer 4 (0x04) bytes */ diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index 7a8fd44a855..fc97620ad24 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -112,9 +112,9 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, */ uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t info_class) { - if (info_class == SMB2_GETINFO_FILE && + if (info_class == SMB2_0_INFO_FILE && level == RAW_FILEINFO_SEC_DESC) { - return SMB2_GETINFO_SECURITY; + return SMB2_0_INFO_SECURITY; } if ((level & 0xFF) == info_class) { return level; @@ -132,7 +132,8 @@ uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t info_class) 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); + uint16_t smb2_level = smb2_getinfo_map_level( + io->generic.level, SMB2_0_INFO_FILE); if (smb2_level == 0) { return NULL; @@ -190,7 +191,8 @@ NTSTATUS smb2_getinfo_file(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, 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); + uint16_t smb2_level = smb2_getinfo_map_level( + io->generic.level, SMB2_0_INFO_FILESYSTEM); if (smb2_level == 0) { return NULL; diff --git a/source4/libcli/smb2/setinfo.c b/source4/libcli/smb2/setinfo.c index 69c0f45b63a..f8b50f6c4b6 100644 --- a/source4/libcli/smb2/setinfo.c +++ b/source4/libcli/smb2/setinfo.c @@ -83,7 +83,8 @@ NTSTATUS smb2_setinfo(struct smb2_tree *tree, struct smb2_setinfo *io) struct smb2_request *smb2_setinfo_file_send(struct smb2_tree *tree, union smb_setfileinfo *io) { struct smb2_setinfo b; - uint16_t smb2_level = smb2_getinfo_map_level(io->generic.level, SMB2_GETINFO_FILE); + uint16_t smb2_level = smb2_getinfo_map_level( + io->generic.level, SMB2_0_INFO_FILE); struct smb2_request *req; if (smb2_level == 0) { diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c index 10ea4eb8c5b..a90c41a73ae 100644 --- a/source4/smb_server/smb2/fileinfo.c +++ b/source4/smb_server/smb2/fileinfo.c @@ -185,16 +185,16 @@ static NTSTATUS smb2srv_getinfo_security(struct smb2srv_getinfo_op *op, uint8_t static NTSTATUS smb2srv_getinfo_backend(struct smb2srv_getinfo_op *op) { switch (op->info->in.info_type) { - case SMB2_GETINFO_FILE: + case SMB2_0_INFO_FILE: return smb2srv_getinfo_file(op, op->info->in.info_class); - case SMB2_GETINFO_FS: + case SMB2_0_INFO_FILESYSTEM: return smb2srv_getinfo_fs(op, op->info->in.info_class); - case SMB2_GETINFO_SECURITY: + case SMB2_0_INFO_SECURITY: return smb2srv_getinfo_security(op, op->info->in.info_class); - case SMB2_GETINFO_QUOTA: + case SMB2_0_INFO_QUOTA: return NT_STATUS_NOT_SUPPORTED; } @@ -338,16 +338,16 @@ static NTSTATUS smb2srv_setinfo_backend(struct smb2srv_setinfo_op *op) smb2_level = 0xFF & (op->info->in.level>>8); switch (smb2_class) { - case SMB2_GETINFO_FILE: + case SMB2_0_INFO_FILE: return smb2srv_setinfo_file(op, smb2_level); - case SMB2_GETINFO_FS: + case SMB2_0_INFO_FILESYSTEM: return smb2srv_setinfo_fs(op, smb2_level); - case SMB2_GETINFO_SECURITY: + case SMB2_0_INFO_SECURITY: return smb2srv_setinfo_security(op, smb2_level); - case 0x04: + case SMB2_0_INFO_QUOTA: return NT_STATUS_NOT_SUPPORTED; } diff --git a/source4/torture/smb2/compound.c b/source4/torture/smb2/compound.c index 0257cc27b8d..a84efc20186 100644 --- a/source4/torture/smb2/compound.c +++ b/source4/torture/smb2/compound.c @@ -184,7 +184,7 @@ static bool test_compound_break(struct torture_context *tctx, ZERO_STRUCT(gf); gf.in.file.handle = h; - gf.in.info_type = SMB2_GETINFO_FILE; + gf.in.info_type = SMB2_0_INFO_FILE; gf.in.info_class = 0x16; gf.in.output_buffer_length = 0x1000; gf.in.input_buffer = data_blob_null; @@ -1226,7 +1226,7 @@ static bool test_compound_interim2(struct torture_context *tctx, ZERO_STRUCT(gf); gf.in.file.handle = hd; - gf.in.info_type = SMB2_GETINFO_FILE; + gf.in.info_type = SMB2_0_INFO_FILE; gf.in.info_class = 0x04; /* FILE_BASIC_INFORMATION */ gf.in.output_buffer_length = 0x1000; gf.in.input_buffer = data_blob_null; diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c index d2307ab20a1..2e36082e067 100644 --- a/source4/torture/smb2/getinfo.c +++ b/source4/torture/smb2/getinfo.c @@ -285,7 +285,7 @@ static bool torture_smb2_qfs_buffercheck(struct torture_context *tctx) } -- Samba Shared Repository