mirror of
https://github.com/clearml/dropbear
synced 2025-04-22 15:17:27 +00:00
connect_remote() is now always non-blocking
This commit is contained in:
parent
2c35f1c8fd
commit
9abcc7b909
@ -72,8 +72,7 @@ int main(int argc, char ** argv) {
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport,
|
int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, &error);
|
||||||
1, &error);
|
|
||||||
sock_in = sock_out = sock;
|
sock_in = sock_out = sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ static int newtcpforwarded(struct Channel * channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(portstring, sizeof(portstring), "%d", fwd->connectport);
|
snprintf(portstring, sizeof(portstring), "%d", fwd->connectport);
|
||||||
sock = connect_remote(fwd->connectaddr, portstring, 1, NULL);
|
sock = connect_remote(fwd->connectaddr, portstring, NULL);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
TRACE(("leave newtcpdirect: sock failed"))
|
TRACE(("leave newtcpdirect: sock failed"))
|
||||||
err = SSH_OPEN_CONNECT_FAILED;
|
err = SSH_OPEN_CONNECT_FAILED;
|
||||||
|
13
dbutil.c
13
dbutil.c
@ -435,8 +435,7 @@ static void set_piggyback_ack(int sock) {
|
|||||||
* wasn't null, it will be a newly malloced error message */
|
* wasn't null, it will be a newly malloced error message */
|
||||||
|
|
||||||
/* TODO: maxfd */
|
/* TODO: maxfd */
|
||||||
int connect_remote(const char* remotehost, const char* remoteport,
|
int connect_remote(const char* remotehost, const char* remoteport, char ** errstring) {
|
||||||
int nonblocking, char ** errstring) {
|
|
||||||
|
|
||||||
struct addrinfo *res0 = NULL, *res = NULL, hints;
|
struct addrinfo *res0 = NULL, *res = NULL, hints;
|
||||||
int sock;
|
int sock;
|
||||||
@ -475,16 +474,14 @@ int connect_remote(const char* remotehost, const char* remoteport,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonblocking) {
|
setnonblocking(sock);
|
||||||
setnonblocking(sock);
|
|
||||||
|
|
||||||
#if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
|
#if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
|
||||||
set_piggyback_ack(sock);
|
set_piggyback_ack(sock);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
|
if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
|
||||||
if (errno == EINPROGRESS && nonblocking) {
|
if (errno == EINPROGRESS) {
|
||||||
TRACE(("Connect in progress"))
|
TRACE(("Connect in progress"))
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -498,7 +495,7 @@ int connect_remote(const char* remotehost, const char* remoteport,
|
|||||||
break; /* Success */
|
break; /* Success */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock < 0 && !(errno == EINPROGRESS && nonblocking)) {
|
if (sock < 0 && !(errno == EINPROGRESS)) {
|
||||||
/* Failed */
|
/* Failed */
|
||||||
if (errstring != NULL && *errstring == NULL) {
|
if (errstring != NULL && *errstring == NULL) {
|
||||||
int len;
|
int len;
|
||||||
|
3
dbutil.h
3
dbutil.h
@ -83,8 +83,7 @@ void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell);
|
|||||||
#ifdef ENABLE_CONNECT_UNIX
|
#ifdef ENABLE_CONNECT_UNIX
|
||||||
int connect_unix(const char* addr);
|
int connect_unix(const char* addr);
|
||||||
#endif
|
#endif
|
||||||
int connect_remote(const char* remotehost, const char* remoteport,
|
int connect_remote(const char* remotehost, const char* remoteport, char ** errstring);
|
||||||
int nonblocking, char ** errstring);
|
|
||||||
int buf_readfile(buffer* buf, const char* filename);
|
int buf_readfile(buffer* buf, const char* filename);
|
||||||
int buf_getline(buffer * line, FILE * authfile);
|
int buf_getline(buffer * line, FILE * authfile);
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ static int newtcpdirect(struct Channel * channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(portstring, sizeof(portstring), "%d", destport);
|
snprintf(portstring, sizeof(portstring), "%d", destport);
|
||||||
sock = connect_remote(desthost, portstring, 1, NULL);
|
sock = connect_remote(desthost, portstring, NULL);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
err = SSH_OPEN_CONNECT_FAILED;
|
err = SSH_OPEN_CONNECT_FAILED;
|
||||||
TRACE(("leave newtcpdirect: sock failed"))
|
TRACE(("leave newtcpdirect: sock failed"))
|
||||||
|
Loading…
Reference in New Issue
Block a user