smbd: move mode logic out of vfswrap_mkdirat() to the caller mkdir_internal()
authorRalph Boehme <slow@samba.org>
Mon, 14 Dec 2020 10:51:20 +0000 (11:51 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 17 Dec 2020 18:56:29 +0000 (18:56 +0000)
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
source3/modules/vfs_default.c
source3/smbd/open.c

index 4c380c3ad20d91027f62ec7221b6d40cb6b21a95..ee5d1caa7935ea2d6889bca2d58210b92090eb53 100644 (file)
@@ -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);
 }
index df52856cd1e6d6c9e383cb1ed5407cf8f5da4017..4aaafedac56788bea057335e6aaf457d121135d0 100644 (file)
@@ -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);
index 801885fe26ddc3ef87d373ff51f409f5891c60dc..35949f4b17c0aefca84c4943a066bbabe9a79bd7 100644 (file)
@@ -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,