]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
use O_PATH to obtain cgroupfs fd
authorMatteo Croce <teknoraver@meta.com>
Thu, 4 Jul 2024 01:16:29 +0000 (03:16 +0200)
committerMatteo Croce <teknoraver@meta.com>
Tue, 16 Jul 2024 13:03:37 +0000 (15:03 +0200)
We get a fd to cgroupfs just to avoid it being umounted, O_PATH
is enough, use it instead of O_RDONLY.

src/core/cgroup.c

index 9620436f6873141898bba78278c11f288b23c67d..6c131673461d8bade3b58239249cc6537e76e2e7 100644 (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");