Mercurial > dropbear
diff dbutil.c @ 225:ca7e76d981d9 agent-client
- progress towards client agent forwarding
(incomplete and does not compile)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 18 Jul 2005 14:32:52 +0000 |
parents | 65585699d980 |
children | 79bf1023cf11 |
line wrap: on
line diff
--- a/dbutil.c Fri Jul 08 19:20:10 2005 +0000 +++ b/dbutil.c Mon Jul 18 14:32:52 2005 +0000 @@ -252,6 +252,23 @@ return nsock; } +/* Connect to a given unix socket. The socket is not non-blocking */ +#ifdef ENABLE_CONNECT_UNIX +int connect_unix(const char* addr) +{ + struct sockaddr_un egdsock; + int fd = -1; + + memset((void*)&egdsock, 0x0, sizeof(egdsock)); + egdsock.sun_family = AF_UNIX; + strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path)); + + fd = socket(PF_UNIX, SOCK_STREAM, 0); + + return fd; +} +#endif + /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will * return immediately if nonblocking is set. On failure, if errstring * wasn't null, it will be a newly malloced error message */ @@ -297,15 +314,7 @@ } if (nonblocking) { - if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { - close(sock); - sock = -1; - if (errstring != NULL && *errstring == NULL) { - *errstring = m_strdup("Failed non-blocking"); - } - TRACE(("Failed non-blocking: %s", strerror(errno))) - continue; - } + setnonblocking(sock); } if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {