1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

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 <vl@samba.org>
This commit is contained in:
Volker Lendecke 2022-12-20 21:26:10 +01:00 committed by Jeremy Allison
parent 70b515be9c
commit 636daef0fe
2 changed files with 9 additions and 1 deletions

View File

@ -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);

View File

@ -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.