mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 07:44:29 +02:00
add back use of pipes in scp.c under USE_PIPES
This matches sftp.c which prefers socketpair but uses pipes on some older platforms.
This commit is contained in:
parent
eec737b59c
commit
f5154d2aac
30
scp.c
30
scp.c
@ -279,7 +279,11 @@ int
|
|||||||
do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
|
do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
|
||||||
char *cmd, int *fdin, int *fdout, pid_t *pid)
|
char *cmd, int *fdin, int *fdout, pid_t *pid)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_PIPES
|
||||||
|
int pin[2], pout[2];
|
||||||
|
#else
|
||||||
int sv[2];
|
int sv[2];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (verbose_mode)
|
if (verbose_mode)
|
||||||
fmprintf(stderr,
|
fmprintf(stderr,
|
||||||
@ -290,9 +294,14 @@ do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
|
|||||||
if (port == -1)
|
if (port == -1)
|
||||||
port = sshport;
|
port = sshport;
|
||||||
|
|
||||||
|
#ifdef USE_PIPES
|
||||||
|
if (pipe(pin) == -1 || pipe(pout) == -1)
|
||||||
|
fatal("pipe: %s", strerror(errno));
|
||||||
|
#else
|
||||||
/* Create a socket pair for communicating with ssh. */
|
/* Create a socket pair for communicating with ssh. */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)
|
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)
|
||||||
fatal("socketpair: %s", strerror(errno));
|
fatal("socketpair: %s", strerror(errno));
|
||||||
|
#endif
|
||||||
|
|
||||||
ssh_signal(SIGTSTP, suspchild);
|
ssh_signal(SIGTSTP, suspchild);
|
||||||
ssh_signal(SIGTTIN, suspchild);
|
ssh_signal(SIGTTIN, suspchild);
|
||||||
@ -305,13 +314,25 @@ do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
|
|||||||
fatal("fork: %s", strerror(errno));
|
fatal("fork: %s", strerror(errno));
|
||||||
case 0:
|
case 0:
|
||||||
/* Child. */
|
/* Child. */
|
||||||
|
#ifdef USE_PIPES
|
||||||
|
if (dup2(pin[0], STDIN_FILENO) == -1 ||
|
||||||
|
dup2(pout[1], STDOUT_FILENO) == -1) {
|
||||||
|
error("dup2: %s", strerror(errno));
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
close(pin[0]);
|
||||||
|
close(pin[1]);
|
||||||
|
close(pout[0]);
|
||||||
|
close(pout[1]);
|
||||||
|
#else
|
||||||
if (dup2(sv[0], STDIN_FILENO) == -1 ||
|
if (dup2(sv[0], STDIN_FILENO) == -1 ||
|
||||||
dup2(sv[0], STDOUT_FILENO) == -1) {
|
dup2(sv[0], STDOUT_FILENO) == -1) {
|
||||||
perror("dup2");
|
error("dup2: %s", strerror(errno));
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
close(sv[0]);
|
close(sv[0]);
|
||||||
close(sv[1]);
|
close(sv[1]);
|
||||||
|
#endif
|
||||||
replacearg(&args, 0, "%s", program);
|
replacearg(&args, 0, "%s", program);
|
||||||
if (port != -1) {
|
if (port != -1) {
|
||||||
addargs(&args, "-p");
|
addargs(&args, "-p");
|
||||||
@ -332,9 +353,16 @@ do_cmd(char *program, char *host, char *remuser, int port, int subsystem,
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
default:
|
default:
|
||||||
/* Parent. Close the other side, and return the local side. */
|
/* Parent. Close the other side, and return the local side. */
|
||||||
|
#ifdef USE_PIPES
|
||||||
|
close(pin[0]);
|
||||||
|
close(pout[1]);
|
||||||
|
*fdout = pin[1];
|
||||||
|
*fdin = pout[0];
|
||||||
|
#else
|
||||||
close(sv[0]);
|
close(sv[0]);
|
||||||
*fdin = sv[1];
|
*fdin = sv[1];
|
||||||
*fdout = sv[1];
|
*fdout = sv[1];
|
||||||
|
#endif
|
||||||
ssh_signal(SIGTERM, killchild);
|
ssh_signal(SIGTERM, killchild);
|
||||||
ssh_signal(SIGINT, killchild);
|
ssh_signal(SIGINT, killchild);
|
||||||
ssh_signal(SIGHUP, killchild);
|
ssh_signal(SIGHUP, killchild);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user