]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
binfmt-util: propagate failure in access_fd()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Jul 2025 09:51:55 +0000 (18:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Jul 2025 05:02:00 +0000 (14:02 +0900)
It is not necessary to hide errors in access_fd(), and only acceptable
errors here are -EROFS, -EACCES, and -EPERM.

src/shared/binfmt-util.c

index c88ce2cd0e29903374f6ac81202d284e8854ff82..49d920c2925367269b563a2ea8c0d1a05813c0bb 100644 (file)
@@ -25,7 +25,13 @@ int binfmt_mounted(void) {
         if (r <= 0)
                 return r;
 
-        return access_fd(fd, W_OK) >= 0;
+        r = access_fd(fd, W_OK);
+        if (ERRNO_IS_NEG_FS_WRITE_REFUSED(r))
+                return false;
+        if (r < 0)
+                return r;
+
+        return true;
 }
 
 int disable_binfmt(void) {