comparison 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
comparison
equal deleted inserted replaced
547:cf376c696dfc 550:61c3513825b0
295 return nsock; 295 return nsock;
296 } 296 }
297 297
298 /* Connect to a given unix socket. The socket is blocking */ 298 /* Connect to a given unix socket. The socket is blocking */
299 #ifdef ENABLE_CONNECT_UNIX 299 #ifdef ENABLE_CONNECT_UNIX
300 int connect_unix(const char* addr) { 300 int connect_unix(const char* path) {
301 struct sockaddr_un egdsock; 301 struct sockaddr_un addr;
302 int fd = -1; 302 int fd = -1;
303 303
304 memset((void*)&egdsock, 0x0, sizeof(egdsock)); 304 memset((void*)&addr, 0x0, sizeof(addr));
305 egdsock.sun_family = AF_UNIX; 305 addr.sun_family = AF_UNIX;
306 strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path)); 306 strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
307 fd = socket(PF_UNIX, SOCK_STREAM, 0); 307 fd = socket(PF_UNIX, SOCK_STREAM, 0);
308 if (fd < 0) {
309 TRACE(("Failed to open unix socket"))
310 return -1;
311 }
312 if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
313 TRACE(("Failed to connect to '%s' socket", path))
314 return -1;
315 }
308 return fd; 316 return fd;
309 } 317 }
310 #endif 318 #endif
311 319
312 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will 320 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will
572 } else { 580 } else {
573 retstring = m_strdup(hbuf); 581 retstring = m_strdup(hbuf);
574 } 582 }
575 583
576 return retstring; 584 return retstring;
577
578 } 585 }
579 586
580 /* Get the hostname corresponding to the address addr. On failure, the IP 587 /* Get the hostname corresponding to the address addr. On failure, the IP
581 * address is returned. The return value is allocated with strdup() */ 588 * address is returned. The return value is allocated with strdup() */
582 char* getaddrhostname(struct sockaddr_storage * addr) { 589 char* getaddrhostname(struct sockaddr_storage * addr) {