version 1.65, 2020/10/18 11:32:01 |
version 1.66, 2020/11/08 22:37:24 |
|
|
return (allowed); |
return (allowed); |
} |
} |
|
|
|
static void |
|
writemsg(const char *msg) |
|
{ |
|
(void)write(STDERR_FILENO, "\r", 1); |
|
(void)write(STDERR_FILENO, msg, strlen(msg)); |
|
(void)write(STDERR_FILENO, "\r\n", 2); |
|
} |
|
|
struct notifier_ctx { |
struct notifier_ctx { |
pid_t pid; |
pid_t pid; |
void (*osigchld)(int); |
void (*osigchld)(int); |
|
|
{ |
{ |
va_list args; |
va_list args; |
char *prompt = NULL; |
char *prompt = NULL; |
pid_t pid; |
pid_t pid = -1; |
void (*osigchld)(int); |
void (*osigchld)(int) = NULL; |
const char *askpass, *s; |
const char *askpass, *s; |
struct notifier_ctx *ret = NULL; |
struct notifier_ctx *ret = NULL; |
|
|
|
|
if (fflush(NULL) != 0) |
if (fflush(NULL) != 0) |
error_f("fflush: %s", 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); |
writemsg(prompt); |
(void)write(STDERR_FILENO, prompt, strlen(prompt)); |
goto out_ctx; |
(void)write(STDERR_FILENO, "\r\n", 2); |
|
goto out; |
|
} |
} |
if ((askpass = getenv("SSH_ASKPASS")) == NULL) |
if ((askpass = getenv("SSH_ASKPASS")) == NULL) |
askpass = _PATH_SSH_ASKPASS_DEFAULT; |
askpass = _PATH_SSH_ASKPASS_DEFAULT; |
|
|
_exit(1); |
_exit(1); |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
out_ctx: |
if ((ret = calloc(1, sizeof(*ret))) == NULL) { |
if ((ret = calloc(1, sizeof(*ret))) == NULL) { |
kill(pid, SIGTERM); |
kill(pid, SIGTERM); |
fatal_f("calloc failed"); |
fatal_f("calloc failed"); |
|
|
} |
} |
|
|
void |
void |
notify_complete(struct notifier_ctx *ctx) |
notify_complete(struct notifier_ctx *ctx, const char *fmt, ...) |
{ |
{ |
int ret; |
int ret; |
|
char *msg = NULL; |
|
va_list args; |
|
|
|
if (fmt != NULL && ctx->pid == -1) { |
|
/* |
|
* notify_start wrote to stderr, so send conclusion message |
|
* there too |
|
*/ |
|
va_start(args, fmt); |
|
xvasprintf(&msg, fmt, args); |
|
va_end(args); |
|
writemsg(msg); |
|
} |
|
|
if (ctx == NULL || ctx->pid <= 0) { |
if (ctx == NULL || ctx->pid <= 0) { |
free(ctx); |
free(ctx); |