comparison dbutil.c @ 258:306499676384

* add -g (dbclient) and -a (dropbear) options for allowing non-local hosts to connect to forwarded ports. Rearranged various some of the tcp listening code. * changed to /* */ style brackets in svr-authpam.c
author Matt Johnston <matt@ucc.asn.au>
date Sun, 04 Dec 2005 16:13:11 +0000
parents b02e8eef3c3a
children 044bc108b9b3 740e782679be
comparison
equal deleted inserted replaced
257:63601217f5ab 258:306499676384
175 setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val)); 175 setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val));
176 #endif 176 #endif
177 177
178 } 178 }
179 179
180 /* Listen on address:port. Unless address is NULL, in which case listen on 180 /* Listen on address:port.
181 * everything. If called with address == "", we'll listen on localhost/loopback. 181 * Special cases are address of "" listening on everything,
182 * and address of NULL listening on localhost only.
182 * Returns the number of sockets bound on success, or -1 on failure. On 183 * Returns the number of sockets bound on success, or -1 on failure. On
183 * failure, if errstring wasn't NULL, it'll be a newly malloced error 184 * failure, if errstring wasn't NULL, it'll be a newly malloced error
184 * string.*/ 185 * string.*/
185 int dropbear_listen(const char* address, const char* port, 186 int dropbear_listen(const char* address, const char* port,
186 int *socks, unsigned int sockcount, char **errstring, int *maxfd) { 187 int *socks, unsigned int sockcount, char **errstring, int *maxfd) {
196 197
197 memset(&hints, 0, sizeof(hints)); 198 memset(&hints, 0, sizeof(hints));
198 hints.ai_family = AF_UNSPEC; /* TODO: let them flag v4 only etc */ 199 hints.ai_family = AF_UNSPEC; /* TODO: let them flag v4 only etc */
199 hints.ai_socktype = SOCK_STREAM; 200 hints.ai_socktype = SOCK_STREAM;
200 201
201 if (address && address[0] == '\0') { 202 // for calling getaddrinfo:
203 // address == NULL and !AI_PASSIVE: local loopback
204 // address == NULL and AI_PASSIVE: all interfaces
205 // address != NULL: whatever the address says
206 if (!address) {
202 TRACE(("dropbear_listen: local loopback")) 207 TRACE(("dropbear_listen: local loopback"))
203 address = NULL;
204 } else { 208 } else {
205 TRACE(("dropbear_listen: not local loopback")) 209 if (address[0] == '\0') {
210 TRACE(("dropbear_listen: all interfaces"))
211 address = NULL;
212 }
206 hints.ai_flags = AI_PASSIVE; 213 hints.ai_flags = AI_PASSIVE;
207 } 214 }
208 err = getaddrinfo(address, port, &hints, &res0); 215 err = getaddrinfo(address, port, &hints, &res0);
209 216
210 if (err) { 217 if (err) {