diff dbutil.c @ 550:61c3513825b0 agent-client

Talking to the agent works now. Can't interpret the pubkeys.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 01 Jul 2009 06:27:27 +0000
parents cf376c696dfc
children 005530560594
line wrap: on
line diff
--- a/dbutil.c	Wed Jul 01 04:53:17 2009 +0000
+++ b/dbutil.c	Wed Jul 01 06:27:27 2009 +0000
@@ -297,14 +297,22 @@
 
 /* Connect to a given unix socket. The socket is blocking */
 #ifdef ENABLE_CONNECT_UNIX
-int connect_unix(const char* addr) {
-	struct sockaddr_un egdsock;
+int connect_unix(const char* path) {
+	struct sockaddr_un addr;
 	int fd = -1;
 
-	memset((void*)&egdsock, 0x0, sizeof(egdsock));
-	egdsock.sun_family = AF_UNIX;
-	strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path));
+	memset((void*)&addr, 0x0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+	strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
 	fd = socket(PF_UNIX, SOCK_STREAM, 0);
+	if (fd < 0) {
+		TRACE(("Failed to open unix socket"))
+		return -1;
+	}
+	if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+		TRACE(("Failed to connect to '%s' socket", path))
+		return -1;
+	}
 	return fd;
 }
 #endif
@@ -574,7 +582,6 @@
 	}
 
 	return retstring;
-
 }
 
 /* Get the hostname corresponding to the address addr. On failure, the IP