Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add GETPASS_ECHO_STAR
details: https://anonhg.NetBSD.org/src/rev/708ac482b586
branches: trunk
changeset: 778766:708ac482b586
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 12 23:16:38 2012 +0000
description:
add GETPASS_ECHO_STAR
diffstat:
include/unistd.h | 5 +++--
lib/libc/gen/getpass.3 | 6 +++++-
lib/libc/gen/getpass.c | 20 +++++++++++++-------
3 files changed, 21 insertions(+), 10 deletions(-)
diffs (108 lines):
diff -r 1730101d4186 -r 708ac482b586 include/unistd.h
--- a/include/unistd.h Thu Apr 12 22:36:15 2012 +0000
+++ b/include/unistd.h Thu Apr 12 23:16:38 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unistd.h,v 1.130 2012/04/12 22:08:02 christos Exp $ */
+/* $NetBSD: unistd.h,v 1.131 2012/04/12 23:16:55 christos Exp $ */
/*-
* Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -333,7 +333,8 @@
#define GETPASS_BUF_LIMIT 0x04 /* beep on buffer limit */
#define GETPASS_NO_SIGNAL 0x08 /* don't make ttychars send signals */
#define GETPASS_NO_BEEP 0x10 /* don't beep */
-#define GETPASS_ECHO 0x20 /* don't turn echo off */
+#define GETPASS_ECHO 0x20 /* echo characters as they are typed */
+#define GETPASS_ECHO_STAR 0x40 /* ech '*' for each character */
char *getpass_r(const char *, char *, size_t);
int getpeereid(int, uid_t *, gid_t *);
int getsubopt(char **, char * const *, char **);
diff -r 1730101d4186 -r 708ac482b586 lib/libc/gen/getpass.3
--- a/lib/libc/gen/getpass.3 Thu Apr 12 22:36:15 2012 +0000
+++ b/lib/libc/gen/getpass.3 Thu Apr 12 23:16:38 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: getpass.3,v 1.16 2012/04/12 22:07:44 christos Exp $
+.\" $NetBSD: getpass.3,v 1.17 2012/04/12 23:16:38 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -98,6 +98,10 @@
.It Dv GETPASS_NO_BEEP
Don't beep if we erase past the beginning of the buffer or we try to enter past
the end.
+.It Dv GETPASS_ECHO_STAR
+Echo a
+.Sq *
+for each character entered.
.It Dv GETPASS_ECHO
Echo characters as they are typed.
.El
diff -r 1730101d4186 -r 708ac482b586 lib/libc/gen/getpass.c
--- a/lib/libc/gen/getpass.c Thu Apr 12 22:36:15 2012 +0000
+++ b/lib/libc/gen/getpass.c Thu Apr 12 23:16:38 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getpass.c,v 1.19 2012/04/12 22:07:44 christos Exp $ */
+/* $NetBSD: getpass.c,v 1.20 2012/04/12 23:16:38 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getpass.c,v 1.19 2012/04/12 22:07:44 christos Exp $");
+__RCSID("$NetBSD: getpass.c,v 1.20 2012/04/12 23:16:38 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -72,6 +72,7 @@
* We also provide a tunable to disable signal delivery
* GETPASS_NO_SIGNAL.
* - GETPASS_NO_BEEP disables beeping.
+ * - GETPASS_ECHO_STAR will echo '*' for each character of the password
* - GETPASS_ECHO will echo the password (as pam likes it)
*/
char *
@@ -151,7 +152,7 @@
/* Line or word kill, treat as reset */
if (c == C(VKILL, CTRL('u')) || c == C(VWERASE, CTRL('w'))) {
- if (flags & GETPASS_ECHO) {
+ if (flags & (GETPASS_ECHO | GETPASS_ECHO_STAR)) {
while (l--)
erase();
}
@@ -165,7 +166,7 @@
beep();
else {
l--;
- if (flags & GETPASS_ECHO)
+ if (flags & (GETPASS_ECHO | GETPASS_ECHO_STAR))
erase();
}
continue;
@@ -219,8 +220,12 @@
}
}
buf[l++] = c;
- if (c && (flags & GETPASS_ECHO))
- (void)write(fd[1], &c, 1);
+ if (c) {
+ if (flags & GETPASS_ECHO_STAR)
+ (void)write(fd[1], "*", 1);
+ else if (flags & GETPASS_ECHO)
+ (void)write(fd[1], &c, 1);
+ }
}
if (havetty)
@@ -304,7 +309,8 @@
{
char buf[28];
int fd[3] = { 0, 1, 2 };
- printf("[%s]\n", getpassfd("foo>", buf, sizeof(buf), fd, GETPASS_ECHO));
+ printf("[%s]\n", getpassfd("foo>", buf, sizeof(buf), fd,
+ GETPASS_ECHO_STAR));
return 0;
}
#endif
Home |
Main Index |
Thread Index |
Old Index