From 5205ad5277e4473ea0b43714a827c2311b43b3a7 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 9 Nov 2021 08:28:41 +0100 Subject: [PATCH 295/310] sys/geom/eli: Optionally turn on visibility for the last attemt ... ... to enter the passphrase. This is useful if the keyboard is prelling. Obtained from: ElectroBSD --- sys/geom/eli/g_eli.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 4534dfd7703a..9b2f59368fea 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -81,6 +81,10 @@ static u_int g_eli_visible_passphrase = GETS_NOECHO; SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RWTUN, &g_eli_visible_passphrase, 0, "Visibility of passphrase prompt (0 = invisible, 1 = visible, 2 = asterisk)"); +static u_int g_eli_last_try_visible = 0; +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, last_try_visible, CTLFLAG_RWTUN, + &g_eli_last_try_visible, 0, + "Make the entered passphrase visible if it's the last attempt"); u_int g_eli_overwrites = G_ELI_OVERWRITES; SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RWTUN, &g_eli_overwrites, 0, "Number of times on-disk keys should be overwritten when destroying them"); @@ -1299,8 +1303,15 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) memcpy(passphrase, cached_passphrase, sizeof(passphrase)); } else { + showpass = g_eli_visible_passphrase; + if (g_eli_last_try_visible && + !showpass && i == tries) { + G_ELI_DEBUG(0, "Last try for %s. " + "Turning visibility on!", + pp->name); + showpass = 1; + } printf("Enter passphrase for %s: ", pp->name); - showpass = g_eli_visible_passphrase; if ((md.md_flags & G_ELI_FLAG_GELIDISPLAYPASS) != 0) showpass = GETS_ECHOPASS; cngets(passphrase, sizeof(passphrase), -- 2.37.1