From: "selvanair (Code Review)" Date: Mon, 2 Mar 2026 20:24:06 +0000 In-Reply-To: References: Reply-To: selva.nair@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <23f1f49f0808ec279ab1935e50c0481e80635716-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="eP8s0nRSPQ8="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Add an optional username-only flag for auth-user-pass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: flichtenheld , openvpn-devel --eP8s0nRSPQ8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos, selvanair. Hello plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1548?usp=3Demail to look at the new patch set (#6). The following approvals got outdated and were removed: Code-Review+2 by plaisthos The change is no longer submittable: Code-Review and checks~ChecksSubmitRul= e are unsatisfied now. Change subject: Add an optional username-only flag for auth-user-pass ...................................................................... Add an optional username-only flag for auth-user-pass Specify "--auth-user-pass username-only" for openvpn to prompt for only username, not password. Prompt via management interface uses the usual ">PASSWORD 'Auth' " prompt with type "username" instead of "username/password". Internally, the password gets set as "[[BLANK]]" which is currently used as tag for blank password. Not compatible with --static-challenge or when username and password are inlined or read from a file. In such cases, the user hard-code a dummy password in the file instead. Change-Id: I788f76e6a70a9c20bca3367140d2741bd0551582 Signed-off-by: Selva Nair --- M doc/man-sections/client-options.rst M doc/management-notes.txt M src/openvpn/init.c M src/openvpn/manage.c M src/openvpn/manage.h M src/openvpn/misc.c M src/openvpn/misc.h M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/ssl.c M src/openvpn/ssl.h M src/openvpn/ssl_common.h 12 files changed, 90 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/48/1548/6 diff --git a/doc/man-sections/client-options.rst b/doc/man-sections/client-= options.rst index b9ae7ce..0b7c308 100644 --- a/doc/man-sections/client-options.rst +++ b/doc/man-sections/client-options.rst @@ -68,7 +68,9 @@ auth-user-pass up If ``up`` is present, it must be a file containing username/password on 2 - lines. If the password line is missing, OpenVPN will prompt for one. + lines or a flag named :code:`username-only` to indicate no password + should be prompted for. In the former case, if the password line is miss= ing + in the file, OpenVPN will prompt for one. If ``up`` is omitted, username/password will be prompted from the console. @@ -84,6 +86,20 @@ where password is optional, and will be prompted from the console if missing. + The :code:`username-only` flag is meant to be used with SSO authenticati= on. + In this case the user will be asked for a username but not password. Ins= tead, + a dummy password :code:`[[BLANK]]` is generated internally and submitted= to + the server. See management-notes.txt for how this option affects usernam= e/password + prompt via the management interface. For the console, it simply eliminat= es + the password prompt. + + The :code:`username-only` flag cannot be used along with embedding usern= ame and/or + password in the config file, or while reading them from an external file= . In + such cases, if only username is relevant and no password prompt is desir= ed, a + dummy password like 'no_passsword' should be embedded as well. This flag= is also + incompatible with the ``--static-challenge`` option and legacy ``dynamic= challenge`` + protocol. + The server configuration must specify an ``--auth-user-pass-verify`` script to verify the username/password provided by the client. diff --git a/doc/management-notes.txt b/doc/management-notes.txt index 86b74f3..500feaf 100644 --- a/doc/management-notes.txt +++ b/doc/management-notes.txt @@ -304,6 +304,19 @@ username "Auth" foo password "Auth" bar + Example 3: + + >PASSWORD:Need 'Auth' username + + OpenVPN needs a --auth-user-pass username. The + management interface client should respond: + + username "Auth" foo + + In this case the user should not be prompted for a password. + Support for such username-only prompting is conditional on the + client announcing a version >=3D 4. + The username/password itself can be in quotes, and special characters such as double quote or backslash must be escaped, for example, diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 1391aa85..4948b8d 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -655,10 +655,10 @@ enable_auth_user_pass(); #ifdef ENABLE_MANAGEMENT auth_user_pass_setup(c->options.auth_user_pass_file, c->options.au= th_user_pass_file_inline, - &c->options.sc_info); + c->options.auth_user_pass_username_only, &c->= options.sc_info); #else auth_user_pass_setup(c->options.auth_user_pass_file, c->options.au= th_user_pass_file_inline, - NULL); + c->options.auth_user_pass_username_only, NULL= ); #endif } } @@ -3376,6 +3376,7 @@ } to.auth_user_pass_file =3D options->auth_user_pass_file; to.auth_user_pass_file_inline =3D options->auth_user_pass_file_inline; + to.auth_user_pass_username_only =3D options->auth_user_pass_username_o= nly; to.auth_token_generate =3D options->auth_token_generate; to.auth_token_lifetime =3D options->auth_token_lifetime; to.auth_token_renewal =3D options->auth_token_renewal; diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 03ff5b3..91b5884 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -58,9 +58,6 @@ #define MANAGEMENT_ECHO_FLAGS 0 #endif -/* tag for blank username/password */ -static const char blank_up[] =3D "[[BLANK]]"; - struct management *management; /* GLOBAL */ /* static forward declarations */ @@ -729,6 +726,13 @@ { switch (man->connection.up_query_mode) { + case UP_QUERY_USERNAME: + if (strlen(man->connection.up_query.username)) + { + man->connection.up_query.defined =3D true; + } + break; + case UP_QUERY_USER_PASS: if (!strlen(man->connection.up_query.username)) { @@ -783,7 +787,9 @@ man_query_username(struct management *man, const char *type, const char *s= tring) { const bool needed =3D - ((man->connection.up_query_mode =3D=3D UP_QUERY_USER_PASS) && man-= >connection.up_query_type); + ((man->connection.up_query_mode =3D=3D UP_QUERY_USER_PASS + || man->connection.up_query_mode =3D=3D UP_QUERY_USERNAME) + && man->connection.up_query_type); man_query_user_pass(man, type, string, needed, "username", man->connec= tion.up_query.username, USER_PASS_LEN); } @@ -3547,6 +3553,12 @@ prefix =3D "PASSWORD"; alert_type =3D "password"; } + else if ((man->connection.client_version >=3D 4) && (flags & GET_U= SER_PASS_USERNAME_ONLY)) + { + up_query_mode =3D UP_QUERY_USERNAME; + prefix =3D "PASSWORD"; + alert_type =3D "username"; + } else { up_query_mode =3D UP_QUERY_USER_PASS; diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 38f437f..e5ad23f 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -264,6 +264,7 @@ #define UP_QUERY_PASS 2 #define UP_QUERY_NEED_OK 3 #define UP_QUERY_NEED_STR 4 +#define UP_QUERY_USERNAME 5 /* states */ #define MS_INITIAL 0 /* all sockets are closed */ diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 9ff281c..8f687a8 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -216,6 +216,12 @@ msg(M_WARN, "Note: previous '%s' credentials failed", prefix); } + /* Use tag for blank password if we are not prompting for one */ + if (flags & GET_USER_PASS_USERNAME_ONLY) + { + strncpy(up->password, blank_up, sizeof(up->password)); + } + #ifdef ENABLE_MANAGEMENT /* * Get username/password from management interface? @@ -389,7 +395,7 @@ query_user_add(BSTR(&user_prompt), up->username, USER_= PASS_LEN, true); } - if (password_from_stdin) + if (password_from_stdin && !(flags & GET_USER_PASS_USERNAM= E_ONLY)) { query_user_add(BSTR(&pass_prompt), up->password, USER_= PASS_LEN, false); } diff --git a/src/openvpn/misc.h b/src/openvpn/misc.h index e9cfadb..76bcac3 100644 --- a/src/openvpn/misc.h +++ b/src/openvpn/misc.h @@ -48,6 +48,9 @@ * Get and store a username/password */ +/* tag for blank username/password */ +static const char blank_up[] =3D "[[BLANK]]"; + struct user_pass { bool defined; @@ -123,6 +126,8 @@ #define GET_USER_PASS_INLINE_CREDS (1 << 10) /** indicates password and response should be concatenated */ #define GET_USER_PASS_STATIC_CHALLENGE_CONCAT (1 << 11) +/** indicate that only username should be prompted for auth-user-pass */ +#define GET_USER_PASS_USERNAME_ONLY (1 << 12) =20 /** * Retrieves the user credentials from various sources depending on the fl= ags. diff --git a/src/openvpn/options.c b/src/openvpn/options.c index fdbc678..d266c3e 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -510,7 +510,8 @@ " up is a file containing the username on the first l= ine,\n" " and a password on the second. If either the passwor= d or both\n" " the username and the password are omitted OpenVPN w= ill prompt\n" - " for them from console.\n" + " for them from console. If [up] is 'username-only', = only username\n" + " will be prompted for from console or management int= erface.\n" "--pull : Accept certain config file options from the peer a= s if they\n" " were part of the local config file. Must be specif= ied\n" " when connecting to a '--mode server' remote host.\n" @@ -3909,6 +3910,12 @@ { o->auth_token_renewal =3D o->renegotiate_seconds; } +#if ENABLE_MANAGEMENT + if (o->auth_user_pass_username_only && o->sc_info.challenge_text) + { + msg(M_USAGE, "'auth-user-pass username-only' cannot be used with s= tatic challenge"); + } +#endif pre_connect_save(o); } =20 @@ -7705,7 +7712,13 @@ else if (streq(p[0], "auth-user-pass") && !p[2]) { VERIFY_PERMISSION(OPT_P_GENERAL | OPT_P_INLINE); - if (p[1]) + options->auth_user_pass_username_only =3D false; + if (p[1] && streq(p[1], "username-only")) + { + options->auth_user_pass_username_only =3D true; + options->auth_user_pass_file =3D "stdin"; + } + else if (p[1]) { options->auth_user_pass_file =3D p[1]; options->auth_user_pass_file_inline =3D is_inline; diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 3d8b505..f4a36fc 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -557,6 +557,7 @@ unsigned int push_update_options_found; /* tracks which option types h= ave been reset in current PUSH_UPDATE sequence */ const char *auth_user_pass_file; bool auth_user_pass_file_inline; + bool auth_user_pass_username_only; struct options_pre_connect *pre_connect; int scheduled_exit_interval; diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 69d0e4e..962f5df 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -290,7 +290,8 @@ } void -auth_user_pass_setup(const char *auth_file, bool is_inline, const struct s= tatic_challenge_info *sci) +auth_user_pass_setup(const char *auth_file, bool is_inline, bool username_= only, + const struct static_challenge_info *sci) { unsigned int flags =3D GET_USER_PASS_MANAGEMENT; @@ -298,6 +299,10 @@ { flags |=3D GET_USER_PASS_INLINE_CREDS; } + if (username_only) + { + flags |=3D GET_USER_PASS_USERNAME_ONLY; + } if (!auth_user_pass.defined && !auth_token.defined) { @@ -2099,10 +2104,12 @@ { #ifdef ENABLE_MANAGEMENT auth_user_pass_setup(session->opt->auth_user_pass_file, - session->opt->auth_user_pass_file_inline, ses= sion->opt->sci); + session->opt->auth_user_pass_file_inline, + session->opt->auth_user_pass_username_only, s= ession->opt->sci); #else auth_user_pass_setup(session->opt->auth_user_pass_file, - session->opt->auth_user_pass_file_inline, NUL= L); + session->opt->auth_user_pass_file_inline, + session->opt->auth_user_pass_username_only, N= ULL); #endif struct user_pass *up =3D &auth_user_pass; diff --git a/src/openvpn/ssl.h b/src/openvpn/ssl.h index 28a3b78..5822336 100644 --- a/src/openvpn/ssl.h +++ b/src/openvpn/ssl.h @@ -389,7 +389,7 @@ * credentials stored in the file, however, if is_inline is true then auth= _file * contains the username/password inline. */ -void auth_user_pass_setup(const char *auth_file, bool is_inline, +void auth_user_pass_setup(const char *auth_file, bool is_inline, bool user= name_only, const struct static_challenge_info *sc_info); /* diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index fba01bb..6f310a5 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -396,6 +396,7 @@ const char *export_peer_cert_dir; const char *auth_user_pass_file; bool auth_user_pass_file_inline; + bool auth_user_pass_username_only; bool auth_token_generate; /**< Generate auth-tokens on successful * user/pass auth,seet via -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1548?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I788f76e6a70a9c20bca3367140d2741bd0551582 Gerrit-Change-Number: 1548 Gerrit-PatchSet: 6 Gerrit-Owner: selvanair Gerrit-Reviewer: plaisthos Gerrit-CC: cron2 Gerrit-CC: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: selvanair --eP8s0nRSPQ8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos, selvanair.

selvanair uploaded patch set #6 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1548?usp=3Demail">View Chan= ge

The following approvals got outdated and were removed: Code-Review+2 by plaisthos

The change is no longer submittable: Code-= Review and checks~ChecksSubmitRule are unsatisfied now.

Ad=
d an optional username-only flag for auth-user-pass

Specify "--= auth-user-pass username-only" for openvpn to prompt
for only userna= me, not password. Prompt via management interface
uses the usual "&= gt;PASSWORD 'Auth' " prompt with type "username"
= instead of "username/password".

Internally, the password g= ets set as "[[BLANK]]" which is currently
used as tag for blan= k password.

Not compatible with --static-challenge or when username = and
password are inlined or read from a file. In such cases, the userhard-code a dummy password in the file instead.

Change-Id: I788f76e= 6a70a9c20bca3367140d2741bd0551582
Signed-off-by: Selva Nair <selva.na= ir@...277...>
---
M doc/man-sections/client-options.rst
M doc/m= anagement-notes.txt
M src/openvpn/init.c
M src/openvpn/manage.c
M = src/openvpn/manage.h
M src/openvpn/misc.c
M src/openvpn/misc.h
M s= rc/openvpn/options.c
M src/openvpn/options.h
M src/openvpn/ssl.c
M= src/openvpn/ssl.h
M src/openvpn/ssl_common.h
12 files changed, 90 in= sertions(+), 14 deletions(-)

git pull ssh://gerr=
it.openvpn.net:29418/openvpn refs/changes/48/1548/6
diff --git a/do=
c/man-sections/client-options.rst b/doc/man-sections/client-options.rst
index b9ae7ce..0b7c308 100644
--- a/doc/man-se= ctions/client-options.rst
+++ b/doc/man-sections/client-opt= ions.rst
@@ -68,7 +68,9 @@
auth-user= -pass up

If ``up`` is present, it must= be a file containing username/password on 2
- lines. If the password line is missing, OpenVPN wi= ll prompt for one.
+ = lines or a flag named :code:`username-only` to indicate no password=
+ should be prompted for. = In the former case, if the password line is missing
+ in the file, OpenVPN will prompt for on= e.

If ``up`` is omitted, username/pass= word will be prompted from the
console.
= @@ -84,6 +86,20 @@
where password is optional, and will = be prompted from the console if
missing.

+ The :code:`user= name-only` flag is meant to be used with SSO authentication.
+ In this case the user will be as= ked for a username but not password. Instead,
+ a dummy password :code:`[[BLANK]]` is generated= internally and submitted to
+ the server. See management-notes.txt for how this option affects= username/password
+ = prompt via the management interface. For the console, it simply eliminates=
+ the password prom= pt.
+
+ The :code:`username-only` flag ca= nnot be used along with embedding username and/or
+ password in the config file, or while readi= ng them from an external file. In
+ such cases, if only username is relevant and no password pr= ompt is desired, a
+ = dummy password like 'no_passsword' should be embedded as well. Thi= s flag is also
+ inc= ompatible with the ``--static-challenge`` option and legacy ``dynamic chall= enge``
+ protocol.
+
T= he server configuration must specify an ``--auth-user-pass-verify``<= br> script to verify the username/password provided by the client.<= /span>

diff --git a/doc/management-notes.txt b/d= oc/management-notes.txt
index 86b74f3..500feaf 100644

--- a/doc/management-notes.txt
+++ b/doc/managem= ent-notes.txt
@@ -304,6 +304,19 @@
use= rname "Auth" foo
password "Auth" b= ar

= + Example 3:
+
+ >PASSWORD:Need = 9;Auth' username
= +
+ OpenVPN needs a = --auth-user-pass username. The
+ management interface client should respond:
+
+ username "Auth" foo
+
+ In this case the user should not be prompted for a passwor= d.
+ Support for suc= h username-only prompting is conditional on the
+ client announcing a version >=3D 4.=
+
The us= ername/password itself can be in quotes, and special
cha= racters such as double quote or backslash must be escaped,
= for example,
diff --git a/src/openvpn/init.c b/src/openv= pn/init.c
index 1391aa85..4948b8d 100644
--= - a/src/openvpn/init.c
+++ b/src/openvpn/init.c
<= span>@@ -655,10 +655,10 @@

enable_auth_user_pass()= ;
#ifdef ENABLE_MANAGEMENT
auth_u= ser_pass_setup(c->options.auth_user_pass_file, c->options.auth_user_p= ass_file_inline,
- = &c->options.sc_info);
+ c->option= s.auth_user_pass_username_only, &c->options.sc_info);
#else
auth_user_pass_setup(c->options.auth_u= ser_pass_file, c->options.auth_user_pass_file_inline,
- NULL);

