From: Volker Lendecke Date: Thu, 3 Mar 2022 10:32:20 +0000 (+0100) Subject: smbd: Inherit acl from an fsp instead of a fname X-Git-Tag: tevent-0.12.0~561 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd1dca2d175291f2258f7963419b16ea3f5c4e31;p=thirdparty%2Fsamba.git smbd: Inherit acl from an fsp instead of a fname Moving slowly towards passing directory handles instead of names, representing the idea that we hold a O_PATH file descriptor on directories. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index fa5a3136113..08c040e85db 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1490,7 +1490,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, + parent_dir->fsp, smb_fname, unx_mode); need_re_stat = true; @@ -4341,7 +4341,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn, } if (lp_inherit_permissions(SNUM(conn))) { - inherit_access_posix_acl(conn, parent_dir_fname, + inherit_access_posix_acl(conn, parent_dir_fname->fsp, smb_dname, mode); need_re_stat = true; } diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 4cfb821fc14..da3566c1cd9 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -4002,17 +4002,17 @@ static bool directory_has_default_posix_acl(struct files_struct *dirfsp) ****************************************************************************/ int inherit_access_posix_acl(connection_struct *conn, - struct smb_filename *inherit_from_dir, - const struct smb_filename *smb_fname, - mode_t mode) + struct files_struct *inherit_from_dirfsp, + const struct smb_filename *smb_fname, + mode_t mode) { int ret; - if (directory_has_default_posix_acl(inherit_from_dir->fsp)) + if (directory_has_default_posix_acl(inherit_from_dirfsp)) return 0; ret = copy_access_posix_acl( - inherit_from_dir->fsp, smb_fname->fsp, mode); + inherit_from_dirfsp, smb_fname->fsp, mode); return ret; } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 63f78024101..f880a223f7f 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -860,9 +860,9 @@ 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, - struct smb_filename *inherit_from_dir, - const struct smb_filename *smb_fname, - mode_t mode); + struct files_struct *inherit_from_dirfsp, + const struct smb_filename *smb_fname, + mode_t mode); NTSTATUS set_unix_posix_default_acl(connection_struct *conn, files_struct *fsp, uint16_t num_def_acls, const char *pdata); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index ce274d196be..3e0e2db75c3 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8105,7 +8105,7 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, if (lp_inherit_permissions(SNUM(conn))) { inherit_access_posix_acl(conn, - parent_fname, + parent_fname->fsp, smb_fname, unixmode); }