diff options
Diffstat (limited to 'sshconnect.c')
-rw-r--r-- | sshconnect.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/sshconnect.c b/sshconnect.c index 2842d9e59..608566207 100644 --- a/sshconnect.c +++ b/sshconnect.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshconnect.c,v 1.285 2017/09/03 23:33:13 djm Exp $ */ | 1 | /* $OpenBSD: sshconnect.c,v 1.286 2017/09/12 06:32:07 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -105,7 +105,7 @@ expand_proxy_command(const char *proxy_command, const char *user, | |||
105 | * a connected fd back to us. | 105 | * a connected fd back to us. |
106 | */ | 106 | */ |
107 | static int | 107 | static int |
108 | ssh_proxy_fdpass_connect(const char *host, u_short port, | 108 | ssh_proxy_fdpass_connect(struct ssh *ssh, const char *host, u_short port, |
109 | const char *proxy_command) | 109 | const char *proxy_command) |
110 | { | 110 | { |
111 | char *command_string; | 111 | char *command_string; |
@@ -176,7 +176,8 @@ ssh_proxy_fdpass_connect(const char *host, u_short port, | |||
176 | fatal("Couldn't wait for child: %s", strerror(errno)); | 176 | fatal("Couldn't wait for child: %s", strerror(errno)); |
177 | 177 | ||
178 | /* Set the connection file descriptors. */ | 178 | /* Set the connection file descriptors. */ |
179 | packet_set_connection(sock, sock); | 179 | if (ssh_packet_set_connection(ssh, sock, sock) == NULL) |
180 | return -1; /* ssh_packet_set_connection logs error */ | ||
180 | 181 | ||
181 | return 0; | 182 | return 0; |
182 | } | 183 | } |
@@ -185,7 +186,8 @@ ssh_proxy_fdpass_connect(const char *host, u_short port, | |||
185 | * Connect to the given ssh server using a proxy command. | 186 | * Connect to the given ssh server using a proxy command. |
186 | */ | 187 | */ |
187 | static int | 188 | static int |
188 | ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) | 189 | ssh_proxy_connect(struct ssh *ssh, const char *host, u_short port, |
190 | const char *proxy_command) | ||
189 | { | 191 | { |
190 | char *command_string; | 192 | char *command_string; |
191 | int pin[2], pout[2]; | 193 | int pin[2], pout[2]; |
@@ -252,9 +254,9 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) | |||
252 | free(command_string); | 254 | free(command_string); |
253 | 255 | ||
254 | /* Set the connection file descriptors. */ | 256 | /* Set the connection file descriptors. */ |
255 | packet_set_connection(pout[0], pin[1]); | 257 | if (ssh_packet_set_connection(ssh, pout[0], pin[1]) == NULL) |
258 | return -1; /* ssh_packet_set_connection logs error */ | ||
256 | 259 | ||
257 | /* Indicate OK return */ | ||
258 | return 0; | 260 | return 0; |
259 | } | 261 | } |
260 | 262 | ||
@@ -410,7 +412,7 @@ timeout_connect(int sockfd, const struct sockaddr *serv_addr, | |||
410 | * the daemon. | 412 | * the daemon. |
411 | */ | 413 | */ |
412 | static int | 414 | static int |
413 | ssh_connect_direct(const char *host, struct addrinfo *aitop, | 415 | ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, |
414 | struct sockaddr_storage *hostaddr, u_short port, int family, | 416 | struct sockaddr_storage *hostaddr, u_short port, int family, |
415 | int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) | 417 | int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
416 | { | 418 | { |
@@ -484,27 +486,31 @@ ssh_connect_direct(const char *host, struct addrinfo *aitop, | |||
484 | error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno)); | 486 | error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno)); |
485 | 487 | ||
486 | /* Set the connection. */ | 488 | /* Set the connection. */ |
487 | packet_set_connection(sock, sock); | 489 | if (ssh_packet_set_connection(ssh, sock, sock) == NULL) |
490 | return -1; /* ssh_packet_set_connection logs error */ | ||
488 | 491 | ||
489 | return 0; | 492 | return 0; |
490 | } | 493 | } |
491 | 494 | ||
492 | int | 495 | int |
493 | ssh_connect(const char *host, struct addrinfo *addrs, | 496 | ssh_connect(struct ssh *ssh, const char *host, struct addrinfo *addrs, |
494 | struct sockaddr_storage *hostaddr, u_short port, int family, | 497 | struct sockaddr_storage *hostaddr, u_short port, int family, |
495 | int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) | 498 | int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
496 | { | 499 | { |
497 | if (options.proxy_command == NULL) { | 500 | if (options.proxy_command == NULL) { |
498 | return ssh_connect_direct(host, addrs, hostaddr, port, family, | 501 | return ssh_connect_direct(ssh, host, addrs, hostaddr, port, |
499 | connection_attempts, timeout_ms, want_keepalive, needpriv); | 502 | family, connection_attempts, timeout_ms, want_keepalive, |
503 | needpriv); | ||
500 | } else if (strcmp(options.proxy_command, "-") == 0) { | 504 | } else if (strcmp(options.proxy_command, "-") == 0) { |
501 | packet_set_connection(STDIN_FILENO, STDOUT_FILENO); | 505 | if ((ssh_packet_set_connection(ssh, |
502 | return 0; /* Always succeeds */ | 506 | STDIN_FILENO, STDOUT_FILENO)) == NULL) |
507 | return -1; /* ssh_packet_set_connection logs error */ | ||
508 | return 0; | ||
503 | } else if (options.proxy_use_fdpass) { | 509 | } else if (options.proxy_use_fdpass) { |
504 | return ssh_proxy_fdpass_connect(host, port, | 510 | return ssh_proxy_fdpass_connect(ssh, host, port, |
505 | options.proxy_command); | 511 | options.proxy_command); |
506 | } | 512 | } |
507 | return ssh_proxy_connect(host, port, options.proxy_command); | 513 | return ssh_proxy_connect(ssh, host, port, options.proxy_command); |
508 | } | 514 | } |
509 | 515 | ||
510 | static void | 516 | static void |