]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: correctly restore ENOENT if fstatfs() modifies it
authorStefan Metzmacher <metze@samba.org>
Wed, 3 Jul 2024 08:58:33 +0000 (10:58 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Jul 2024 11:41:12 +0000 (11:41 +0000)
Review with: git show -U5

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jul  3 11:41:12 UTC 2024 on atb-devel-224

source3/smbd/open.c

index 0c101c19b4693fc79fff51606db82ed1215afc94..7999b3f082ed62c4a686b2f8edc8411ab142a880 100644 (file)
@@ -1190,10 +1190,8 @@ static NTSTATUS reopen_from_fsp(struct files_struct *dirfsp,
                                struct statfs sbuf = {};
                                int ret = fstatfs(old_fd, &sbuf);
                                if (ret == -1) {
-                                       int saved_errno = errno;
                                        DBG_ERR("fstatfs failed: %s\n",
                                                strerror(errno));
-                                       errno = saved_errno;
                                } else if (sbuf.f_type == AUTOFS_SUPER_MAGIC) {
                                        /*
                                         * When reopening an as-yet
@@ -1203,6 +1201,8 @@ static NTSTATUS reopen_from_fsp(struct files_struct *dirfsp,
                                         */
                                        goto namebased_open;
                                }
+                               /* restore ENOENT if changed in the meantime */
+                               errno = ENOENT;
                        }
 #endif
                        status = map_nt_error_from_unix(errno);