]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Fix following symlinks if basedir != cwd_fsp
authorVolker Lendecke <vl@samba.org>
Wed, 23 Oct 2024 12:14:39 +0000 (14:14 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 12 Nov 2024 18:07:33 +0000 (18:07 +0000)
Unused so far, but soon we'll call this routine with a basedir that's
somewhere below the share root.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/filename.c

index 2ae6edde4c38c5023216ae36925827bb9fcce620..6884802a74bbdd992926d0fc337270e160868b90 100644 (file)
@@ -1079,6 +1079,7 @@ NTSTATUS filename_convert_dirfsp(
        struct symlink_reparse_struct *lnk = NULL;
        NTSTATUS status;
        char *target = NULL;
+       char *base_name = NULL;
        char *safe_target = NULL;
        size_t symlink_redirects = 0;
        int ret;
@@ -1146,9 +1147,13 @@ next:
                return map_nt_error_from_unix(ret);
        }
 
+       if (basedir != conn->cwd_fsp) {
+               base_name = basedir->fsp_name->base_name;
+       }
+
        status = safe_symlink_target_path(mem_ctx,
                                          conn->connectpath,
-                                         NULL,
+                                         base_name,
                                          target,
                                          lnk->unparsed_path_length,
                                          &safe_target);
@@ -1157,6 +1162,7 @@ next:
                return status;
        }
        name_in = safe_target;
+       basedir = conn->cwd_fsp;
 
        symlink_redirects += 1;