comparison dbutil.c @ 458:c1e9c81d1d27 agent-client

propagate from branch 'au.asn.ucc.matt.dropbear' (head 8a7db1e2fdc5636abb338adb636babc32f465739) to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head d82c25da2f7e4fb6da510d806c64344e80bb270d)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 16 Aug 2007 13:34:37 +0000
parents c216212001fc 79bf1023cf11
children d588e3ea557a
comparison
equal deleted inserted replaced
457:e430a26064ee 458:c1e9c81d1d27
293 293
294 TRACE(("leave dropbear_listen: success, %d socks bound", nsock)) 294 TRACE(("leave dropbear_listen: success, %d socks bound", nsock))
295 return nsock; 295 return nsock;
296 } 296 }
297 297
298 /* Connect to a given unix socket. The socket is not non-blocking */
299 #ifdef ENABLE_CONNECT_UNIX
300 int connect_unix(const char* addr)
301 {
302 struct sockaddr_un egdsock;
303 int fd = -1;
304
305 memset((void*)&egdsock, 0x0, sizeof(egdsock));
306 egdsock.sun_family = AF_UNIX;
307 strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path));
308
309 fd = socket(PF_UNIX, SOCK_STREAM, 0);
310
311 return fd;
312 }
313 #endif
314
298 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will 315 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will
299 * return immediately if nonblocking is set. On failure, if errstring 316 * return immediately if nonblocking is set. On failure, if errstring
300 * wasn't null, it will be a newly malloced error message */ 317 * wasn't null, it will be a newly malloced error message */
301 318
302 /* TODO: maxfd */ 319 /* TODO: maxfd */
338 err = errno; 355 err = errno;
339 continue; 356 continue;
340 } 357 }
341 358
342 if (nonblocking) { 359 if (nonblocking) {
343 if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { 360 setnonblocking(sock);
344 close(sock);
345 sock = -1;
346 if (errstring != NULL && *errstring == NULL) {
347 *errstring = m_strdup("Failed non-blocking");
348 }
349 TRACE(("Failed non-blocking: %s", strerror(errno)))
350 continue;
351 }
352 } 361 }
353 362
354 if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { 363 if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
355 if (errno == EINPROGRESS && nonblocking) { 364 if (errno == EINPROGRESS && nonblocking) {
356 TRACE(("Connect in progress")) 365 TRACE(("Connect in progress"))