From ac3c32d0d51f626d6198c6994daff4fc48f6b5ae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Aug 2013 12:10:05 -0700 Subject: [PATCH] Allow UNIX extensions client to act on open fsp instead of pathname if available. Eliminates possible race condition on pathname op. Signed-off-by: Jeremy Allison Reviewed-by: Simo Sorce (cherry picked from commit f1ff97fc022adaacaa23b7da250be6f7d51c6ac7) --- source3/smbd/trans2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index fc31ad4ba47..0703d21607d 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7154,11 +7154,18 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, */ if (raw_unixmode != SMB_MODE_NO_CHANGE) { + int ret; + DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC " "setting mode 0%o for file %s\n", (unsigned int)unixmode, smb_fname_str_dbg(smb_fname))); - if (SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode) != 0) { + if (fsp && fsp->fh->fd != -1) { + ret = SMB_VFS_FCHMOD(fsp, unixmode); + } else { + ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode); + } + if (ret != 0) { return map_nt_error_from_unix(errno); } } -- 2.11.4.GIT