1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-13 00:58:27 +03:00

use O_PATH to get the root fds

`switch_root()` opens two file descriptors to do the switch but never
reads from them. Open them with O_PATH.
This commit is contained in:
Matteo Croce 2024-07-09 01:24:50 +02:00
parent b22befa9f5
commit e51d8e0aa4

View 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);