From: Jeremy Allison Date: Thu, 14 Jan 2021 19:50:39 +0000 (-0800) Subject: s3: smbd: Move creation of parent_fname out of lp_inherit_permissions() clause in... X-Git-Tag: samba-4.14.0rc1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebcde172de0886cb41741f9a5ad6ebaf36efeea6;p=thirdparty%2Fsamba.git s3: smbd: Move creation of parent_fname out of lp_inherit_permissions() clause in smb_unix_mknod(). We will need this for the upcoming openat_pathref_fsp() use. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 69b8323a29d..d0cc3b711db 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8113,6 +8113,8 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, NTSTATUS status; mode_t unixmode; int ret; + struct smb_filename *parent_fname = NULL; + bool ok; if (total_data < 100) { return NT_STATUS_INVALID_PARAMETER; @@ -8169,6 +8171,14 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, "%.0f mode 0%o for file %s\n", (double)dev, (unsigned int)unixmode, smb_fname_str_dbg(smb_fname))); + ok = parent_smb_fname(talloc_tos(), + smb_fname, + &parent_fname, + NULL); + if (!ok) { + return NT_STATUS_NO_MEMORY; + } + /* Ok - do the mknod. */ ret = SMB_VFS_MKNODAT(conn, conn->cwd_fsp, @@ -8177,6 +8187,7 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, dev); if (ret != 0) { + TALLOC_FREE(parent_fname); return map_nt_error_from_unix(errno); } @@ -8185,22 +8196,12 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn, */ if (lp_inherit_permissions(SNUM(conn))) { - struct smb_filename *parent_fname = NULL; - bool ok; - - ok = parent_smb_fname(talloc_tos(), - smb_fname, - &parent_fname, - NULL); - if (!ok) { - return NT_STATUS_NO_MEMORY; - } inherit_access_posix_acl(conn, parent_fname, smb_fname, unixmode); - TALLOC_FREE(parent_fname); } + TALLOC_FREE(parent_fname); return NT_STATUS_OK; }