summaryrefslogtreecommitdiff
path: root/src/cgroups-agent
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-07-15 11:02:40 +0200
committerLennart Poettering <lennart@poettering.net>2022-07-15 14:51:41 +0200
commit50492ce81589773df2d82b4fc8047778e86c6edf (patch)
treeb00eb2d7d67f1bf2240b1941f0aa44b291f858a2 /src/cgroups-agent
parent81b739d25805f6eb532f0390cf62ab367fbafd87 (diff)
downloadsystemd-50492ce81589773df2d82b4fc8047778e86c6edf.tar.gz
cgroups-agent: connect stdin/stdout/stderr to /dev/null
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.
Diffstat (limited to 'src/cgroups-agent')
-rw-r--r--src/cgroups-agent/cgroups-agent.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index 071cba3099..9126736235 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -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.");