Skip to content

Commit

Permalink
Password-reveal: Respect group policy setting, if any
Browse files Browse the repository at this point in the history
- The policy setting is checked when GUI is started. Any change
  in policy will be effective only after restarting the GUI.

Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair authored and lstipakov committed Apr 26, 2023
1 parent 9186648 commit 982e1a4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,13 @@ ResetPasswordReveal(HWND edit, HWND btn, WPARAM wParam)
{
return;
}

if (o.disable_password_reveal)
{
ShowWindow(btn, SW_HIDE);
return;
}

/* set the password field to be masked as a sane default */
SendMessage(edit, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
SendMessage(btn, STM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM)LoadLocalizedSmallIcon(ID_ICO_EYE));
Expand Down
1 change: 1 addition & 0 deletions options.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ typedef struct {
DWORD ovpn_engine; /* 0 - openvpn2, 1 - openvpn3 */
DWORD enable_persistent; /* 0 - disabled, 1 - enabled, 2 - enabled & auto attach */
DWORD enable_auto_restart; /* 0 - disabled, >0 enabled */
DWORD disable_password_reveal; /* read from group policy */
#ifdef DEBUG
FILE *debug_fp;
#endif
Expand Down
15 changes: 15 additions & 0 deletions registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@ GetRegistryKeys ()
o.mgmt_port_offset = 25340;
}

/* Read group policy setting for password reveal */
status = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Policies\\Microsoft\\Windows\\CredUI", 0, KEY_READ, &regkey);
if (status != ERROR_SUCCESS
|| !GetRegistryValueNumeric(regkey, L"DisablePasswordReveal", &o.disable_password_reveal))
{
o.disable_password_reveal = 0;
PrintDebug(L"default: %ls = %lu", L"DisablePasswordReveal", o.disable_password_reveal);
}
else
{
PrintDebug(L"from policy: %ls = %lu", L"DisablePasswordReveal", o.disable_password_reveal);
}
if (status == ERROR_SUCCESS)
RegCloseKey(regkey);

ExpandOptions ();
return true;
}
Expand Down

0 comments on commit 982e1a4

Please sign in to comment.