summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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