Browse code

Fix using management interface to get passwords.

Commits da9b292733e929a2900dc32d37f0424c3d588366 and
315f6fbc7f657a7f1127628bd714f468709d5185 broke the use case where we are
asking password from the management client. The password is always asked
before daemonization. With this fix we avoid this and ask it via management
interface in the same spot as before the mentioned commits. Tested on Linux.

v2: This patch was first submitted by Christian Pellegrin (from Google),
and reworked by Steffan Karger (from the OpenVPN team) to also work for
setups with --management-query-passwords but without --auth-user-pass.

Signed-off-by: Steffan Karger <steffan@karger.me>
Signed-off-by: Christian Pellegrin <chripell@google.com>
Tested-by: Christian Pellegrin <chripell@google.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <55A6C46C.5080601@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9927
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Steffan Karger authored on 2015/07/16 05:13:52
Showing 1 changed files
... ...
@@ -229,8 +229,12 @@ openvpn_main (int argc, char *argv[])
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);
232
+	  /* Query passwords before becoming a daemon if we don't use the
233
+	   * management interface to get them. */
234
+#ifdef ENABLE_MANAGEMENT
235
+	  if (!(c.options.management_flags & MF_QUERY_PASSWORDS))
236
+#endif
237
+	    init_query_passwords (&c);
234 238
 
235 239
 	  /* become a daemon if --daemon */
236 240
 	  if (c.first_time)
... ...
@@ -243,6 +247,9 @@ openvpn_main (int argc, char *argv[])
243 243
 	  /* open management subsystem */
244 244
 	  if (!open_management (&c))
245 245
 	    break;
246
+	  /* query for passwords through management interface, if needed */
247
+	  if (c.options.management_flags & MF_QUERY_PASSWORDS)
248
+	    init_query_passwords (&c);
246 249
 #endif
247 250
 
248 251
 	  /* set certain options as environmental variables */