Skip to content

Parse username indication in >PASSWORD 'Auth' - #838

Merged
lstipakov merged 3 commits into
OpenVPN:masterfrom
selvanair:prefered-username
Nov 5, 2026
Merged

lstipakov merged 3 commits into
OpenVPN:masterfrom
selvanair:prefered-username

Conversation

@selvanair

Copy link
Copy Markdown
Collaborator

If the server prompts with preferred username indicated as UN: in the >PASSWORD 'Auth' username/password prompt use it to prefill the dialog. Any saved username takes precedence. The user may still edit the username.

Change management client version to 6 to announce support for this feature.

Add a call to CheckVersion() in PLAP as client version will not get announced otherwise when run from logn screen.

OpenVPN caches prompts like this, so username hint will be present only if client version is set before the prompt is created. For persistent and PLAP instances its recommended to start the tunnel instance with --management-hold.

Github: #719

If the server prompts with preferred username indicated as
UN:<base64> in the >PASSWORD 'Auth' username/password prompt
use it to prefill the dialog. Any saved username takes
precedence. The user may still edit the username.

Change management client version to 6 to announce support for
this feature.

Add a call to CheckVersion() in PLAP as client version will not
get announced otherwise when run from logn screen.

OpenVPN caches prompts like this, so username hint will be
present only if client version is set before the prompt is
created.  For persistent and PLAP instances its recommended
to start the tunnel instance with --management-hold.

Github: OpenVPN#719

Signed-off-by: Selva Nair <selva.nair@gmail.com>
@selvanair

Copy link
Copy Markdown
Collaborator Author

As core support for this will be in 2.7.9, would be nice to get this too merged before then!

@selvanair selvanair added this to the 2.7.9 milestone Nov 4, 2026
Comment thread openvpn.c
c->dynamic_cr = NULL;
}

static void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never called on Cleanup(), as a consequence the last allocation leaks per connection AND the hint survives into the later prompt:

  • prompt with UN:YWxpY2U= → username "alice"
  • next prompt with NO UN: field → username "alice" ← stale

Comment thread plap/ui_glue.c Outdated
o.hInstance = hinstance;

/* OnReady() needs the daemon version to announce the management client version. */
if (!CheckVersion())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 1 here propagates as E_FAIL from SetUsageScenario(CPUS_PLAP), so a CheckVersion() failure doesn't just skip the version announcement — the PLAP entry never appears on the logon screen.

Two of its failure paths are silent, the rest pop a modal MessageBoxEx from LogonUI. Could we log and continue at the old version 4 behavior instead?

A CheckVersion() failure made InitializeUI() return 1, which surfaces as
E_FAIL from SetUsageScenario(CPUS_PLAP) and makes LogonUI drop the PLAP
entry altogether. Log and continue: with o.ovpn_version unset, OnReady()
simply omits the "version" command.

Add a quiet parameter to CheckVersion() so failures go to the event log
instead of a message box, as PLAP has no interactive desktop, and log the
two paths that returned FALSE silently.

Signed-off-by: Lev Stipakov <lev.stipakov@openvpn.com>
c->username was never freed -- do it in Cleanup(), next to free_dynamic_cr().

Also clear it on every 'Auth' prompt rather than only when a UN: field is
present. Otherwise the hint outlives its prompt: on auth retry openvpn
re-prompts without UN:, and the stale value would overwrite the username
the user had just corrected.

Signed-off-by: Lev Stipakov <lev.stipakov@openvpn.com>
@lstipakov
lstipakov self-requested a review November 5, 2026 10:12
@lstipakov
lstipakov merged commit b7334f7 into OpenVPN:master Nov 5, 2026
10 checks passed
@selvanair
selvanair deleted the prefered-username branch November 10, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants