summaryrefslogtreecommitdiff
path: root/readpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'readpass.c')
-rw-r--r--readpass.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/readpass.c b/readpass.c
index 69edce306..122d2a87c 100644
--- a/readpass.c
+++ b/readpass.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readpass.c,v 1.62 2020/07/14 23:57:01 djm Exp $ */ 1/* $OpenBSD: readpass.c,v 1.63 2020/08/11 09:45:54 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -235,8 +235,8 @@ notify_start(int force_askpass, const char *fmt, ...)
235 int devnull; 235 int devnull;
236 pid_t pid; 236 pid_t pid;
237 void (*osigchld)(int); 237 void (*osigchld)(int);
238 const char *askpass; 238 const char *askpass, *s;
239 struct notifier_ctx *ret; 239 struct notifier_ctx *ret = NULL;
240 240
241 va_start(args, fmt); 241 va_start(args, fmt);
242 xvasprintf(&prompt, fmt, args); 242 xvasprintf(&prompt, fmt, args);
@@ -248,15 +248,19 @@ notify_start(int force_askpass, const char *fmt, ...)
248 (void)write(STDERR_FILENO, "\r", 1); 248 (void)write(STDERR_FILENO, "\r", 1);
249 (void)write(STDERR_FILENO, prompt, strlen(prompt)); 249 (void)write(STDERR_FILENO, prompt, strlen(prompt));
250 (void)write(STDERR_FILENO, "\r\n", 2); 250 (void)write(STDERR_FILENO, "\r\n", 2);
251 free(prompt); 251 goto out;
252 return NULL;
253 } 252 }
254 if ((askpass = getenv("SSH_ASKPASS")) == NULL) 253 if ((askpass = getenv("SSH_ASKPASS")) == NULL)
255 askpass = _PATH_SSH_ASKPASS_DEFAULT; 254 askpass = _PATH_SSH_ASKPASS_DEFAULT;
256 if (getenv("DISPLAY") == NULL || *askpass == '\0') { 255 if (*askpass == '\0') {
257 debug3("%s: cannot notify", __func__); 256 debug3("%s: cannot notify: no askpass", __func__);
258 free(prompt); 257 goto out;
259 return NULL; 258 }
259 if (getenv("DISPLAY") == NULL &&
260 ((s = getenv(SSH_ASKPASS_REQUIRE_ENV)) == NULL ||
261 strcmp(s, "force") != 0)) {
262 debug3("%s: cannot notify: no display", __func__);
263 goto out;
260 } 264 }
261 osigchld = ssh_signal(SIGCHLD, SIG_DFL); 265 osigchld = ssh_signal(SIGCHLD, SIG_DFL);
262 if ((pid = fork()) == -1) { 266 if ((pid = fork()) == -1) {
@@ -284,6 +288,7 @@ notify_start(int force_askpass, const char *fmt, ...)
284 } 288 }
285 ret->pid = pid; 289 ret->pid = pid;
286 ret->osigchld = osigchld; 290 ret->osigchld = osigchld;
291 out:
287 free(prompt); 292 free(prompt);
288 return ret; 293 return ret;
289} 294}