]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: In filename_convert_dirfsp_nosymlink(), in SMB1-only POSIX mode, allow...
authorJeremy Allison <jra@samba.org>
Mon, 1 Aug 2022 21:24:31 +0000 (14:24 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 2 Aug 2022 19:49:31 +0000 (19:49 +0000)
Doesn't contain a valid smb_fname->fsp pointer of course,
and is only used by the SMB1 code to take a reference to
a smylink name for manipulation (unlinkat, readlinkat etc.).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/filename.c

index 27650326ade9883b54e5c64cc0f725d0622468c5..a9a998db7c5d74e78ad298b1eefddb25ec709c24 100644 (file)
@@ -2907,6 +2907,28 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
                char *normalized = NULL;
 
                if (VALID_STAT(smb_fname_rel->st)) {
+#if defined(WITH_SMB1SERVER)
+                       /*
+                        * 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 &&
+                                       S_ISLNK(smb_fname_rel->st.st_ex_mode)) {
+                               SMB_ASSERT(smb_fname_rel->fsp == NULL);
+                               SMB_ASSERT(streamname == NULL);
+
+                               smb_fname = full_path_from_dirfsp_atname(
+                                               mem_ctx,
+                                               smb_dirname->fsp,
+                                               smb_fname_rel);
+                               if (smb_fname == NULL) {
+                                       status = NT_STATUS_NO_MEMORY;
+                                       goto fail;
+                               }
+                               goto done;
+                       }
+#endif
                        /*
                         * NT_STATUS_OBJECT_NAME_NOT_FOUND is
                         * misleading: The object exists but might be