]> andersk Git - gssapi-openssh.git/blobdiff - openssh/readpass.c
Import of OpenSSH 4.0p1
[gssapi-openssh.git] / openssh / readpass.c
index eb4f6fdb6d903aa29b533e42b315b150a2f9a3ca..c2bacdcd48ea9a5fb6a59f067cb238ffae009b15 100644 (file)
@@ -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);
+}
This page took 0.060652 seconds and 4 git commands to generate.