]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroups-agent: connect stdin/stdout/stderr to /dev/null
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Jul 2022 09:02:40 +0000 (11:02 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 15 Jul 2022 12:51:41 +0000 (14:51 +0200)
Inspired by https://github.com/systemd/systemd/pull/24024 this is
another user mode helper, where this might be an issue. hence let's
rather be safe than sorry, and also connect stdin/stdout/stderr
explicitly with /dev/null.

src/cgroups-agent/cgroups-agent.c

index 071cba30996e855d83bdad59ca8917234341dc4a..91267362351805b2e2c818347f009fad2986f381 100644 (file)
@@ -16,6 +16,13 @@ int main(int argc, char *argv[]) {
         _cleanup_close_ int fd = -1;
         ssize_t n;
         size_t l;
+        int r;
+
+        r = rearrange_stdio(-1, -1, -1);
+        if (r < 0) {
+                log_error_errno(r, "Failed to connect stdin/stdout/stderr with /dev/null: %m");
+                return EXIT_FAILURE;
+        }
 
         if (argc != 2) {
                 log_error("Incorrect number of arguments.");