From 6f6f6ffc410631ccfc29d27945d079ed532352a3 Mon Sep 17 00:00:00 2001 From: Raul Gutierrez Segales Date: Sat, 27 Oct 2012 22:29:27 -0700 Subject: [PATCH] [shrpx] fix password handling for certs keys We should only call daemon() after ListenHandler is instantiated, where SSL_CTX_use_PrivateKey_file is called, otherwise we have no stdin/stdout to get the password for keyfile. --- src/shrpx.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/shrpx.cc b/src/shrpx.cc index 62a6259c..a705137d 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -230,6 +230,13 @@ int event_loop() ListenHandler *listener_handler = new ListenHandler(evbase); + if(get_config()->daemon) { + if(daemon(0, 0) == -1) { + LOG(FATAL) << "Failed to daemonize: " << strerror(errno); + exit(EXIT_FAILURE); + } + } + // ListenHandler loads private key. After that, we drop the root // privileges if needed. drop_privileges(); @@ -648,12 +655,6 @@ int main(int argc, char **argv) mod_config()->use_syslog = true; } - if(get_config()->daemon) { - if(daemon(0, 0) == -1) { - LOG(FATAL) << "Failed to daemonize: " << strerror(errno); - exit(EXIT_FAILURE); - } - } if(get_config()->pid_file) { save_pid(); }