]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Revert "smbd: Simplify filename_convert_dirfsp()"
authorVolker Lendecke <vl@samba.org>
Tue, 19 Nov 2024 10:48:12 +0000 (11:48 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 22 Nov 2024 09:50:37 +0000 (09:50 +0000)
This reverts commit bd30c9c128c203c3ed4b123b651862a9953f6cf2.

While this does indeed slightly simplify code, it simplifies too much: Soon we
will need filename_convert_dirfsp_nosymlink raw without looking at
UCF_LCOMP_LNK_OK. So in hindsight this went too far.

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

index 6b31670eff3b865fe8038ab9b2816489d91ba99d..b4d58f5ba7967e1d078830cbb60fe952e0309b48 100644 (file)
@@ -1041,13 +1041,6 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
        }
 
 done:
-       if (S_ISLNK(smb_fname->st.st_ex_mode) &&
-           !(ucf_flags & UCF_LCOMP_LNK_OK)) {
-               status = NT_STATUS_STOPPED_ON_SYMLINK;
-               *_symlink_err = symlink_err;
-               goto fail;
-       }
-
        *_dirfsp = smb_dirname->fsp;
        *_smb_fname = smb_fname;
        *_symlink_err = symlink_err;
@@ -1109,6 +1102,18 @@ next:
                                                   _smb_fname_rel,
                                                   &symlink_err);
 
+       if (NT_STATUS_IS_OK(status) && S_ISLNK((*_smb_fname)->st.st_ex_mode)) {
+               /*
+                * lcomp is a symlink
+                */
+               if (ucf_flags & UCF_LCOMP_LNK_OK) {
+                       TALLOC_FREE(symlink_err);
+                       return NT_STATUS_OK;
+               }
+               close_file_free(NULL, _dirfsp, ERROR_CLOSE);
+               status = NT_STATUS_STOPPED_ON_SYMLINK;
+       }
+
        if (!NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
                return status;
        }