The branch, master has been updated via 95c7d23462b vfs: Simplify fake_acls_stat() with an early return via e93f46357fd smbd: Simplify reopen_from_fsp() with an early return via 1d6762d86b9 smbd: copy_access_posix_acl() just needs fsps these days via a1d5ae30ed9 smbd: chmod_acl_internals() does not need connection_struct anymore via ea8a6537543 smbd: Make directory_has_default_posix_acl() just take "dirfsp" via 191c15f5ef7 smbd: Modernize a debug statement via 888275eee2d torture: Align an integer type via 69f2352c494 mdssvc: Align an integer type from 2b2b41c8682 s3: smbd: Add two new functions in a new file, smb2_posix.c: smb2_posix_cc_info(), store_smb2_posix_info()
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 95c7d23462b5b69ff852182a4922119279f3432d Author: Volker Lendecke <v...@samba.org> Date: Tue Jan 18 17:55:04 2022 +0100 vfs: Simplify fake_acls_stat() with an early return Review with "git di -b" 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): Tue Feb 1 20:04:44 UTC 2022 on sn-devel-184 commit e93f46357fd047c492e2582ee0bab2a0731e7bde Author: Volker Lendecke <v...@samba.org> Date: Thu Dec 30 15:59:33 2021 +0100 smbd: Simplify reopen_from_fsp() with an early return Review with git show -b Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 1d6762d86b9e4cdfbdd85657038a332392cd29ce Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 24 17:37:37 2022 +0100 smbd: copy_access_posix_acl() just needs fsps these days Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a1d5ae30ed9f38118077e9b208ccc2d1cc7918d1 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 24 17:34:23 2022 +0100 smbd: chmod_acl_internals() does not need connection_struct anymore Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ea8a653754350f7a3e28dd3c62fc1796017b125f Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 24 17:32:08 2022 +0100 smbd: Make directory_has_default_posix_acl() just take "dirfsp" conn is not referenced anymore, and we only need the files_struct Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 191c15f5ef77ca3d1ea3ac0e0b6ccc3085c8735d Author: Volker Lendecke <v...@samba.org> Date: Thu Jan 27 20:34:28 2022 +0100 smbd: Modernize a debug statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 888275eee2d582af4d42e86b62ce8ffda3e014bd Author: Volker Lendecke <v...@samba.org> Date: Thu Jan 27 21:52:31 2022 +0100 torture: Align an integer type Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 69f2352c4942a761ae5c61589ac7ce93ebfc8f93 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 31 08:57:41 2022 +0100 mdssvc: Align an integer type In libjansson 2.13.1 json_array_size() returns a size_t Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_fake_acls.c | 164 +++++++++++++++++----------------- source3/rpc_server/mdssvc/mdssvc_es.c | 4 +- source3/smbd/open.c | 32 +++---- source3/smbd/posix_acls.c | 39 ++++---- source3/smbd/smb2_server.c | 6 +- source4/torture/smb2/create.c | 6 +- 6 files changed, 127 insertions(+), 124 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_fake_acls.c b/source3/modules/vfs_fake_acls.c index 441e22ea3f6..25dc12f2c4c 100644 --- a/source3/modules/vfs_fake_acls.c +++ b/source3/modules/vfs_fake_acls.c @@ -80,6 +80,8 @@ static int fake_acls_stat(vfs_handle_struct *handle, { int ret = -1; struct in_pathref_data *prd = NULL; + struct smb_filename *smb_fname_cp = NULL; + struct files_struct *fsp = NULL; SMB_VFS_HANDLE_GET_DATA(handle, prd, @@ -87,99 +89,97 @@ static int fake_acls_stat(vfs_handle_struct *handle, return -1); ret = SMB_VFS_NEXT_STAT(handle, smb_fname); - if (ret == 0) { - struct smb_filename *smb_fname_cp = NULL; - struct files_struct *fsp = NULL; - - if (smb_fname->fsp != NULL) { - fsp = smb_fname->fsp; - if (fsp->base_fsp != NULL) { - /* - * This is a stream pathname. Use - * the base_fsp to get the xattr. - */ - fsp = fsp->base_fsp; - } - } else { - NTSTATUS status; + if (ret != 0) { + return ret; + } + if (smb_fname->fsp != NULL) { + fsp = smb_fname->fsp; + if (fsp->base_fsp != NULL) { /* - * Ensure openat_pathref_fsp() - * can't recurse into fake_acls_stat(). - * openat_pathref_fsp() doesn't care - * about the uid/gid values, it only - * wants a valid/invalid stat answer - * and we know smb_fname exists as - * the SMB_VFS_NEXT_STAT() returned - * zero above. + * This is a stream pathname. Use + * the base_fsp to get the xattr. */ - if (prd->calling_pathref_fsp) { - return 0; - } + fsp = fsp->base_fsp; + } + } else { + NTSTATUS status; - /* - * openat_pathref_fsp() expects a talloc'ed - * smb_filename. stat can be passed a struct - * from the stack. Make a talloc'ed copy - * so openat_pathref_fsp() can add its - * destructor. - */ - smb_fname_cp = cp_smb_filename(talloc_tos(), - smb_fname); - if (smb_fname_cp == NULL) { - errno = ENOMEM; - return -1; - } - - /* Recursion guard. */ - prd->calling_pathref_fsp = true; - status = openat_pathref_fsp(handle->conn->cwd_fsp, - smb_fname_cp); - /* End recursion guard. */ - prd->calling_pathref_fsp = false; - - if (!NT_STATUS_IS_OK(status)) { - /* - * Ignore errors here. We know - * the path exists (the SMB_VFS_NEXT_STAT() - * above succeeded. So being unable to - * open a pathref fsp can be due to a - * range of errors (startup path beginning - * with '/' for example, path = ".." when - * enumerating a directory. Just treat this - * the same way as the path not having the - * FAKE_UID or FAKE_GID EA's present. For the - * test purposes of this module (fake NT ACLs - * from windows clients) this is close enough. - * Just report for debugging purposes. - */ - DBG_DEBUG("Unable to get pathref fsp on %s. " - "Error %s\n", - smb_fname_str_dbg(smb_fname_cp), - nt_errstr(status)); - TALLOC_FREE(smb_fname_cp); - return 0; - } - fsp = smb_fname_cp->fsp; + /* + * Ensure openat_pathref_fsp() + * can't recurse into fake_acls_stat(). + * openat_pathref_fsp() doesn't care + * about the uid/gid values, it only + * wants a valid/invalid stat answer + * and we know smb_fname exists as + * the SMB_VFS_NEXT_STAT() returned + * zero above. + */ + if (prd->calling_pathref_fsp) { + return 0; } - ret = fake_acls_fuid(handle, - fsp, - &smb_fname->st.st_ex_uid); - if (ret != 0) { - TALLOC_FREE(smb_fname_cp); - return ret; + /* + * openat_pathref_fsp() expects a talloc'ed + * smb_filename. stat can be passed a struct + * from the stack. Make a talloc'ed copy + * so openat_pathref_fsp() can add its + * destructor. + */ + smb_fname_cp = cp_smb_filename(talloc_tos(), + smb_fname); + if (smb_fname_cp == NULL) { + errno = ENOMEM; + return -1; } - ret = fake_acls_fgid(handle, - fsp, - &smb_fname->st.st_ex_gid); - if (ret != 0) { + + /* Recursion guard. */ + prd->calling_pathref_fsp = true; + status = openat_pathref_fsp(handle->conn->cwd_fsp, + smb_fname_cp); + /* End recursion guard. */ + prd->calling_pathref_fsp = false; + + if (!NT_STATUS_IS_OK(status)) { + /* + * Ignore errors here. We know + * the path exists (the SMB_VFS_NEXT_STAT() + * above succeeded. So being unable to + * open a pathref fsp can be due to a + * range of errors (startup path beginning + * with '/' for example, path = ".." when + * enumerating a directory. Just treat this + * the same way as the path not having the + * FAKE_UID or FAKE_GID EA's present. For the + * test purposes of this module (fake NT ACLs + * from windows clients) this is close enough. + * Just report for debugging purposes. + */ + DBG_DEBUG("Unable to get pathref fsp on %s. " + "Error %s\n", + smb_fname_str_dbg(smb_fname_cp), + nt_errstr(status)); TALLOC_FREE(smb_fname_cp); - return ret; + return 0; } - TALLOC_FREE(smb_fname_cp); + fsp = smb_fname_cp->fsp; } + ret = fake_acls_fuid(handle, + fsp, + &smb_fname->st.st_ex_uid); + if (ret != 0) { + TALLOC_FREE(smb_fname_cp); + return ret; + } + ret = fake_acls_fgid(handle, + fsp, + &smb_fname->st.st_ex_gid); + if (ret != 0) { + TALLOC_FREE(smb_fname_cp); + return ret; + } + TALLOC_FREE(smb_fname_cp); return ret; } diff --git a/source3/rpc_server/mdssvc/mdssvc_es.c b/source3/rpc_server/mdssvc/mdssvc_es.c index aa169a80e1f..7eba87abf53 100644 --- a/source3/rpc_server/mdssvc/mdssvc_es.c +++ b/source3/rpc_server/mdssvc/mdssvc_es.c @@ -679,7 +679,7 @@ static void mds_es_search_http_read_done(struct tevent_req *subreq) json_t *match = NULL; size_t i; json_error_t error; - int hits; + size_t hits; NTSTATUS status; int ret; bool ok; @@ -770,7 +770,7 @@ static void mds_es_search_http_read_done(struct tevent_req *subreq) DBG_ERR("Hu?! No results?\n"); goto fail; } - DBG_DEBUG("Hits: %d\n", hits); + DBG_DEBUG("Hits: %zu\n", hits); for (i = 0; i < hits; i++) { const char *path = NULL; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 0427b0cef9d..6acc38c80f6 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1227,25 +1227,25 @@ static NTSTATUS reopen_from_fsp(struct files_struct *fsp, status = reopen_from_procfd(fsp, flags, mode); - if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - /* - * Close the existing pathref fd and set the fsp flag - * is_pathref to false so we get a "normal" fd this - * time. - */ - status = fd_close(fsp); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - fsp->fsp_flags.is_pathref = false; + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + return status; + } - status = fd_open_atomic(fsp, - flags, - mode, - p_file_created); + /* + * Close the existing pathref fd and set the fsp flag + * is_pathref to false so we get a "normal" fd this time. + */ + status = fd_close(fsp); + if (!NT_STATUS_IS_OK(status)) { + return status; } + fsp->fsp_flags.is_pathref = false; + + status = fd_open_atomic(fsp, + flags, + mode, + p_file_created); return status; } diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 899e7dc3c1e..ba9a61f2db6 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -3885,7 +3885,7 @@ int get_acl_group_bits( connection_struct *conn, and set the mask to rwx. Needed to preserve complex ACLs set by NT. ****************************************************************************/ -static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mode_t mode) +static int chmod_acl_internals(SMB_ACL_T posix_acl, mode_t mode) { int entry_id = SMB_ACL_FIRST_ENTRY; SMB_ACL_ENTRY_T entry; @@ -3953,24 +3953,25 @@ static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mo resulting ACL on TO. Note that name is in UNIX character set. ****************************************************************************/ -static int copy_access_posix_acl(connection_struct *conn, - const struct smb_filename *smb_fname_from, - const struct smb_filename *smb_fname_to, - mode_t mode) +static int copy_access_posix_acl(struct files_struct *from, + struct files_struct *to, + mode_t mode) { SMB_ACL_T posix_acl = NULL; int ret = -1; - if ((posix_acl = SMB_VFS_SYS_ACL_GET_FD(smb_fname_from->fsp, - SMB_ACL_TYPE_ACCESS, - talloc_tos())) == NULL) + posix_acl = SMB_VFS_SYS_ACL_GET_FD( + from, SMB_ACL_TYPE_ACCESS, talloc_tos()); + if (from == NULL) { return -1; + } - if ((ret = chmod_acl_internals(conn, posix_acl, mode)) == -1) + ret = chmod_acl_internals(posix_acl, mode); + if (ret == -1) { goto done; + } - ret = SMB_VFS_SYS_ACL_SET_FD(smb_fname_to->fsp, - SMB_ACL_TYPE_ACCESS, posix_acl); + ret = SMB_VFS_SYS_ACL_SET_FD(to, SMB_ACL_TYPE_ACCESS, posix_acl); done: @@ -3982,12 +3983,10 @@ static int copy_access_posix_acl(connection_struct *conn, Check for an existing default POSIX ACL on a directory. ****************************************************************************/ -static bool directory_has_default_posix_acl(connection_struct *conn, - const struct smb_filename *smb_fname) +static bool directory_has_default_posix_acl(struct files_struct *dirfsp) { - SMB_ACL_T def_acl = SMB_VFS_SYS_ACL_GET_FD(smb_fname->fsp, - SMB_ACL_TYPE_DEFAULT, - talloc_tos()); + SMB_ACL_T def_acl = SMB_VFS_SYS_ACL_GET_FD( + dirfsp, SMB_ACL_TYPE_DEFAULT, talloc_tos()); bool has_acl = False; SMB_ACL_ENTRY_T entry; @@ -4011,10 +4010,14 @@ int inherit_access_posix_acl(connection_struct *conn, const struct smb_filename *smb_fname, mode_t mode) { - if (directory_has_default_posix_acl(conn, inherit_from_dir)) + int ret; + + if (directory_has_default_posix_acl(inherit_from_dir->fsp)) return 0; - return copy_access_posix_acl(conn, inherit_from_dir, smb_fname, mode); + ret = copy_access_posix_acl( + inherit_from_dir->fsp, smb_fname->fsp, mode); + return ret; } /**************************************************************************** diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 042f343b0ca..caf6b6add1d 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -2976,9 +2976,9 @@ NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req) flags = IVAL(inhdr, SMB2_HDR_FLAGS); opcode = SVAL(inhdr, SMB2_HDR_OPCODE); mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID); - DEBUG(10,("smbd_smb2_request_dispatch: opcode[%s] mid = %llu\n", - smb2_opcode_name(opcode), - (unsigned long long)mid)); + DBG_DEBUG("opcode[%s] mid = %"PRIu64"\n", + smb2_opcode_name(opcode), + mid); if (xconn->protocol >= PROTOCOL_SMB2_02) { /* diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index 41a6ed6e4e4..4327fea9cc7 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -709,7 +709,7 @@ static bool test_smb2_open(struct torture_context *tctx, struct smb2_handle h = {{0}}; struct smb2_handle h1 = {{0}}; bool ret = true; - int i; + size_t i; struct { uint32_t create_disp; bool with_file; @@ -760,7 +760,7 @@ static bool test_smb2_open(struct torture_context *tctx, status= smb2_create(tree, tctx, &(io.smb2)); if (!NT_STATUS_IS_OK(status)) { torture_comment(tctx, - "Failed to create file %s status %s %d\n", + "Failed to create file %s status %s %zu\n", fname, nt_errstr(status), i); ret = false; @@ -772,7 +772,7 @@ static bool test_smb2_open(struct torture_context *tctx, status = smb2_create(tree, tctx, &(io.smb2)); if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) { torture_comment(tctx, - "(%s) incorrect status %s should be %s (i=%d " + "(%s) incorrect status %s should be %s (i=%zu " "with_file=%d open_disp=%d)\n", __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), -- Samba Shared Repository