]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec-invoke: save original stdin/stdout with O_CLOEXEC set
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Jul 2024 09:43:40 +0000 (11:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 Jul 2024 09:44:04 +0000 (11:44 +0200)
We turn off the flag anyway when we install them back as stdin/stdout
later (via dup2()). let's hence follow our usual rules, and turn on
O_CLOEXEC.

src/core/exec-invoke.c

index 9489fc230968ee68e39d6b6fa5681382a23e8e5b..5a47c336c0baf6a60b114118884f0d6daa478421 100644 (file)
@@ -659,11 +659,11 @@ static int setup_confirm_stdio(
         assert(ret_saved_stdin);
         assert(ret_saved_stdout);
 
-        saved_stdin = fcntl(STDIN_FILENO, F_DUPFD, 3);
+        saved_stdin = fcntl(STDIN_FILENO, F_DUPFD_CLOEXEC, 3);
         if (saved_stdin < 0)
                 return -errno;
 
-        saved_stdout = fcntl(STDOUT_FILENO, F_DUPFD, 3);
+        saved_stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 3);
         if (saved_stdout < 0)
                 return -errno;