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
commitfd15a53c49ca01530665639f3711604c436601ee (patch)
tree452c73475f617631e23f13c4d176336939521ad7 /src/openvpn/misc.c
parentd42fbdd9d8dc05868a9ce749fb43a37e6b75b143 (diff)
parent41ffafc126abd9af67061f4931b7614f3cb898b0 (diff)
Merge tag 'upstream/2.3.8'
Upstream version 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))
{