In the case where we need to prompt the user for information, AND we're started at boot-time by init, we don't actually have a TTY to read from! So we fudge it by using /dev/console. --- apache_1.3.12-tty/mod_ssl-2.6.4-1.3.12/pkg.sslmod/ssl_engine_pphrase.c Thu Apr 27 15:08:49 2000 +++ apache_1.3.12-tty/mod_ssl-2.6.4-1.3.12/pkg.sslmod/ssl_engine_pphrase.c Thu Apr 27 15:08:49 2000 @@ -72,6 +72,7 @@ ** _________________________________________________________________ */ +#define STDOUT_FILENO_STORE 49 #define STDERR_FILENO_STORE 50 #define BUILTIN_DIALOG_BACKOFF 2 #define BUILTIN_DIALOG_RETRIES 5 @@ -401,6 +402,7 @@ int *pnPassPhraseDialogCur; BOOL *pbPassPhraseDialogOnce; int stderr_store; + int stdout_store; char **cpp; int len = -1; @@ -450,12 +452,22 @@ * to the general error logfile. */ #ifdef WIN32 + stdout_store = STDOUT_FILENO_STORE; stderr_store = STDERR_FILENO_STORE; + dup2(stdout_store, STDOUT_FILENO); + dup2(stderr_store, STDERR_FILENO); #else - if ((stderr_store = open("/dev/null", O_WRONLY)) == -1) - stderr_store = STDERR_FILENO_STORE; + stdout_store = dup(STDOUT_FILENO); + stderr_store = dup(STDERR_FILENO); + i = open("/dev/tty", O_WRONLY); + if(i == -1) { + i = open("/dev/console", O_WRONLY); + } + if(i != -1) { + dup2(i, STDOUT_FILENO); + dup2(i, STDERR_FILENO); + } #endif - dup2(STDERR_FILENO, stderr_store); #ifdef WIN32 if ((con = fopen("con", "w")) != NULL) dup2(fileno(con), STDERR_FILENO); @@ -472,7 +484,7 @@ * something... */ if (*pnPassPhraseDialog == 1) { - fprintf(stderr, "%s mod_ssl/%s (Pass Phrase Dialog)\n", + fprintf(stderr, "\n%s mod_ssl/%s (Pass Phrase Dialog)\n", SERVER_BASEVERSION, MOD_SSL_VERSION); fprintf(stderr, "Some of your private key files are encrypted for security reasons.\n"); fprintf(stderr, "In order to read them you have to provide us with the pass phrases.\n"); @@ -504,7 +516,9 @@ /* * Restore STDERR to Apache error logfile */ + dup2(stdout_store, STDOUT_FILENO); dup2(stderr_store, STDERR_FILENO); + close(stdout_store); close(stderr_store); #ifdef WIN32 if (con != NULL)