]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: simplify setting and resetting fsp->fsp_name in non_widelink_open()
authorRalph Boehme <slow@samba.org>
Mon, 19 Oct 2020 08:19:28 +0000 (10:19 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Instead of setting and resetting the name to the relative name every time we
call into the VFS, just set it once and reset it at the end and when recursing
via process_symlink_open().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index b77f29272fb54e6a7ecb94816e7b9e138164c6bc..3dff25ccf8b28fbf93c0a341f1599d6fb3516929 100644 (file)
@@ -720,7 +720,6 @@ static int non_widelink_open(const struct files_struct *dirfsp,
                            mode);
 
        fsp_set_fd(fsp, fd);
-       fsp->fsp_name = orig_fsp_name;
 
        if (fd != -1 &&
            !is_ntfs_stream_smb_fname(fsp->fsp_name) &&
@@ -738,24 +737,16 @@ static int non_widelink_open(const struct files_struct *dirfsp,
                 */
                int ret;
 
-               fsp->fsp_name = smb_fname_rel;
-
                ret = SMB_VFS_FSTAT(fsp, &orig_fsp_name->st);
-
-               fsp->fsp_name = orig_fsp_name;
-
                if (ret != 0) {
                        goto out;
                }
 
                if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
-                       fsp->fsp_name = smb_fname_rel;
-
                        ret = SMB_VFS_CLOSE(fsp);
                        SMB_ASSERT(ret == 0);
 
                        fsp_set_fd(fsp, -1);
-                       fsp->fsp_name = orig_fsp_name;
                        fd = -1;
                        errno = ELOOP;
                }
@@ -783,6 +774,9 @@ static int non_widelink_open(const struct files_struct *dirfsp,
                                /* Explicitly no symlinks. */
                                goto out;
                        }
+
+                       fsp->fsp_name = orig_fsp_name;
+
                        /*
                         * We may have a symlink. Follow in userspace
                         * to ensure it's under the share definition.
@@ -810,7 +804,7 @@ static int non_widelink_open(const struct files_struct *dirfsp,
        }
 
   out:
-
+       fsp->fsp_name = orig_fsp_name;
        TALLOC_FREE(parent_dir_fname);
 
        if (oldwd_fname != NULL) {