From d9ae1c78b92c876dbe285d6edd170e920933c0a5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 28 Apr 2020 18:03:41 +0200 Subject: [PATCH] smbd: pass struct smb_filename to directory_has_default_acl() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/modules/vfs_ceph.c | 4 +--- source3/modules/vfs_default.c | 4 +--- source3/smbd/file_access.c | 12 ++---------- source3/smbd/open.c | 2 +- source3/smbd/proto.h | 3 ++- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 1e02a3fe2d8..166fdc9feee 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -365,9 +365,7 @@ static int cephwrap_mkdirat(struct vfs_handle_struct *handle, 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, - parent->base_name)) - { + if (ok && directory_has_default_acl(handle->conn, parent)) { mode = 0777; } } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index de4fc5d6a1b..a739b17963a 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -637,9 +637,7 @@ static int vfswrap_mkdirat(vfs_handle_struct *handle, 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, - parent->base_name)) - { + if (ok && directory_has_default_acl(handle->conn, parent)) { mode = (0777 & lp_directory_mask(SNUM(handle->conn))); } } diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index 39a8f195040..4884301fd4b 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -140,20 +140,12 @@ bool can_write_to_file(connection_struct *conn, Check for an existing default Windows ACL on a directory. ****************************************************************************/ -bool directory_has_default_acl(connection_struct *conn, const char *fname) +bool directory_has_default_acl(connection_struct *conn, + struct smb_filename *smb_fname) { struct security_descriptor *secdesc = NULL; unsigned int i; NTSTATUS status; - struct smb_filename *smb_fname = synthetic_smb_fname(talloc_tos(), - fname, - NULL, - NULL, - 0); - - if (smb_fname == NULL) { - return false; - } status = SMB_VFS_GET_NT_ACL(conn, smb_fname, SECINFO_DACL, talloc_tos(), diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 63adfabee4c..76f85fcc25c 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3615,7 +3615,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, */ if ((flags2 & O_CREAT) && lp_inherit_acls(SNUM(conn)) && - (def_acl = directory_has_default_acl(conn, parent_dir))) { + (def_acl = directory_has_default_acl(conn, parent_dir_fname))) { unx_mode = (0777 & lp_create_mask(SNUM(conn))); } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index cb32ebaca5e..e7b5e3239a7 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -326,7 +326,8 @@ bool can_delete_file_in_directory(connection_struct *conn, const struct smb_filename *smb_fname); bool can_write_to_file(connection_struct *conn, const struct smb_filename *smb_fname); -bool directory_has_default_acl(connection_struct *conn, const char *fname); +bool directory_has_default_acl(connection_struct *conn, + struct smb_filename *smb_fname); NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode); /* The following definitions come from smbd/fileio.c */ -- 2.47.3