From b54158fb72d5008c0cf639c9d24501a010885ef1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme <slow@samba.org> Date: Mon, 14 Dec 2020 11:51:20 +0100 Subject: [PATCH] smbd: move mode logic out of vfswrap_mkdirat() to the caller mkdir_internal() This is the correct place where this code should be. It also means opaque VFS modules that implement their own mkdirat() like glusterfs now use this logic. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> --- source3/modules/vfs_ceph.c | 14 -------------- source3/modules/vfs_default.c | 14 -------------- source3/smbd/open.c | 8 ++++++++ 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 4c380c3ad20..ee5d1caa793 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -365,26 +365,12 @@ static int cephwrap_mkdirat(struct vfs_handle_struct *handle, mode_t mode) { int result; - struct smb_filename *parent = NULL; - bool ok; DBG_DEBUG("[CEPH] mkdir(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)); SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); - if (lp_inherit_acls(SNUM(handle->conn))) { - ok = parent_smb_fname(talloc_tos(), smb_fname, &parent, NULL); - if (ok && directory_has_default_acl(handle->conn, - dirfsp, - parent)) - { - mode = 0777; - } - } - - TALLOC_FREE(parent); - result = ceph_mkdir(handle->data, smb_fname->base_name, mode); return WRAP_RETURN(result); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index df52856cd1e..4aaafedac56 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -670,25 +670,11 @@ static int vfswrap_mkdirat(vfs_handle_struct *handle, mode_t mode) { int result; - struct smb_filename *parent = NULL; - bool ok; START_PROFILE(syscall_mkdirat); SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); - if (lp_inherit_acls(SNUM(handle->conn))) { - ok = parent_smb_fname(talloc_tos(), smb_fname, &parent, NULL); - if (ok && directory_has_default_acl(handle->conn, - dirfsp, - parent)) - { - mode = (0777 & lp_directory_mask(SNUM(handle->conn))); - } - } - - TALLOC_FREE(parent); - result = mkdirat(fsp_get_pathref_fd(dirfsp), smb_fname->base_name, mode); END_PROFILE(syscall_mkdirat); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 801885fe26d..35949f4b17c 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -4364,6 +4364,14 @@ static NTSTATUS mkdir_internal(connection_struct *conn, return status; } + if (lp_inherit_acls(SNUM(conn))) { + if (directory_has_default_acl(conn, + conn->cwd_fsp, + parent_dir_fname)) { + mode = (0777 & lp_directory_mask(SNUM(conn))); + } + } + ret = SMB_VFS_MKDIRAT(conn, conn->cwd_fsp, smb_dname,