summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-11-14 14:12:43 +0000
committered <ed@FreeBSD.org>2010-11-14 14:12:43 +0000
commit4ee939c936810cdbeb5d64f9b2b28890e4af0814 (patch)
tree8cfc4a89bf07768ed21b9e6d521da70520fb8e36 /sys
parentdd93d3c0fda933782c0813b9cf0b13c8c5f80054 (diff)
downloadFreeBSD-src-4ee939c936810cdbeb5d64f9b2b28890e4af0814.zip
FreeBSD-src-4ee939c936810cdbeb5d64f9b2b28890e4af0814.tar.gz
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)
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/eli/g_eli.c4
-rw-r--r--sys/kern/vfs_mountroot.c2
-rw-r--r--sys/libkern/gets.c10
-rw-r--r--sys/sys/libkern.h5
4 files changed, 17 insertions, 4 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index deffeb7..8834b86 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -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,
diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c
index 07c2988..48a632e 100644
--- a/sys/kern/vfs_mountroot.c
+++ b/sys/kern/vfs_mountroot.c
@@ -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] == '?') {
diff --git a/sys/libkern/gets.c b/sys/libkern/gets.c
index 4834da0..64452f3 100644
--- a/sys/libkern/gets.c
+++ b/sys/libkern/gets.c
@@ -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;
}
}
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h
index ebba374..a6e2acd 100644
--- a/sys/sys/libkern.h
+++ b/sys/sys/libkern.h
@@ -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_ */
OpenPOWER on IntegriCloud