summaryrefslogtreecommitdiff
path: root/src/openvpn/misc.c
diff options
context:
space:
mode:
authorAlberto Gonzalez Iniesta <agi@inittab.org>2015-08-10 16:45:51 +0200
committerAlberto Gonzalez Iniesta <agi@inittab.org>2015-08-10 16:45:51 +0200
commit41ffafc126abd9af67061f4931b7614f3cb898b0 (patch)
tree6a46d6c8d05ba0acc9df8bffca98f99ffe7b74a8 /src/openvpn/misc.c
parent6149d88c5a2c58a9cc943ca02c36e8ee4e5d1751 (diff)
Imported Upstream version 2.3.8upstream/2.3.8
Diffstat (limited to 'src/openvpn/misc.c')
-rw-r--r--src/openvpn/misc.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index 8408438..f20d059 100644
--- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
@@ -127,30 +127,21 @@ run_up_down (const char *command,
gc_free (&gc);
}
-/* Get the file we will later write our process ID to */
+/* Write our PID to a file */
void
-get_pid_file (const char* filename, struct pid_state *state)
+write_pid (const char *filename)
{
- CLEAR (*state);
if (filename)
{
- state->fp = platform_fopen (filename, "w");
- if (!state->fp)
+ unsigned int pid = 0;
+ FILE *fp = platform_fopen (filename, "w");
+ if (!fp)
msg (M_ERR, "Open error on pid file %s", filename);
- state->filename = filename;
- }
-}
-/* Write our PID to a file */
-void
-write_pid (const struct pid_state *state)
-{
- if (state->filename && state->fp)
- {
- unsigned int pid = platform_getpid ();
- fprintf(state->fp, "%u\n", pid);
- if (fclose (state->fp))
- msg (M_ERR, "Close error on pid file %s", state->filename);
+ pid = platform_getpid ();
+ fprintf(fp, "%u\n", pid);
+ if (fclose (fp))
+ msg (M_ERR, "Close error on pid file %s", filename);
}
}
@@ -1097,6 +1088,12 @@ get_user_pass_cr (struct user_pass *up,
*/
else if (from_stdin)
{
+#ifndef WIN32
+ /* did we --daemon'ize before asking for passwords? */
+ if ( !isatty(0) && !isatty(2) )
+ { msg(M_FATAL, "neither stdin nor stderr are a tty device, can't ask for %s password. If you used --daemon, you need to use --askpass to make passphrase-protected keys work, and you can not use --auth-nocache.", prefix ); }
+#endif
+
#ifdef ENABLE_CLIENT_CR
if (auth_challenge && (flags & GET_USER_PASS_DYNAMIC_CHALLENGE))
{