Browse code

reload HTTP proxy credentials when moving to the next connection profile

The HTTP proxy credentials are stored in a static variable that is
possibly initialized before each connection attempt.

However, the variable is never "released" therefore get_user_pass()
refuses to overwrite its content and leaves it as it is.
Consequently, if the user config contains multiple connection profiles
with different http-proxy, each having its own credentials, only the
first user/pass couple is loaded and the others are all ignored.
This leads to connection failures because the proper credentials are
not associated with the right proxy server.

The root of the misbehaviour seems to be located in the fact that,
despite the argument force passed to get_user_pass_http() being true,
no action is taken to release the static object containing the
credentials.

Fix the misbehaviour by releasing the http-proxy credential object
when the reload is "forced".

Trac: #836
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan@karger.me>
Tested-by: David Sommerseth <davids@openvpn.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171204044907.32261-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16007.html
Signed-off-by: David Sommerseth <davids@openvpn.net>

Antonio Quartulli authored on 2017/12/04 13:49:07
Showing 1 changed files
... ...
@@ -253,9 +253,24 @@ username_password_as_base64(const struct http_proxy_info *p,
253 253
 }
254 254
 
255 255
 static void
256
+clear_user_pass_http(void)
257
+{
258
+    purge_user_pass(&static_proxy_user_pass, true);
259
+}
260
+
261
+static void
256 262
 get_user_pass_http(struct http_proxy_info *p, const bool force)
257 263
 {
258
-    if (!static_proxy_user_pass.defined || force)
264
+    /*
265
+     * in case of forced (re)load, make sure the static storage is set as
266
+     * undefined, otherwise get_user_pass() won't try to load any credential
267
+     */
268
+    if (force)
269
+    {
270
+        clear_user_pass_http();
271
+    }
272
+
273
+    if (!static_proxy_user_pass.defined)
259 274
     {
260 275
         unsigned int flags = GET_USER_PASS_MANAGEMENT;
261 276
         if (p->queried_creds)
... ...
@@ -274,11 +289,6 @@ get_user_pass_http(struct http_proxy_info *p, const bool force)
274 274
         p->up = static_proxy_user_pass;
275 275
     }
276 276
 }
277
-static void
278
-clear_user_pass_http(void)
279
-{
280
-    purge_user_pass(&static_proxy_user_pass, true);
281
-}
282 277
 
283 278
 #if 0
284 279
 /* function only used in #if 0 debug statement */