+ = c->options.auth_user_pass_username_only, NULL);
#e= ndif
}
}
@@ -3376,6 += 3376,7 @@
}
to.auth_user_pass_fil= e =3D options->auth_user_pass_file;
to.auth_user_pa= ss_file_inline =3D options->auth_user_pass_file_inline;
+ to.auth_user_pass_username_only = =3D options->auth_user_pass_username_only;
to.auth_= token_generate =3D options->auth_token_generate;
to= .auth_token_lifetime =3D options->auth_token_lifetime;
= to.auth_token_renewal =3D options->auth_token_renewal;
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 03ff5b3..91b5884 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -58,9 +58,6 @@=
#define MANAGEMENT_ECHO_FLAGS 0
#endif

-/* ta= g for blank username/password */
-static const char blank_up[] =3D "[[BLANK]]";-
struct manag= ement *management; /* GLOBAL */

/* stati= c forward declarations */
@@ -729,6 +726,13 @@
{

switch (man->connection.up_query_mode)

{
+ = case UP_QUERY_USERNAME:
+ if (strlen(man->connection.up_query.username))

+ {+ man->conne= ction.up_query.defined =3D true;
+ }
+ break;
+
case UP_QUERY_USER_PASS:
= if (!strlen(man->connection.up_query.username))
{
@@ -783,7 +787,9 @@
man_= query_username(struct management *man, const char *type, const char *string= )
{
const bool needed =3D
<= span style=3D"color: hsl(0, 100%, 40%);">- ((man->connection.up_q= uery_mode =3D=3D UP_QUERY_USER_PASS) && man->connection.up_query= _type);
+ ((ma= n->connection.up_query_mode =3D=3D UP_QUERY_USER_PASS
+ || man->connection.up_que= ry_mode =3D=3D UP_QUERY_USERNAME)
+ && man->connection.up_query_type);=
man_query_user_pass(man, type, string, needed, "usernam= e", man->connection.up_query.username,
= USER_PASS_LEN);
}
@@ -3547,6 = +3553,12 @@
prefix =3D "PASSWORD";
alert_type =3D "password";
= }
+ = else if ((man->connection.client_version >=3D 4) && (fla= gs & GET_USER_PASS_USERNAME_ONLY))
+ {
+ up_query_mode =3D UP_QUERY_USERNAME;
+ prefix =3D "PASSWORD= ";
+ = alert_type =3D "username";
+ }
else
= {
up_query_mode =3D UP_QUERY_USER_PASS;=
diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h
index 38f437f..e5ad23f 100644
--- a/src/open= vpn/manage.h
+++ b/src/openvpn/manage.h
@@ = -264,6 +264,7 @@
#define UP_QUERY_PASS 2
#define UP_QUERY_NEED_OK 3

#define UP_QUERY_NEED_ST= R 4
+#define UP_QUER= Y_USERNAME 5

/* states */
#define MS_INITIAL 0 /* all sockets are closed */

diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index= 9ff281c..8f687a8 100644
--- a/src/openvpn/misc.c+++ b/src/openvpn/misc.c
@@ -216,6 +216,12 @@=
msg(M_WARN, "Note: previous '%s' creden= tials failed", prefix);
}

+ /* Use tag fo= r blank password if we are not prompting for one */
+ if (flags & GET_USER_PASS_USE= RNAME_ONLY)
+ = {
+ strncp= y(up->password, blank_up, sizeof(up->password));
+ }
+
#ifdef ENABLE_MANAGEMENT<= br> /*
* Get username/password from= management interface?
@@ -389,7 +395,7 @@
= query_user_add(BSTR(&user_prompt), up->username= , USER_PASS_LEN, true);
}
=
- if (= password_from_stdin)
= + if (password_from_stdin && !(flags & GET_USER_= PASS_USERNAME_ONLY))
{
= query_user_add(BSTR(&pass_prompt), up->password, U= SER_PASS_LEN, false);
}
di= ff --git a/src/openvpn/misc.h b/src/openvpn/misc.h
index e9= cfadb..76bcac3 100644
--- a/src/openvpn/misc.h
+++ b/src/openvpn/misc.h

@@ -48,6 +48,9 @@
* Get and store a username/password
*/

+/* tag for bla= nk username/password */
+static const char blank_up[] =3D "[[BLANK]]";
+
struct user_pass<= /span>
{
bool defined;
@@ -1= 23,6 +126,8 @@
#define GET_USER_PASS_INLINE_CREDS = (1 << 10)
/** indicates password and response sho= uld be concatenated */
#define GET_USER_PASS_STATIC_CHALLE= NGE_CONCAT (1 << 11)
+/** indicate that only username should be prompted for auth-user-pas= s */
+#define GET_USE= R_PASS_USERNAME_ONLY (1 << 12)

= /**
* Retrieves the user credentials from various = sources depending on the flags.
diff --git a/src/openvpn/op= tions.c b/src/openvpn/options.c
index fdbc678..d266c3e 1006= 44
--- a/src/openvpn/options.c
+++ b/src/op= envpn/options.c
@@ -510,7 +510,8 @@
&q= uot; up is a file containing the username on the first lin= e,\n"
" and a password on t= he second. If either the password or both\n"
&quo= t; the username and the password are omitted OpenVPN will = prompt\n"
- &qu= ot; for them from console.\n"
+ " for them from= console. If [up] is 'username-only', only username\n"<= br>+ " = will be prompted for from console or management interface.\n"<= br> "--pull : Accept certain config file options f= rom the peer as if they\n"
" = were part of the local config file. Must be specified\n"
= " when connecting to a '--mode server&= #39; remote host.\n"
@@ -3909,6 +3910,12 @@
= {
o->auth_token_renewal =3D o->re= negotiate_seconds;
}
+#if ENABLE_MANAGEMENT
+ if (o->auth_user_pass_username_only &&am= p; o->sc_info.challenge_text)
+ {
+ = msg(M_USAGE, "'auth-user-pass username-only' cannot be = used with static challenge");
+ }
= +#endif
pre_connect_save(o);
}=

@@ -7705,7 +7712,13 @@
els= e if (streq(p[0], "auth-user-pass") && !p[2])
<= span> {

VERIFY_PERMISSION(OPT_P_GENERAL | OPT_= P_INLINE);
- if = (p[1])
+ optio= ns->auth_user_pass_username_only =3D false;
+ if (p[1] && streq(p[1], "us= ername-only"))
+= {
+ = options->auth_user_pass_username_only =3D true;
+ options->auth_user_pass_fi= le =3D "stdin";
+ }
+ = else if (p[1])
{
= options->auth_user_pass_file =3D p[1];
opti= ons->auth_user_pass_file_inline =3D is_inline;
diff --gi= t a/src/openvpn/options.h b/src/openvpn/options.h
index 3d8= b505..f4a36fc 100644
--- a/src/openvpn/options.h
= +++ b/src/openvpn/options.h
@@ -557,6 +557,7 @@

unsigned int push_update_options_found; /* tracks which opt= ion types have been reset in current PUSH_UPDATE sequence */
const char *auth_user_pass_file;
bool auth_user= _pass_file_inline;
+ = bool auth_user_pass_username_only;
struct options_p= re_connect *pre_connect;

int schedul= ed_exit_interval;
diff --git a/src/openvpn/ssl.c b/src/open= vpn/ssl.c
index 69d0e4e..962f5df 100644
---= a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -290,7 +290,8 @@
}

= void
-auth_user_pass_s= etup(const char *auth_file, bool is_inline, const struct static_challenge_i= nfo *sci)
+auth_user_= pass_setup(const char *auth_file, bool is_inline, bool username_only,

+ cons= t struct static_challenge_info *sci)
{
= unsigned int flags =3D GET_USER_PASS_MANAGEMENT;
=
@@ -298,6 +299,10 @@
{
= flags |=3D GET_USER_PASS_INLINE_CREDS;
}+ if (username_only)=
+ {
+ flags |=3D GET_USER_PASS_USERNAM= E_ONLY;
+ }=

if (!auth_user_pass.defined && !au= th_token.defined)
{
@@ -2099,10 +2104,= 12 @@
{
#ifdef ENABLE_MANAGEMENT

auth_user_pass_setup(session->opt->auth_user_pas= s_file,
- = session->opt->auth_user_pass_file_inline, session->= opt->sci);
+ = session->opt->auth_user_pass_file_inline,
+ = session->opt->auth_user_pass_username_only, session->opt->= sci);
#else
auth_user_pass_setup(= session->opt->auth_user_pass_file,
- session->opt->auth_us= er_pass_file_inline, NULL);
+ session->opt->auth_user_pass_fil= e_inline,
+ = session->opt->auth_user_pass_username_only, NULL);=
#endif
struct user_pass *up =3D = &auth_user_pass;

diff --git a/src/ope= nvpn/ssl.h b/src/openvpn/ssl.h
index 28a3b78..5822336 10064= 4
--- a/src/openvpn/ssl.h
+++ b/src/openvpn= /ssl.h
@@ -389,7 +389,7 @@
* credentials = stored in the file, however, if is_inline is true then auth_file
= * contains the username/password inline.
*/
-void auth_user_pass_setup(c= onst char *auth_file, bool is_inline,
+void auth_user_pass_setup(const char *auth_file, bool is_= inline, bool username_only,
cons= t struct static_challenge_info *sc_info);

/*

diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ss= l_common.h
index fba01bb..6f310a5 100644
--= - a/src/openvpn/ssl_common.h
+++ b/src/openvpn/ssl_common.h=
@@ -396,6 +396,7 @@
const char *expor= t_peer_cert_dir;
const char *auth_user_pass_file;
bool auth_user_pass_file_inline;
+ bool auth_user_pass_username_only;=

bool auth_token_generate; /**< Generat= e auth-tokens on successful
= * user/pass auth,seet via

To view, vi= sit chan= ge 1548. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I788f76e6a70a9c20bca3367140d= 2741bd0551582
Gerrit-Change-Number: 1548
Gerrit-PatchSet: 6
Gerrit-Owner: selvanair <selva.nair@...1354...= ..>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: cron2 <gert@...1296...>
Gerrit-CC: flichtenheld <frank@...2641...&g= t;
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: selvanair <selva.nair@...493...= 277...>
= --eP8s0nRSPQ8=--