summaryrefslogtreecommitdiff
path: root/readpass.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2003-09-01 18:42:19 +0000
committerColin Watson <cjwatson@debian.org>2003-09-01 18:42:19 +0000
commit8d6b7f4c46de3feb66f704ab483e51ea1a3bb0e1 (patch)
tree41fe3dd71501bbec5b0393f1536c925eaee180e9 /readpass.c
parentf045c69060bfdd5cf8759a5f29d7008d02e4de5b (diff)
parent58bfa257481a1c6938ada9bbd38801cc45633fb0 (diff)
Debian release 3.6p1-1.
Diffstat (limited to 'readpass.c')
-rw-r--r--readpass.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/readpass.c b/readpass.c
index 96b7e84b4..95ec5d873 100644
--- a/readpass.c
+++ b/readpass.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: readpass.c,v 1.27 2002/03/26 15:58:46 markus Exp $"); 26RCSID("$OpenBSD: readpass.c,v 1.28 2003/01/23 13:50:27 markus Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29#include "readpass.h" 29#include "readpass.h"
@@ -46,11 +46,11 @@ ssh_askpass(char *askpass, const char *msg)
46 fatal("internal error: askpass undefined"); 46 fatal("internal error: askpass undefined");
47 if (pipe(p) < 0) { 47 if (pipe(p) < 0) {
48 error("ssh_askpass: pipe: %s", strerror(errno)); 48 error("ssh_askpass: pipe: %s", strerror(errno));
49 return xstrdup(""); 49 return NULL;
50 } 50 }
51 if ((pid = fork()) < 0) { 51 if ((pid = fork()) < 0) {
52 error("ssh_askpass: fork: %s", strerror(errno)); 52 error("ssh_askpass: fork: %s", strerror(errno));
53 return xstrdup(""); 53 return NULL;
54 } 54 }
55 if (pid == 0) { 55 if (pid == 0) {
56 seteuid(getuid()); 56 seteuid(getuid());
@@ -79,6 +79,11 @@ ssh_askpass(char *askpass, const char *msg)
79 if (errno != EINTR) 79 if (errno != EINTR)
80 break; 80 break;
81 81
82 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
83 memset(buf, 0, sizeof(buf));
84 return NULL;
85 }
86
82 buf[strcspn(buf, "\r\n")] = '\0'; 87 buf[strcspn(buf, "\r\n")] = '\0';
83 pass = xstrdup(buf); 88 pass = xstrdup(buf);
84 memset(buf, 0, sizeof(buf)); 89 memset(buf, 0, sizeof(buf));
@@ -115,7 +120,10 @@ read_passphrase(const char *prompt, int flags)
115 askpass = getenv(SSH_ASKPASS_ENV); 120 askpass = getenv(SSH_ASKPASS_ENV);
116 else 121 else
117 askpass = _PATH_SSH_ASKPASS_DEFAULT; 122 askpass = _PATH_SSH_ASKPASS_DEFAULT;
118 return ssh_askpass(askpass, prompt); 123 if ((ret = ssh_askpass(askpass, prompt)) == NULL)
124 if (!(flags & RP_ALLOW_EOF))
125 return xstrdup("");
126 return ret;
119 } 127 }
120 128
121 if (readpassphrase(prompt, buf, sizeof buf, rppflags) == NULL) { 129 if (readpassphrase(prompt, buf, sizeof buf, rppflags) == NULL) {