diff options
author | Matt Johnston <matt@ucc.asn.au> | 2008-09-23 16:05:04 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2008-09-23 16:05:04 +0000 |
commit | e674c73ee62c79608dc986ca4eda4d8299f2e324 (patch) | |
tree | c14f9f6bc8a5d5ffb182db4966b154943830fef4 /dbutil.c | |
parent | 90f8c1fd51ac6af033d455a775dc5a1455d7d7cb (diff) | |
parent | bb84e33d99f5cbdb362940fc5eb7e4548df4cf23 (diff) |
propagate from branch 'au.asn.ucc.matt.dropbear' (head 4fb35083f0f46ea667e7043e7d4314aecd3df46c)
to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 833d0adef6cdbf43ea75283524c665e70b0ee1ee)
--HG--
branch : agent-client
extra : convert_revision : 6bbab8364de17bd9ecb1dee5ffb796e48c0380d2
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -295,6 +295,23 @@ int dropbear_listen(const char* address, const char* port, 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 */ @@ -341,15 +358,7 @@ int connect_remote(const char* remotehost, const char* remoteport, } 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) { |