Add support for asterisk characters when filling in the GELI password
during boot. Change the last argument of gets() to indicate a visibility flag and add definitions for the numerical constants. Except for the value 2, gets() will behave exactly the same, so existing consumers shouldn't break. We only use it in two places, though. Submitted by: lme (older version)
This commit is contained in:
parent
991ab941ee
commit
eb4c31fd41
@ -64,11 +64,11 @@ static u_int g_eli_tries = 3;
|
||||
TUNABLE_INT("kern.geom.eli.tries", &g_eli_tries);
|
||||
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RW, &g_eli_tries, 0,
|
||||
"Number of tries for entering the passphrase");
|
||||
static u_int g_eli_visible_passphrase = 0;
|
||||
static u_int g_eli_visible_passphrase = GETS_NOECHO;
|
||||
TUNABLE_INT("kern.geom.eli.visible_passphrase", &g_eli_visible_passphrase);
|
||||
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RW,
|
||||
&g_eli_visible_passphrase, 0,
|
||||
"Turn on echo when entering the passphrase (for debug purposes only!!)");
|
||||
"Visibility of passphrase prompt (0 = invisible, 1 = visible, 2 = asterisk)");
|
||||
u_int g_eli_overwrites = G_ELI_OVERWRITES;
|
||||
TUNABLE_INT("kern.geom.eli.overwrites", &g_eli_overwrites);
|
||||
SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RW, &g_eli_overwrites,
|
||||
|
@ -484,7 +484,7 @@ parse_dir_ask(char **conf)
|
||||
|
||||
again:
|
||||
printf("\nmountroot> ");
|
||||
gets(name, sizeof(name), 1);
|
||||
gets(name, sizeof(name), GETS_ECHO);
|
||||
if (name[0] == '\0')
|
||||
return (0);
|
||||
if (name[0] == '?') {
|
||||
|
@ -60,8 +60,16 @@ gets(char *cp, size_t size, int visible)
|
||||
continue;
|
||||
default:
|
||||
if (lp < end) {
|
||||
if (visible)
|
||||
switch (visible) {
|
||||
case GETS_NOECHO:
|
||||
break;
|
||||
case GETS_ECHOPASS:
|
||||
printf("*");
|
||||
break;
|
||||
default:
|
||||
printf("%c", c);
|
||||
break;
|
||||
}
|
||||
*lp++ = c;
|
||||
}
|
||||
}
|
||||
|
@ -187,4 +187,9 @@ strrchr(const char *p, int ch)
|
||||
#define FNM_IGNORECASE FNM_CASEFOLD
|
||||
#define FNM_FILE_NAME FNM_PATHNAME
|
||||
|
||||
/* Visibility of characters in gets() */
|
||||
#define GETS_NOECHO 0 /* Disable echoing of characters. */
|
||||
#define GETS_ECHO 1 /* Enable echoing of characters. */
|
||||
#define GETS_ECHOPASS 2 /* Print a * for every character. */
|
||||
|
||||
#endif /* !_SYS_LIBKERN_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user