From: Jeremy Allison Date: Mon, 19 Apr 2021 23:38:00 +0000 (-0700) Subject: s3: smbd: Prevent fchmod on a symlink. X-Git-Tag: tevent-0.11.0~1073 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c3470c0f2937f0a878469f751e868b7e80234d8;p=thirdparty%2Fsamba.git s3: smbd: Prevent fchmod on a symlink. Remove selftest/knownfail.d/symlink_chmod. Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Tue Apr 20 08:23:42 UTC 2021 on sn-devel-184 --- diff --git a/selftest/knownfail.d/symlink_chmod b/selftest/knownfail.d/symlink_chmod deleted file mode 100644 index 8ebe2a7cf9e..00000000000 --- a/selftest/knownfail.d/symlink_chmod +++ /dev/null @@ -1,2 +0,0 @@ -^samba3.smbtorture_s3.plain.*POSIX-SYMLINK-CHMOD -^samba3.smbtorture_s3.crypt.*POSIX-SYMLINK-CHMOD diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 7c15a731e0d..de843117581 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8324,6 +8324,12 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, if (raw_unixmode != SMB_MODE_NO_CHANGE) { int ret; + if (fsp == NULL || S_ISLNK(smb_fname->st.st_ex_mode)) { + DBG_WARNING("Can't set mode on symlink %s\n", + smb_fname_str_dbg(smb_fname)); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + DEBUG(10,("smb_set_file_unix_basic: SMB_SET_FILE_UNIX_BASIC " "setting mode 0%o for file %s\n", (unsigned int)unixmode,