version 1.64, 2020/10/03 09:22:26 |
version 1.65, 2020/10/18 11:32:01 |
|
|
void (*osigchld)(int); |
void (*osigchld)(int); |
|
|
if (fflush(stdout) != 0) |
if (fflush(stdout) != 0) |
error("%s: fflush: %s", __func__, strerror(errno)); |
error_f("fflush: %s", strerror(errno)); |
if (askpass == NULL) |
if (askpass == NULL) |
fatal("internal error: askpass undefined"); |
fatal("internal error: askpass undefined"); |
if (pipe(p) == -1) { |
if (pipe(p) == -1) { |
error("%s: pipe: %s", __func__, strerror(errno)); |
error_f("pipe: %s", strerror(errno)); |
return NULL; |
return NULL; |
} |
} |
osigchld = ssh_signal(SIGCHLD, SIG_DFL); |
osigchld = ssh_signal(SIGCHLD, SIG_DFL); |
if ((pid = fork()) == -1) { |
if ((pid = fork()) == -1) { |
error("%s: fork: %s", __func__, strerror(errno)); |
error_f("fork: %s", strerror(errno)); |
ssh_signal(SIGCHLD, osigchld); |
ssh_signal(SIGCHLD, osigchld); |
return NULL; |
return NULL; |
} |
} |
if (pid == 0) { |
if (pid == 0) { |
close(p[0]); |
close(p[0]); |
if (dup2(p[1], STDOUT_FILENO) == -1) |
if (dup2(p[1], STDOUT_FILENO) == -1) |
fatal("%s: dup2: %s", __func__, strerror(errno)); |
fatal_f("dup2: %s", strerror(errno)); |
if (env_hint != NULL) |
if (env_hint != NULL) |
setenv("SSH_ASKPASS_PROMPT", env_hint, 1); |
setenv("SSH_ASKPASS_PROMPT", env_hint, 1); |
execlp(askpass, askpass, msg, (char *)NULL); |
execlp(askpass, askpass, msg, (char *)NULL); |
fatal("%s: exec(%s): %s", __func__, askpass, strerror(errno)); |
fatal_f("exec(%s): %s", askpass, strerror(errno)); |
} |
} |
close(p[1]); |
close(p[1]); |
|
|
|
|
|
|
rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF; |
rppflags = (flags & RP_ECHO) ? RPP_ECHO_ON : RPP_ECHO_OFF; |
if (use_askpass) |
if (use_askpass) |
debug("%s: requested to askpass", __func__); |
debug_f("requested to askpass"); |
else if (flags & RP_USE_ASKPASS) |
else if (flags & RP_USE_ASKPASS) |
use_askpass = 1; |
use_askpass = 1; |
else if (flags & RP_ALLOW_STDIN) { |
else if (flags & RP_ALLOW_STDIN) { |
|
|
va_end(args); |
va_end(args); |
|
|
if (fflush(NULL) != 0) |
if (fflush(NULL) != 0) |
error("%s: fflush: %s", __func__, strerror(errno)); |
error_f("fflush: %s", strerror(errno)); |
if (!force_askpass && isatty(STDERR_FILENO)) { |
if (!force_askpass && isatty(STDERR_FILENO)) { |
(void)write(STDERR_FILENO, "\r", 1); |
(void)write(STDERR_FILENO, "\r", 1); |
(void)write(STDERR_FILENO, prompt, strlen(prompt)); |
(void)write(STDERR_FILENO, prompt, strlen(prompt)); |
|
|
if ((askpass = getenv("SSH_ASKPASS")) == NULL) |
if ((askpass = getenv("SSH_ASKPASS")) == NULL) |
askpass = _PATH_SSH_ASKPASS_DEFAULT; |
askpass = _PATH_SSH_ASKPASS_DEFAULT; |
if (*askpass == '\0') { |
if (*askpass == '\0') { |
debug3("%s: cannot notify: no askpass", __func__); |
debug3_f("cannot notify: no askpass"); |
goto out; |
goto out; |
} |
} |
if (getenv("DISPLAY") == NULL && |
if (getenv("DISPLAY") == NULL && |
((s = getenv(SSH_ASKPASS_REQUIRE_ENV)) == NULL || |
((s = getenv(SSH_ASKPASS_REQUIRE_ENV)) == NULL || |
strcmp(s, "force") != 0)) { |
strcmp(s, "force") != 0)) { |
debug3("%s: cannot notify: no display", __func__); |
debug3_f("cannot notify: no display"); |
goto out; |
goto out; |
} |
} |
osigchld = ssh_signal(SIGCHLD, SIG_DFL); |
osigchld = ssh_signal(SIGCHLD, SIG_DFL); |
if ((pid = fork()) == -1) { |
if ((pid = fork()) == -1) { |
error("%s: fork: %s", __func__, strerror(errno)); |
error_f("fork: %s", strerror(errno)); |
ssh_signal(SIGCHLD, osigchld); |
ssh_signal(SIGCHLD, osigchld); |
free(prompt); |
free(prompt); |
return NULL; |
return NULL; |
} |
} |
if (pid == 0) { |
if (pid == 0) { |
if (stdfd_devnull(1, 1, 0) == -1) |
if (stdfd_devnull(1, 1, 0) == -1) |
fatal("%s: stdfd_devnull failed", __func__); |
fatal_f("stdfd_devnull failed"); |
closefrom(STDERR_FILENO + 1); |
closefrom(STDERR_FILENO + 1); |
setenv("SSH_ASKPASS_PROMPT", "none", 1); /* hint to UI */ |
setenv("SSH_ASKPASS_PROMPT", "none", 1); /* hint to UI */ |
execlp(askpass, askpass, prompt, (char *)NULL); |
execlp(askpass, askpass, prompt, (char *)NULL); |
error("%s: exec(%s): %s", __func__, askpass, strerror(errno)); |
error_f("exec(%s): %s", askpass, strerror(errno)); |
_exit(1); |
_exit(1); |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
if ((ret = calloc(1, sizeof(*ret))) == NULL) { |
if ((ret = calloc(1, sizeof(*ret))) == NULL) { |
kill(pid, SIGTERM); |
kill(pid, SIGTERM); |
fatal("%s: calloc failed", __func__); |
fatal_f("calloc failed"); |
} |
} |
ret->pid = pid; |
ret->pid = pid; |
ret->osigchld = osigchld; |
ret->osigchld = osigchld; |
|
|
break; |
break; |
} |
} |
if (ret == -1) |
if (ret == -1) |
fatal("%s: waitpid: %s", __func__, strerror(errno)); |
fatal_f("waitpid: %s", strerror(errno)); |
ssh_signal(SIGCHLD, ctx->osigchld); |
ssh_signal(SIGCHLD, ctx->osigchld); |
free(ctx); |
free(ctx); |
} |
} |