Browse code

fix regression: query password before becoming daemon

The init sequence was changed to daemonize before the crypto init to fix
issues on FreeBSD some commits ago. This introduced a regression where
we would no longer query for passwords before daemonizing, as described
in trac #574 and #576.

This commit restores the correct order, and adds a bit of const
correctness since we're touching this now code anyway.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1436477759-5884-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9901
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 315f6fbc7f657a7f1127628bd714f468709d5185)

Steffan Karger authored on 2015/07/10 06:35:59
Showing 3 changed files
... ...
@@ -389,8 +389,8 @@ next_connection_entry (struct context *c)
389 389
 /*
390 390
  * Query for private key and auth-user-pass username/passwords
391 391
  */
392
-static void
393
-init_query_passwords (struct context *c)
392
+void
393
+init_query_passwords (const struct context *c)
394 394
 {
395 395
 #if defined(ENABLE_CRYPTO) && defined(ENABLE_SSL)
396 396
   /* Certificate password input */
... ...
@@ -520,8 +520,6 @@ context_init_1 (struct context *c)
520 520
 
521 521
   init_connection_list (c);
522 522
 
523
-  init_query_passwords (c);
524
-
525 523
 #if defined(ENABLE_PKCS11)
526 524
   if (c->first_time) {
527 525
     int i;
... ...
@@ -63,6 +63,11 @@ void init_instance_handle_signals (struct context *c, const struct env_set *env,
63 63
 
64 64
 void init_instance (struct context *c, const struct env_set *env, const unsigned int flags);
65 65
 
66
+/**
67
+ * Query for private key and auth-user-pass username/passwords.
68
+ */
69
+void init_query_passwords (const struct context *c);
70
+
66 71
 void do_route (const struct options *options,
67 72
 	       struct route_list *route_list,
68 73
 	       struct route_ipv6_list *route_ipv6_list,
... ...
@@ -228,7 +228,10 @@ openvpn_main (int argc, char *argv[])
228 228
 	  /* test crypto? */
229 229
 	  if (do_test_crypto (&c.options))
230 230
 	    break;
231
-	  
231
+
232
+	  /* Query passwords before becoming a daemon */
233
+	  init_query_passwords (&c);
234
+
232 235
 	  /* become a daemon if --daemon */
233 236
 	  if (c.first_time)
234 237
 	    {