version 1.285, 2017/09/03 23:33:13 |
version 1.286, 2017/09/12 06:32:07 |
|
|
* a connected fd back to us. |
* a connected fd back to us. |
*/ |
*/ |
static int |
static int |
ssh_proxy_fdpass_connect(const char *host, u_short port, |
ssh_proxy_fdpass_connect(struct ssh *ssh, const char *host, u_short port, |
const char *proxy_command) |
const char *proxy_command) |
{ |
{ |
char *command_string; |
char *command_string; |
|
|
fatal("Couldn't wait for child: %s", strerror(errno)); |
fatal("Couldn't wait for child: %s", strerror(errno)); |
|
|
/* Set the connection file descriptors. */ |
/* Set the connection file descriptors. */ |
packet_set_connection(sock, sock); |
if (ssh_packet_set_connection(ssh, sock, sock) == NULL) |
|
return -1; /* ssh_packet_set_connection logs error */ |
|
|
return 0; |
return 0; |
} |
} |
|
|
* Connect to the given ssh server using a proxy command. |
* Connect to the given ssh server using a proxy command. |
*/ |
*/ |
static int |
static int |
ssh_proxy_connect(const char *host, u_short port, const char *proxy_command) |
ssh_proxy_connect(struct ssh *ssh, const char *host, u_short port, |
|
const char *proxy_command) |
{ |
{ |
char *command_string; |
char *command_string; |
int pin[2], pout[2]; |
int pin[2], pout[2]; |
|
|
free(command_string); |
free(command_string); |
|
|
/* Set the connection file descriptors. */ |
/* Set the connection file descriptors. */ |
packet_set_connection(pout[0], pin[1]); |
if (ssh_packet_set_connection(ssh, pout[0], pin[1]) == NULL) |
|
return -1; /* ssh_packet_set_connection logs error */ |
|
|
/* Indicate OK return */ |
|
return 0; |
return 0; |
} |
} |
|
|
|
|
* the daemon. |
* the daemon. |
*/ |
*/ |
static int |
static int |
ssh_connect_direct(const char *host, struct addrinfo *aitop, |
ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, |
struct sockaddr_storage *hostaddr, u_short port, int family, |
struct sockaddr_storage *hostaddr, u_short port, int family, |
int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
{ |
{ |
|
|
error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno)); |
error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno)); |
|
|
/* Set the connection. */ |
/* Set the connection. */ |
packet_set_connection(sock, sock); |
if (ssh_packet_set_connection(ssh, sock, sock) == NULL) |
|
return -1; /* ssh_packet_set_connection logs error */ |
|
|
return 0; |
return 0; |
} |
} |
|
|
int |
int |
ssh_connect(const char *host, struct addrinfo *addrs, |
ssh_connect(struct ssh *ssh, const char *host, struct addrinfo *addrs, |
struct sockaddr_storage *hostaddr, u_short port, int family, |
struct sockaddr_storage *hostaddr, u_short port, int family, |
int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
int connection_attempts, int *timeout_ms, int want_keepalive, int needpriv) |
{ |
{ |
if (options.proxy_command == NULL) { |
if (options.proxy_command == NULL) { |
return ssh_connect_direct(host, addrs, hostaddr, port, family, |
return ssh_connect_direct(ssh, host, addrs, hostaddr, port, |
connection_attempts, timeout_ms, want_keepalive, needpriv); |
family, connection_attempts, timeout_ms, want_keepalive, |
|
needpriv); |
} else if (strcmp(options.proxy_command, "-") == 0) { |
} else if (strcmp(options.proxy_command, "-") == 0) { |
packet_set_connection(STDIN_FILENO, STDOUT_FILENO); |
if ((ssh_packet_set_connection(ssh, |
return 0; /* Always succeeds */ |
STDIN_FILENO, STDOUT_FILENO)) == NULL) |
|
return -1; /* ssh_packet_set_connection logs error */ |
|
return 0; |
} else if (options.proxy_use_fdpass) { |
} else if (options.proxy_use_fdpass) { |
return ssh_proxy_fdpass_connect(host, port, |
return ssh_proxy_fdpass_connect(ssh, host, port, |
options.proxy_command); |
options.proxy_command); |
} |
} |
return ssh_proxy_connect(host, port, options.proxy_command); |
return ssh_proxy_connect(ssh, host, port, options.proxy_command); |
} |
} |
|
|
static void |
static void |