]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
os-util: make open_extension_release() return O_PATH fd
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 8 Apr 2023 09:00:31 +0000 (18:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Apr 2023 09:44:50 +0000 (18:44 +0900)
src/basic/os-util.c

index 0bc1aeb25cc925b5cfbd242c3bd73d16b764572a..c1874e2572ea8d97fdd7659bb814e9317712e68e 100644 (file)
@@ -230,18 +230,8 @@ int open_extension_release(const char *root, ImageClass image_class, const char
         if (r < 0)
                 return r;
 
-        if (ret_fd) {
-                int real_fd;
-
-                /* Convert the O_PATH fd into a proper, readable one */
-                real_fd = fd_reopen(fd, O_RDONLY|O_CLOEXEC|O_NOCTTY);
-                safe_close(fd);
-                if (real_fd < 0)
-                        return real_fd;
-
-                *ret_fd = real_fd;
-        }
-
+        if (ret_fd)
+                *ret_fd = TAKE_FD(fd);
         if (ret_path)
                 *ret_path = TAKE_PTR(q);