]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
discover-image: make sure quota logic works on O_PATH fds
authorLennart Poettering <lennart@poettering.net>
Mon, 9 Dec 2024 12:51:51 +0000 (13:51 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Dec 2024 10:21:57 +0000 (11:21 +0100)
src/shared/discover-image.c

index 82be0b73d8aa8cb26ce16de7c889873284c872aa..35386dfc58f67ac822dfea9bfb44aeab9c70fad3 100644 (file)
@@ -295,10 +295,15 @@ static int image_update_quota(Image *i, int fd) {
                 return -EOPNOTSUPP;
 
         if (fd < 0) {
-                fd_close = open(i->path, O_CLOEXEC|O_NOCTTY|O_DIRECTORY);
+                fd_close = open(i->path, O_CLOEXEC|O_DIRECTORY);
                 if (fd_close < 0)
                         return -errno;
                 fd = fd_close;
+        } else {
+                /* Convert from O_PATH to proper fd, if needed */
+                fd = fd_reopen_condition(fd, O_CLOEXEC|O_DIRECTORY, O_PATH, &fd_close);
+                if (fd < 0)
+                        return fd;
         }
 
         r = btrfs_quota_scan_ongoing(fd);