diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2005-06-05 15:40:50 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2005-06-05 15:40:50 +0000 |
commit | 5e8dbd04ef7b2df5ba3f8dc859ad6e472ce1c534 (patch) | |
tree | 7767975616a98948a7ef791c43b28a21711a22c7 /crypto/openssh/readpass.c | |
parent | d74d50a84bda49cca847afc2f65bf790d6af7361 (diff) | |
download | src-test2-5e8dbd04ef7b2df5ba3f8dc859ad6e472ce1c534.tar.gz src-test2-5e8dbd04ef7b2df5ba3f8dc859ad6e472ce1c534.zip |
Notes
Diffstat (limited to 'crypto/openssh/readpass.c')
-rw-r--r-- | crypto/openssh/readpass.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/crypto/openssh/readpass.c b/crypto/openssh/readpass.c index eb4f6fdb6d90..c2bacdcd48ea 100644 --- a/crypto/openssh/readpass.c +++ b/crypto/openssh/readpass.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: readpass.c,v 1.30 2004/06/17 15:10:14 djm Exp $"); +RCSID("$OpenBSD: readpass.c,v 1.31 2004/10/29 22:53:56 djm Exp $"); #include "xmalloc.h" #include "misc.h" @@ -141,3 +141,29 @@ read_passphrase(const char *prompt, int flags) memset(buf, 'x', sizeof buf); return ret; } + +int +ask_permission(const char *fmt, ...) +{ + va_list args; + char *p, prompt[1024]; + int allowed = 0; + + va_start(args, fmt); + vsnprintf(prompt, sizeof(prompt), fmt, args); + va_end(args); + + p = read_passphrase(prompt, RP_USE_ASKPASS|RP_ALLOW_EOF); + if (p != NULL) { + /* + * Accept empty responses and responses consisting + * of the word "yes" as affirmative. + */ + if (*p == '\0' || *p == '\n' || + strcasecmp(p, "yes") == 0) + allowed = 1; + xfree(p); + } + + return (allowed); +} |