From 096e2c1954f8b910c8cc4a4fa41f8325fd7ab84c Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 20 Apr 2021 18:46:58 +0200 Subject: [PATCH] conmon: do not chown /dev/null skip the fchmod for the standard input files when /dev/null is used. Signed-off-by: Giuseppe Scrivano --- src/conmon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conmon.c b/src/conmon.c index 0878ae5..2e0f23e 100644 --- a/src/conmon.c +++ b/src/conmon.c @@ -223,21 +223,21 @@ int main(int argc, char *argv[]) workerfd_stdin = dev_null_r; if (dup2(workerfd_stdin, STDIN_FILENO) < 0) _pexit("Failed to dup over stdin"); - if (fchmod(STDIN_FILENO, 0777) < 0) + if (workerfd_stdin != dev_null_r && fchmod(STDIN_FILENO, 0777) < 0) nwarn("Failed to chown stdin"); if (workerfd_stdout < 0) workerfd_stdout = dev_null_w; if (dup2(workerfd_stdout, STDOUT_FILENO) < 0) _pexit("Failed to dup over stdout"); - if (fchmod(STDOUT_FILENO, 0777) < 0) + if (workerfd_stdout != dev_null_w && fchmod(STDOUT_FILENO, 0777) < 0) nwarn("Failed to chown stdout"); if (workerfd_stderr < 0) workerfd_stderr = workerfd_stdout; if (dup2(workerfd_stderr, STDERR_FILENO) < 0) _pexit("Failed to dup over stderr"); - if (fchmod(STDERR_FILENO, 0777) < 0) + if (workerfd_stderr != dev_null_w && fchmod(STDERR_FILENO, 0777) < 0) nwarn("Failed to chown stderr"); /* If LISTEN_PID env is set, we need to set the LISTEN_PID