summaryrefslogtreecommitdiffhomepage
path: root/dbutil.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-07-18 14:32:52 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-07-18 14:32:52 +0000
commite444f0cfe67c71d3f38854f27cefae9aea6c4cd9 (patch)
tree7539060f852ea180fe550525412f7345a464adba /dbutil.c
parentb8e28df43a1d37b5a50b34db357daea98c42a89c (diff)
- progress towards client agent forwarding
(incomplete and does not compile) --HG-- branch : agent-client extra : convert_revision : 01038174ec27245b51bd43a66c01ad930880f67b
Diffstat (limited to 'dbutil.c')
-rw-r--r--dbutil.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/dbutil.c b/dbutil.c
index 45c720e..fdac66a 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -252,6 +252,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 */
@@ -297,15 +314,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) {