]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
use O_PATH to get the root fds
authorMatteo Croce <teknoraver@meta.com>
Mon, 8 Jul 2024 23:24:50 +0000 (01:24 +0200)
committerMatteo Croce <teknoraver@meta.com>
Tue, 16 Jul 2024 13:03:37 +0000 (15:03 +0200)
`switch_root()` opens two file descriptors to do the switch but never
reads from them. Open them with O_PATH.

src/shared/switch-root.c

index e64b6f6c8fc5219f3444e5abb35f0310bb794dba..621161a1c0f456053f7932d6d3e55ffab530af92 100644 (file)
@@ -58,7 +58,7 @@ int switch_root(const char *new_root,
         if (old_root_fd < 0)
                 return log_error_errno(errno, "Failed to open root directory: %m");
 
-        new_root_fd = open(new_root, O_DIRECTORY|O_CLOEXEC);
+        new_root_fd = open(new_root, O_PATH|O_DIRECTORY|O_CLOEXEC);
         if (new_root_fd < 0)
                 return log_error_errno(errno, "Failed to open target directory '%s': %m", new_root);