diff options
author | des <des@FreeBSD.org> | 2005-06-05 15:40:50 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2005-06-05 15:40:50 +0000 |
commit | 11a09ab416e21c995885dc0e5847151627094217 (patch) | |
tree | 7767975616a98948a7ef791c43b28a21711a22c7 /crypto/openssh/readpass.c | |
parent | d5d493f03ae792146848e3cba16bb9e667c73125 (diff) | |
download | FreeBSD-src-11a09ab416e21c995885dc0e5847151627094217.zip FreeBSD-src-11a09ab416e21c995885dc0e5847151627094217.tar.gz |
Vendor import of OpenSSH 4.0p1.
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 eb4f6fd..c2bacdc 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); +} |