smbd: convert inherit_access_posix_acl() arg parent_dir to struct smb_filename
authorRalph Boehme <slow@samba.org>
Wed, 29 Apr 2020 08:56:23 +0000 (10:56 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 29 Apr 2020 16:39:41 +0000 (16:39 +0000)
This also fixes a bug introduced by cea8e57eac2ed7b90a5c5d207bf392ff0546398e
where inherit_access_posix_acl() used the smb_fname->base_name instead of
inherit_from_dir in synthetic_smb_fname() to get an struct smb_filename of the
parent directory.

Nobody complained so far, fix it silently.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c
source3/smbd/posix_acls.c
source3/smbd/proto.h
source3/smbd/trans2.c

index ad913f723a5a878ac45de152b06fdaef27ee3632..9c7418022a00e99957def02df45c24de2644bc83 100644 (file)
@@ -1338,7 +1338,7 @@ static NTSTATUS open_file(files_struct *fsp,
                        /* Inherit the ACL if required */
                        if (lp_inherit_permissions(SNUM(conn))) {
                                inherit_access_posix_acl(conn,
-                                                        parent_dir->base_name,
+                                                        parent_dir,
                                                         smb_fname,
                                                         unx_mode);
                                need_re_stat = true;
@@ -4153,7 +4153,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        }
 
        if (lp_inherit_permissions(SNUM(conn))) {
-               inherit_access_posix_acl(conn, parent_dir,
+               inherit_access_posix_acl(conn, parent_dir_fname,
                                         smb_dname, mode);
                need_re_stat = true;
        }
index 7e64965d85ef5770e0de70072f13caad01a5faac..97caa47dde923eb0959a9d1124309c5333cfcf99 100644 (file)
@@ -4189,24 +4189,14 @@ static bool directory_has_default_posix_acl(connection_struct *conn,
 ****************************************************************************/
 
 int inherit_access_posix_acl(connection_struct *conn,
-                       const char *inherit_from_dir,
+                       struct smb_filename *inherit_from_dir,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
 {
-       struct smb_filename *inherit_from_fname =
-                       synthetic_smb_fname(talloc_tos(),
-                               smb_fname->base_name,
-                               NULL,
-                               NULL,
-                               smb_fname->flags);
-       if (inherit_from_fname == NULL) {
-               return-1;
-       }
-
-       if (directory_has_default_posix_acl(conn, inherit_from_fname))
+       if (directory_has_default_posix_acl(conn, inherit_from_dir))
                return 0;
 
-       return copy_access_posix_acl(conn, inherit_from_fname, smb_fname, mode);
+       return copy_access_posix_acl(conn, inherit_from_dir, smb_fname, mode);
 }
 
 /****************************************************************************
index f4163aee3fd5ada52232d2cef0df186d9b1a664a..cee7f80a420fb737bb1508f89c5dd513e60bd540 100644 (file)
@@ -826,7 +826,7 @@ int get_acl_group_bits( connection_struct *conn,
                        const struct smb_filename *smb_fname,
                        mode_t *mode);
 int inherit_access_posix_acl(connection_struct *conn,
-                       const char *inherit_from_dir,
+                       struct smb_filename *inherit_from_dir,
                        const struct smb_filename *smb_fname,
                        mode_t mode);
 NTSTATUS set_unix_posix_default_acl(connection_struct *conn,
index 37947d8139c39a59daf758bca4e0e127a860d241..21e77b5c3b8d8606292173bb9d8646eeaca784c8 100644 (file)
@@ -8154,7 +8154,7 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn,
                        return NT_STATUS_NO_MEMORY;
                }
                inherit_access_posix_acl(conn,
-                                        parent_fname->base_name,
+                                        parent_fname,
                                         smb_fname,
                                         unixmode);
                TALLOC_FREE(parent_fname);