use O_PATH to obtain cgroupfs fd

We get a fd to cgroupfs just to avoid it being umounted, O_PATH
is enough, use it instead of O_RDONLY.
This commit is contained in:
Matteo Croce
2024-07-16 15:03:37 +02:00
parent 572e163ef5
commit b22befa9f5
+1 -1
View File
@@ -4270,7 +4270,7 @@ int manager_setup_cgroup(Manager *m) {
/* 6. And pin it, so that it cannot be unmounted */
safe_close(m->pin_cgroupfs_fd);
m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
m->pin_cgroupfs_fd = open(path, O_PATH|O_CLOEXEC|O_DIRECTORY);
if (m->pin_cgroupfs_fd < 0)
return log_error_errno(errno, "Failed to open pin file: %m");