From: Ralph Boehme Date: Wed, 29 Apr 2020 08:56:23 +0000 (+0200) Subject: smbd: convert inherit_access_posix_acl() arg parent_dir to struct smb_filename X-Git-Tag: ldb-2.2.0~811 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf504ac3c6421757c1aa2822b3ffa5212e1e87f7;p=thirdparty%2Fsamba.git smbd: convert inherit_access_posix_acl() arg parent_dir to struct smb_filename 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ad913f723a5..9c7418022a0 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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; } diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 7e64965d85e..97caa47dde9 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -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); } /**************************************************************************** diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index f4163aee3fd..cee7f80a420 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 37947d8139c..21e77b5c3b8 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -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);