From: Ralph Boehme Date: Tue, 28 Apr 2020 16:18:08 +0000 (+0200) Subject: smbd: pass struct smb_filename smb_fname_parent to unix_mode() X-Git-Tag: ldb-2.2.0~817 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45a560bce3ef06c211e60e3932521303cc396896;p=thirdparty%2Fsamba.git smbd: pass struct smb_filename smb_fname_parent to unix_mode() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 1baee073a36..7ddc5fd3fc6 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -120,7 +120,7 @@ static int set_link_read_only_flag(const SMB_STRUCT_STAT *const sbuf) mode_t unix_mode(connection_struct *conn, int dosmode, const struct smb_filename *smb_fname, - const char *inherit_from_dir) + struct smb_filename *smb_fname_parent) { mode_t result = (S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH); mode_t dir_mode = 0; /* Mode of the inherit_from directory if @@ -130,29 +130,15 @@ mode_t unix_mode(connection_struct *conn, int dosmode, result &= ~(S_IWUSR | S_IWGRP | S_IWOTH); } - if ((inherit_from_dir != NULL) && lp_inherit_permissions(SNUM(conn))) { - struct smb_filename *smb_fname_parent; - - DEBUG(2, ("unix_mode(%s) inheriting from %s\n", + if ((smb_fname_parent != NULL) && lp_inherit_permissions(SNUM(conn))) { + DBG_DEBUG("[%s] inheriting from [%s]\n", smb_fname_str_dbg(smb_fname), - inherit_from_dir)); - - smb_fname_parent = synthetic_smb_fname(talloc_tos(), - inherit_from_dir, - NULL, - NULL, - smb_fname->flags); - if (smb_fname_parent == NULL) { - DEBUG(1,("unix_mode(%s) failed, [dir %s]: No memory\n", - smb_fname_str_dbg(smb_fname), - inherit_from_dir)); - return(0); - } + smb_fname_str_dbg(smb_fname_parent)); if (SMB_VFS_STAT(conn, smb_fname_parent) != 0) { - DEBUG(4,("unix_mode(%s) failed, [dir %s]: %s\n", - smb_fname_str_dbg(smb_fname), - inherit_from_dir, strerror(errno))); + DBG_ERR("stat failed [%s]: %s\n", + smb_fname_str_dbg(smb_fname_parent), + strerror(errno)); TALLOC_FREE(smb_fname_parent); return(0); /* *** shouldn't happen! *** */ } @@ -1006,7 +992,7 @@ int file_set_dosmode(connection_struct *conn, } /* Fall back to UNIX modes. */ - unixmode = unix_mode(conn, dosmode, smb_fname, parent_dir->base_name); + unixmode = unix_mode(conn, dosmode, smb_fname, parent_dir); /* preserve the file type bits */ mask |= S_IFMT; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 4f2f7d2923d..a842f5f031f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3330,7 +3330,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is * created new. */ unx_mode = unix_mode(conn, new_dos_attributes | FILE_ATTRIBUTE_ARCHIVE, - smb_fname, parent_dir); + smb_fname, parent_dir_fname); } DEBUG(10, ("open_file_ntcreate: fname=%s, dos_attrs=0x%x " @@ -4093,7 +4093,10 @@ static NTSTATUS mkdir_internal(connection_struct *conn, posix_open = true; mode = (mode_t)(file_attributes & ~FILE_FLAG_POSIX_SEMANTICS); } else { - mode = unix_mode(conn, FILE_ATTRIBUTE_DIRECTORY, smb_dname, parent_dir); + mode = unix_mode(conn, + FILE_ATTRIBUTE_DIRECTORY, + smb_dname, + parent_dir_fname); } status = check_parent_access(conn, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index e1c892209a1..8e88ab40372 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -259,7 +259,7 @@ bool smbd_setup_mdns_registration(struct tevent_context *ev, mode_t unix_mode(connection_struct *conn, int dosmode, const struct smb_filename *smb_fname, - const char *inherit_from_dir); + struct smb_filename *smb_fname_parent); uint32_t dos_mode_msdfs(connection_struct *conn, const struct smb_filename *smb_fname); uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname);