Mercurial > dropbear
comparison dbutil.c @ 225:ca7e76d981d9 agent-client
- progress towards client agent forwarding
(incomplete and does not compile)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 18 Jul 2005 14:32:52 +0000 |
parents | 65585699d980 |
children | 79bf1023cf11 |
comparison
equal
deleted
inserted
replaced
224:1dbd2473482f | 225:ca7e76d981d9 |
---|---|
250 | 250 |
251 TRACE(("leave dropbear_listen: success, %d socks bound", nsock)) | 251 TRACE(("leave dropbear_listen: success, %d socks bound", nsock)) |
252 return nsock; | 252 return nsock; |
253 } | 253 } |
254 | 254 |
255 /* Connect to a given unix socket. The socket is not non-blocking */ | |
256 #ifdef ENABLE_CONNECT_UNIX | |
257 int connect_unix(const char* addr) | |
258 { | |
259 struct sockaddr_un egdsock; | |
260 int fd = -1; | |
261 | |
262 memset((void*)&egdsock, 0x0, sizeof(egdsock)); | |
263 egdsock.sun_family = AF_UNIX; | |
264 strlcpy(egdsock.sun_path, addr, sizeof(egdsock.sun_path)); | |
265 | |
266 fd = socket(PF_UNIX, SOCK_STREAM, 0); | |
267 | |
268 return fd; | |
269 } | |
270 #endif | |
271 | |
255 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will | 272 /* Connect via TCP to a host. Connection will try ipv4 or ipv6, will |
256 * return immediately if nonblocking is set. On failure, if errstring | 273 * return immediately if nonblocking is set. On failure, if errstring |
257 * wasn't null, it will be a newly malloced error message */ | 274 * wasn't null, it will be a newly malloced error message */ |
258 | 275 |
259 /* TODO: maxfd */ | 276 /* TODO: maxfd */ |
295 err = errno; | 312 err = errno; |
296 continue; | 313 continue; |
297 } | 314 } |
298 | 315 |
299 if (nonblocking) { | 316 if (nonblocking) { |
300 if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { | 317 setnonblocking(sock); |
301 close(sock); | |
302 sock = -1; | |
303 if (errstring != NULL && *errstring == NULL) { | |
304 *errstring = m_strdup("Failed non-blocking"); | |
305 } | |
306 TRACE(("Failed non-blocking: %s", strerror(errno))) | |
307 continue; | |
308 } | |
309 } | 318 } |
310 | 319 |
311 if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { | 320 if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { |
312 if (errno == EINPROGRESS && nonblocking) { | 321 if (errno == EINPROGRESS && nonblocking) { |
313 TRACE(("Connect in progress")) | 322 TRACE(("Connect in progress")) |