Skip to contentSkip to conversation

Fix OpenVPN querying user/password if auth-token with user expires

PATCH Superseded Arne Schwabe 3 participants 7 messages Jul 22, 2021 – Jul 27, 2021

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix OpenVPN querying user/password if auth-token with user expires

The problematic behaviour happens when start a profile without auth-user-pass and connect to a server that pushes auth-token When the auth token expires OpenVPN asks for auth User and password again.

The problem is that the auth_user_pass_setup sets auth_user_pass_enabled = true; This function is called from two places. In ssl.c it is only called with an auth-token present or that variable already set. The other one is init_query_passwords.

Move setting auth_user_pass_enabled to the second place to ensure it is only set if we really want passwords.

---
 src/openvpn/init.c | 2 ++
 src/openvpn/ssl.c  | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
src/openvpn/init.c +2 -0
index a1401e805..f9083e69c 100644
@@ -595,6 +595,7 @@ init_query_passwords(const struct context *c)
     /* Auth user/pass input */
     if (c->options.auth_user_pass_file)
     {
+        auth_user_pass_enabled = true;
 #ifdef ENABLE_MANAGEMENT
         auth_user_pass_setup(c->options.auth_user_pass_file, &c->options.sc_info);
 #else
@@ -3116,6 +3117,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.auth_token_generate = options->auth_token_generate;
     to.auth_token_lifetime = options->auth_token_lifetime;
     to.auth_token_call_auth = options->auth_token_call_auth;
+    to.auth_token_user_common_name = options->auth_token_user_common_name;
     to.auth_token_key = c->c1.ks.auth_token_key;
 
     to.x509_track = options->x509_track;
src/openvpn/ssl.c +0 -1
index aa8cb3b27..c2dc36019 100644
@@ -396,7 +396,6 @@ static char *auth_challenge; /* GLOBAL */
 void
 auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *sci)
 {
-    auth_user_pass_enabled = true;
     if (!auth_user_pass.defined && !auth_token.defined)
     {
 #ifdef ENABLE_MANAGEMENT
Signature · 1 line
2.32.0
#1 lore raw

Hi,

src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 3123

Quoted 8 lines · Arne Schwabe
src/openvpn/init.c +1 -0
@@ -3116,6 +3117,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.auth_token_generate = options->auth_token_generate;
     to.auth_token_lifetime = options->auth_token_lifetime;
     to.auth_token_call_auth = options->auth_token_call_auth;
+    to.auth_token_user_common_name = options->auth_token_user_common_name;
     to.auth_token_key = c->c1.ks.auth_token_key;
 
     to.x509_track = options->x509_track;

That hunk looks unrelated...?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#2 lore raw

Am 23.07.21 um 08:40 schrieb Gert Doering:

Quoted 10 lines

Hi,

Quoted 7 lines · Arne Schwabe
src/openvpn/init.c +1 -0
@@ -3116,6 +3117,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.auth_token_generate = options->auth_token_generate;
     to.auth_token_lifetime = options->auth_token_lifetime;
     to.auth_token_call_auth = options->auth_token_call_auth;
+    to.auth_token_user_common_name = options->auth_token_user_common_name;
     to.auth_token_key = c->c1.ks.auth_token_key;
 
Quoted 6 lines

src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 3123

Quoted 1 line
src/openvpn/init.c +0 -0
     to.x509_track = options->x509_track;

That hunk looks unrelated...?

gert

Oops :/

Is there anything wrong or should I send a v2 just with that change?

Arne

#3 lore raw

Hi,

Quoted 9 lines · Arne Schwabe

Am 23.07.21 um 08:40 schrieb Gert Doering:

Quoted 8 lines · Arne Schwabe
Quoted 7 lines
src/openvpn/init.c +1 -0
@@ -3116,6 +3117,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.auth_token_generate = options->auth_token_generate;
     to.auth_token_lifetime = options->auth_token_lifetime;
     to.auth_token_call_auth = options->auth_token_call_auth;
+    to.auth_token_user_common_name = options->auth_token_user_common_name;
     to.auth_token_key = c->c1.ks.auth_token_key;
 
Quoted 7 lines
Quoted 4 lines

src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 3123

Quoted 1 line
src/openvpn/init.c +0 -0
     to.x509_track = options->x509_track;

That hunk looks unrelated...?

Oops :/

Is there anything wrong or should I send a v2 just with that change?

Well, current master does not have an "auth_token_user_common_name" structure element anyway, so the introduction of it should not be part of this bugfix (and it wouldn't compile) :-)

So, "v2, *without* that change" sounds like a plan.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#4 lore raw

PATCH v2 1/1 Fix OpenVPN querying user/password if auth-token with user expires

In reply to Arne Schwabe

The problematic behaviour happens when start a profile without auth-user-pass and connect to a server that pushes auth-token When the auth token expires OpenVPN asks for auth User and password again.

The problem is that the auth_user_pass_setup sets auth_user_pass_enabled = true; This function is called from two places. In ssl.c it is only called with an auth-token present or that variable already set. The other one is init_query_passwords.

Move setting auth_user_pass_enabled to the second place to ensure it is only set if we really want passwords.

Patch V2: Remove unrelated code change

---
 src/openvpn/init.c | 1 +
 src/openvpn/ssl.c  | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
src/openvpn/init.c +1 -0
index a1401e805..d5d192663 100644
@@ -595,6 +595,7 @@ init_query_passwords(const struct context *c)
     /* Auth user/pass input */
     if (c->options.auth_user_pass_file)
     {
+        auth_user_pass_enabled = true;
 #ifdef ENABLE_MANAGEMENT
         auth_user_pass_setup(c->options.auth_user_pass_file, &c->options.sc_info);
 #else
src/openvpn/ssl.c +0 -1
index aa8cb3b27..c2dc36019 100644
@@ -396,7 +396,6 @@ static char *auth_challenge; /* GLOBAL */
 void
 auth_user_pass_setup(const char *auth_file, const struct static_challenge_info *sci)
 {
-    auth_user_pass_enabled = true;
     if (!auth_user_pass.defined && !auth_token.defined)
     {
 #ifdef ENABLE_MANAGEMENT
Signature · 1 line
2.32.0
#5 lore raw
In reply to Arne Schwabe

Hi,

Quoted 22 lines · Arne Schwabe

The problematic behaviour happens when start a profile without auth-user-pass and connect to a server that pushes auth-token When the auth token expires OpenVPN asks for auth User and password again.

The problem is that the auth_user_pass_setup sets auth_user_pass_enabled = true; This function is called from two places. In ssl.c it is only called with an auth-token present or that variable already set. The other one is init_query_passwords.

Move setting auth_user_pass_enabled to the second place to ensure it is only set if we really want passwords.

---
 src/openvpn/init.c | 2 ++
 src/openvpn/ssl.c  | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
src/openvpn/init.c +0 -0
index a1401e805..f9083e69c 100644

src/openvpn/init.c init_query_passwords(const struct context *c) · line 600

Quoted 6 lines
src/openvpn/init.c +1 -0
@@ -595,6 +595,7 @@ init_query_passwords(const struct context *c)
     /* Auth user/pass input */
     if (c->options.auth_user_pass_file)
     {
+        auth_user_pass_enabled = true;
 #ifdef ENABLE_MANAGEMENT
         auth_user_pass_setup(c->options.auth_user_pass_file, &c->options.sc_info);

init.c: In function ‘init_query_passwords’:
init.c:597:9: error: ‘auth_user_pass_enabled’ undeclared (first use in this function); did you mean ‘auth_user_pass_setup’?

  597 |         auth_user_pass_enabled = true;
      |         ^~~~~~~~~~~~~~~~~~~~~~
      |         auth_user_pass_setup

anything wrong with my master branch?

Signature · 1 line
Antonio Quartulli
#6 lore raw

Hi,

Quoted 35 lines · Antonio Quartulli

Hi,

Quoted 22 lines · Arne Schwabe

The problematic behaviour happens when start a profile without auth-user-pass and connect to a server that pushes auth-token When the auth token expires OpenVPN asks for auth User and password again.

The problem is that the auth_user_pass_setup sets auth_user_pass_enabled = true; This function is called from two places. In ssl.c it is only called with an auth-token present or that variable already set. The other one is init_query_passwords.

Move setting auth_user_pass_enabled to the second place to ensure it is only set if we really want passwords.

---
 src/openvpn/init.c | 2 ++
 src/openvpn/ssl.c  | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
src/openvpn/init.c +0 -0
index a1401e805..f9083e69c 100644

src/openvpn/init.c init_query_passwords(const struct context *c) · line 600

Quoted 6 lines
src/openvpn/init.c +1 -0
@@ -595,6 +595,7 @@ init_query_passwords(const struct context *c)
     /* Auth user/pass input */
     if (c->options.auth_user_pass_file)
     {
+        auth_user_pass_enabled = true;
 #ifdef ENABLE_MANAGEMENT
         auth_user_pass_setup(c->options.auth_user_pass_file, &c->options.sc_info);

init.c: In function ‘init_query_passwords’:
init.c:597:9: error: ‘auth_user_pass_enabled’ undeclared (first use in this function); did you mean ‘auth_user_pass_setup’?

Quoted 6 lines
  597 |         auth_user_pass_enabled = true;
      |         ^~~~~~~~~~~~~~~~~~~~~~
      |         auth_user_pass_setup

anything wrong with my master branch?

this reply was meant for PATCHv2.

Cheers,

Quoted 3 lines
Signature · 1 line
Antonio Quartulli