]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify filename_convert_dirfsp_nosymlink()
authorVolker Lendecke <vl@samba.org>
Thu, 10 Oct 2024 08:16:14 +0000 (10:16 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 12 Nov 2024 18:07:33 +0000 (18:07 +0000)
Reference conn->cwd_fsp just once, shrinks next patches

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

index 8f7d25841d392741d8d6e40726f4da4cc4b52bea..2ae6edde4c38c5023216ae36925827bb9fcce620 100644 (file)
@@ -667,6 +667,7 @@ fail:
 static NTSTATUS filename_convert_dirfsp_nosymlink(
        TALLOC_CTX *mem_ctx,
        connection_struct *conn,
+       struct files_struct *basedir,
        const char *name_in,
        uint32_t ucf_flags,
        NTTIME twrp,
@@ -704,7 +705,7 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
                        .st_ex_ctime = omit,
                };
 
-               *_dirfsp = conn->cwd_fsp;
+               *_dirfsp = basedir;
                *_smb_fname = smb_fname;
                return NT_STATUS_OK;
        }
@@ -750,15 +751,14 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
        }
 
        if (dirname[0] == '\0') {
-               status = synthetic_pathref(
-                       mem_ctx,
-                       conn->cwd_fsp,
-                       ".",
-                       NULL,
-                       NULL,
-                       0,
-                       posix ? SMB_FILENAME_POSIX_PATH : 0,
-                       &smb_dirname);
+               status = synthetic_pathref(mem_ctx,
+                                          basedir,
+                                          ".",
+                                          NULL,
+                                          NULL,
+                                          0,
+                                          posix ? SMB_FILENAME_POSIX_PATH : 0,
+                                          &smb_dirname);
        } else {
                status = normalize_filename_case(conn, dirname, ucf_flags);
                if (!NT_STATUS_IS_OK(status)) {
@@ -770,7 +770,7 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
 
                status = openat_pathref_fsp_nosymlink(mem_ctx,
                                                      conn,
-                                                     conn->cwd_fsp,
+                                                     basedir,
                                                      dirname,
                                                      twrp,
                                                      posix,
@@ -1090,6 +1090,7 @@ next:
 
        status = filename_convert_dirfsp_nosymlink(mem_ctx,
                                                   conn,
+                                                  conn->cwd_fsp,
                                                   name_in,
                                                   ucf_flags,
                                                   twrp,