From: Jeremy Allison Date: Tue, 6 Apr 2021 18:53:40 +0000 (-0700) Subject: s3: smbd: Fix parent_pathref() to cope with symlink parents. X-Git-Tag: tevent-0.11.0~1289 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d590d9130ee28cc0c39d605015f4b5904ba582f5;p=thirdparty%2Fsamba.git s3: smbd: Fix parent_pathref() to cope with symlink parents. We know that the parent name must exist, and the name has been canonicalized even if this was a POSIX pathname. Ensure that we follow symlinks for the parent. See the torture test POSIX-SYMLINK-PARENT for details. Remove knownfail entry. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Apr 7 15:39:45 UTC 2021 on sn-devel-184 --- diff --git a/selftest/knownfail.d/symlink_parent b/selftest/knownfail.d/symlink_parent deleted file mode 100644 index 752bab94ca3..00000000000 --- a/selftest/knownfail.d/symlink_parent +++ /dev/null @@ -1,2 +0,0 @@ -^samba3.smbtorture_s3.plain.*POSIX-SYMLINK-PARENT -^samba3.smbtorture_s3.crypt.*POSIX-SYMLINK-PARENT diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 213d069a5f4..548004d33c6 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -703,6 +703,16 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } + /* + * We know that the parent name must + * exist, and the name has been canonicalized + * even if this was a POSIX pathname. + * Ensure that we follow symlinks for + * the parent. See the torture test + * POSIX-SYMLINK-PARENT for details. + */ + parent->flags &= ~SMB_FILENAME_POSIX_PATH; + ret = vfs_stat(dirfsp->conn, parent); if (ret != 0) { TALLOC_FREE(parent);