svn commit: r215299 - in head/sys: geom/eli kern libkern sys

Ed Schouten ed at FreeBSD.org
Sun Nov 14 14:12:44 UTC 2010


Author: ed
Date: Sun Nov 14 14:12:43 2010
New Revision: 215299
URL: http://svn.freebsd.org/changeset/base/215299

Log:
  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)

Modified:
  head/sys/geom/eli/g_eli.c
  head/sys/kern/vfs_mountroot.c
  head/sys/libkern/gets.c
  head/sys/sys/libkern.h

Modified: head/sys/geom/eli/g_eli.c
==============================================================================
--- head/sys/geom/eli/g_eli.c	Sun Nov 14 13:31:01 2010	(r215298)
+++ head/sys/geom/eli/g_eli.c	Sun Nov 14 14:12:43 2010	(r215299)
@@ -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,

Modified: head/sys/kern/vfs_mountroot.c
==============================================================================
--- head/sys/kern/vfs_mountroot.c	Sun Nov 14 13:31:01 2010	(r215298)
+++ head/sys/kern/vfs_mountroot.c	Sun Nov 14 14:12:43 2010	(r215299)
@@ -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] == '?') {

Modified: head/sys/libkern/gets.c
==============================================================================
--- head/sys/libkern/gets.c	Sun Nov 14 13:31:01 2010	(r215298)
+++ head/sys/libkern/gets.c	Sun Nov 14 14:12:43 2010	(r215299)
@@ -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;
 			}
 		}

Modified: head/sys/sys/libkern.h
==============================================================================
--- head/sys/sys/libkern.h	Sun Nov 14 13:31:01 2010	(r215298)
+++ head/sys/sys/libkern.h	Sun Nov 14 14:12:43 2010	(r215299)
@@ -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_ */


More information about the svn-src-all mailing list