mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-31 01:35:11 +02:00
- djm@cvs.openbsd.org 2010/12/15 00:49:27
[readpass.c] fix ControlMaster=ask regression reset SIGCHLD handler before fork (and restore it after) so we don't miss the the askpass child's exit status. Correct test for exit status/signal to account for waitpid() failure; with claudio@ ok claudio@ markus@
This commit is contained in:
parent
05c8997b33
commit
106079c06d
@ -13,6 +13,12 @@
|
|||||||
[sshconnect.c]
|
[sshconnect.c]
|
||||||
don't mention key type in key-changed-warning, since we also print
|
don't mention key type in key-changed-warning, since we also print
|
||||||
this warning if a new key type appears. ok djm@
|
this warning if a new key type appears. ok djm@
|
||||||
|
- djm@cvs.openbsd.org 2010/12/15 00:49:27
|
||||||
|
[readpass.c]
|
||||||
|
fix ControlMaster=ask regression
|
||||||
|
reset SIGCHLD handler before fork (and restore it after) so we don't miss
|
||||||
|
the the askpass child's exit status. Correct test for exit status/signal to
|
||||||
|
account for waitpid() failure; with claudio@ ok claudio@ markus@
|
||||||
|
|
||||||
20110104
|
20110104
|
||||||
- (djm) [configure.ac Makefile.in] Use mandoc as preferred manpage
|
- (djm) [configure.ac Makefile.in] Use mandoc as preferred manpage
|
||||||
|
27
readpass.c
27
readpass.c
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: readpass.c,v 1.47 2006/08/03 03:34:42 deraadt Exp $ */
|
/* $OpenBSD: readpass.c,v 1.48 2010/12/15 00:49:27 djm Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
@ -33,6 +33,7 @@
|
|||||||
#ifdef HAVE_PATHS_H
|
#ifdef HAVE_PATHS_H
|
||||||
# include <paths.h>
|
# include <paths.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -49,11 +50,12 @@
|
|||||||
static char *
|
static char *
|
||||||
ssh_askpass(char *askpass, const char *msg)
|
ssh_askpass(char *askpass, const char *msg)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid, ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
char *pass;
|
char *pass;
|
||||||
int p[2], status, ret;
|
int p[2], status;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
void (*osigchld)(int);
|
||||||
|
|
||||||
if (fflush(stdout) != 0)
|
if (fflush(stdout) != 0)
|
||||||
error("ssh_askpass: fflush: %s", strerror(errno));
|
error("ssh_askpass: fflush: %s", strerror(errno));
|
||||||
@ -63,8 +65,10 @@ ssh_askpass(char *askpass, const char *msg)
|
|||||||
error("ssh_askpass: pipe: %s", strerror(errno));
|
error("ssh_askpass: pipe: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
osigchld = signal(SIGCHLD, SIG_DFL);
|
||||||
if ((pid = fork()) < 0) {
|
if ((pid = fork()) < 0) {
|
||||||
error("ssh_askpass: fork: %s", strerror(errno));
|
error("ssh_askpass: fork: %s", strerror(errno));
|
||||||
|
signal(SIGCHLD, osigchld);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
@ -77,23 +81,24 @@ ssh_askpass(char *askpass, const char *msg)
|
|||||||
}
|
}
|
||||||
close(p[1]);
|
close(p[1]);
|
||||||
|
|
||||||
len = ret = 0;
|
len = 0;
|
||||||
do {
|
do {
|
||||||
ret = read(p[0], buf + len, sizeof(buf) - 1 - len);
|
ssize_t r = read(p[0], buf + len, sizeof(buf) - 1 - len);
|
||||||
if (ret == -1 && errno == EINTR)
|
|
||||||
|
if (r == -1 && errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
if (ret <= 0)
|
if (r <= 0)
|
||||||
break;
|
break;
|
||||||
len += ret;
|
len += r;
|
||||||
} while (sizeof(buf) - 1 - len > 0);
|
} while (sizeof(buf) - 1 - len > 0);
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
while (waitpid(pid, &status, 0) < 0)
|
while ((ret = waitpid(pid, &status, 0)) < 0)
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
break;
|
break;
|
||||||
|
signal(SIGCHLD, osigchld);
|
||||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user