diff options
author | Werner Koch <[email protected]> | 2016-11-16 20:17:47 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-11-16 20:17:47 +0000 |
commit | 4839e6d002a8ad1f7d3260792c3c9641e258f342 (patch) | |
tree | a578efc00d6a60dc6ddc36372e41948b92a0d1a2 /scd/scdaemon.c | |
parent | common: Rename keybox_file_rename to gnupg_rename_file. (diff) | |
download | gnupg-4839e6d002a8ad1f7d3260792c3c9641e258f342.tar.gz gnupg-4839e6d002a8ad1f7d3260792c3c9641e258f342.zip |
scd,dirmngr: Keep the standard fds when daemonizing.
* dirmngr/dirmngr.c (main): Before calling setsid do not close the
standard fds but connect them to /dev/null.
* scd/scdaemon.c (main): Ditto. Noet that the old test for a log
stream was even reverted.
--
Note that this was fixed for gpg-agent 10 years ago on 2006-11-09.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'scd/scdaemon.c')
-rw-r--r-- | scd/scdaemon.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/scd/scdaemon.c b/scd/scdaemon.c index acc5b4772..064cae9cb 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -871,9 +871,19 @@ main (int argc, char **argv ) /* Close stdin, stdout and stderr unless it is the log stream. */ for (i=0; i <= 2; i++) { - if ( log_test_fd (i) && i != fd) - close (i); + if (!log_test_fd (i) && i != fd ) + { + if ( !close (i) + && open ("/dev/null", i? O_WRONLY : O_RDONLY) == -1) + { + log_error ("failed to open '%s': %s\n", + "/dev/null", strerror (errno)); + cleanup (); + exit (1); + } + } } + if (setsid() == -1) { log_error ("setsid() failed: %s\n", strerror(errno) ); |