]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: let openat_pathref_dirfsp_nosymlink() handle ELOOP similar to ENOTDIR
authorStefan Metzmacher <metze@samba.org>
Fri, 12 Aug 2022 17:12:44 +0000 (19:12 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 15 Aug 2022 15:03:37 +0000 (15:03 +0000)
This is no likely to happen as we use O_NOFOLLOW with O_DIRECTORY,
but it's better to be prepared...

This will be more important in the upcoming openat2(RESOLVE_NO_SYMLINK)
case, but we should be consitent...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/files.c

index f23e9e96e52ef80ac726c7ca4b269d446c6d4747..23de0ad63c2287e6f23eb85d710a24ca459674aa 100644 (file)
@@ -860,7 +860,15 @@ next:
                        &how);
        }
 
-       if ((fd == -1) && (errno == ENOTDIR)) {
+       /*
+        * O_NOFOLLOW|O_DIRECTORY results in
+        * ENOTDIR instead of ELOOP.
+        *
+        * But we should be prepared to handle ELOOP too.
+        */
+       if ((fd == -1) && (errno == ENOTDIR || errno == ELOOP)) {
+               NTSTATUS orig_status = map_nt_error_from_unix(errno);
+
                status = readlink_talloc(
                        mem_ctx, dirfsp, &rel_fname, substitute);
 
@@ -898,7 +906,7 @@ next:
                        /*
                         * Restore the error status from SMB_VFS_OPENAT()
                         */
-                       status = NT_STATUS_NOT_A_DIRECTORY;
+                       status = orig_status;
                }
                goto fail;
        }