From: Volker Lendecke Date: Tue, 20 Dec 2022 20:26:10 +0000 (+0100) Subject: smbd: Hide the SMB1 posix symlink behaviour behind UCF_LCOMP_LNK_OK X-Git-Tag: talloc-2.4.0~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=636daef0fef98d79161377aab78ca6c403cb71c3;p=thirdparty%2Fsamba.git smbd: Hide the SMB1 posix symlink behaviour behind UCF_LCOMP_LNK_OK This will be used in the future to also open symlinks as reparse points, so this won't be specific to only SMB1 posix extensions. I have tried to avoid additional flags for several weeks by making openat_pathref_fsp or other flavors of this to always open fsp's with symlink O_PATH opens, because I think NT_STATUS_OBJECT_NAME_NOT_FOUND with a valid stat is a really bad and racy way to express that we just hit a symlink, but I miserably failed. Adding additional flags (another one will follow) is wrong, but I don't see another way right now. Signed-off-by: Volker Lendecke --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index be24854f89c..73e88add2c3 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -41,6 +41,10 @@ uint32_t ucf_flags_from_smb_request(struct smb_request *req) if (req->posix_pathnames) { ucf_flags |= UCF_POSIX_PATHNAMES; + + if (!req->sconn->using_smb2) { + ucf_flags |= UCF_LCOMP_LNK_OK; + } } if (req->flags2 & FLAGS2_DFS_PATHNAMES) { ucf_flags |= UCF_DFS_PATHNAME; @@ -1251,7 +1255,7 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( * In SMB1 posix mode, if this is a symlink, * allow access to the name with a NULL smb_fname->fsp. */ - if (!conn->sconn->using_smb2 && posix) { + if (ucf_flags & UCF_LCOMP_LNK_OK) { SMB_ASSERT(smb_fname_rel->fsp == NULL); SMB_ASSERT(streamname == NULL); diff --git a/source3/smbd/smbd.h b/source3/smbd/smbd.h index 6cf2b64a5a1..1c98bea4334 100644 --- a/source3/smbd/smbd.h +++ b/source3/smbd/smbd.h @@ -84,6 +84,10 @@ struct trans_state { #define UCF_POSIX_PATHNAMES 0x00000008 /* #define UCF_UNIX_NAME_LOOKUP 0x00000010 is no longer used. */ #define UCF_PREP_CREATEFILE 0x00000020 +/* + * Return a non-fsp smb_fname for a symlink + */ +#define UCF_LCOMP_LNK_OK 0x00000040 /* * Use the same bit as FLAGS2_REPARSE_PATH * which means the same thing.