Lines 124-129
const char ctty[] = _PATH_CONSOLE;
Link Here
|
124 |
#define MAXUNAMES 20 /* maximum number of user names */ |
124 |
#define MAXUNAMES 20 /* maximum number of user names */ |
125 |
|
125 |
|
126 |
/* |
126 |
/* |
|
|
127 |
* List of hosts for binding. |
128 |
*/ |
129 |
static STAILQ_HEAD(, host) hqueue; |
130 |
struct host { |
131 |
char *name; |
132 |
STAILQ_ENTRY(host) next; |
133 |
}; |
134 |
|
135 |
/* |
127 |
* Unix sockets. |
136 |
* Unix sockets. |
128 |
* We have two default sockets, one with 666 permissions, |
137 |
* We have two default sockets, one with 666 permissions, |
129 |
* and one for privileged programs. |
138 |
* and one for privileged programs. |
Lines 274-280
static int Debug; /* debug flag */
Link Here
|
274 |
static int resolve = 1; /* resolve hostname */ |
283 |
static int resolve = 1; /* resolve hostname */ |
275 |
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ |
284 |
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ |
276 |
static const char *LocalDomain; /* our local domain name */ |
285 |
static const char *LocalDomain; /* our local domain name */ |
277 |
static int *finet; /* Internet datagram socket */ |
286 |
static int *finet; /* Internet datagram sockets */ |
278 |
static int fklog = -1; /* /dev/klog */ |
287 |
static int fklog = -1; /* /dev/klog */ |
279 |
static int Initialized; /* set when we have initialized ourselves */ |
288 |
static int Initialized; /* set when we have initialized ourselves */ |
280 |
static int MarkInterval = 20 * 60; /* interval between marks in seconds */ |
289 |
static int MarkInterval = 20 * 60; /* interval between marks in seconds */ |
Lines 347-356
main(int argc, char *argv[])
Link Here
|
347 |
struct sockaddr_storage frominet; |
356 |
struct sockaddr_storage frominet; |
348 |
fd_set *fdsr = NULL; |
357 |
fd_set *fdsr = NULL; |
349 |
char line[MAXLINE + 1]; |
358 |
char line[MAXLINE + 1]; |
350 |
char *bindhostname; |
|
|
351 |
const char *hname; |
359 |
const char *hname; |
352 |
struct timeval tv, *tvp; |
360 |
struct timeval tv, *tvp; |
353 |
struct sigaction sact; |
361 |
struct sigaction sact; |
|
|
362 |
struct host *host; |
354 |
struct funix *fx, *fx1; |
363 |
struct funix *fx, *fx1; |
355 |
sigset_t mask; |
364 |
sigset_t mask; |
356 |
pid_t ppid = 1, spid; |
365 |
pid_t ppid = 1, spid; |
Lines 359-365
main(int argc, char *argv[])
Link Here
|
359 |
if (madvise(NULL, 0, MADV_PROTECT) != 0) |
368 |
if (madvise(NULL, 0, MADV_PROTECT) != 0) |
360 |
dprintf("madvise() failed: %s\n", strerror(errno)); |
369 |
dprintf("madvise() failed: %s\n", strerror(errno)); |
361 |
|
370 |
|
362 |
bindhostname = NULL; |
371 |
STAILQ_INIT(&hqueue); |
|
|
372 |
|
363 |
while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nNop:P:sS:Tuv")) |
373 |
while ((ch = getopt(argc, argv, "468Aa:b:cCdf:kl:m:nNop:P:sS:Tuv")) |
364 |
!= -1) |
374 |
!= -1) |
365 |
switch (ch) { |
375 |
switch (ch) { |
Lines 382-389
main(int argc, char *argv[])
Link Here
|
382 |
usage(); |
392 |
usage(); |
383 |
break; |
393 |
break; |
384 |
case 'b': |
394 |
case 'b': |
385 |
bindhostname = optarg; |
395 |
{ |
|
|
396 |
if ((host = malloc(sizeof(struct host))) == NULL) |
397 |
err(1, "malloc failed"); |
398 |
host->name = optarg; |
399 |
STAILQ_INSERT_TAIL(&hqueue, host, next); |
386 |
break; |
400 |
break; |
|
|
401 |
} |
387 |
case 'c': |
402 |
case 'c': |
388 |
no_compress++; |
403 |
no_compress++; |
389 |
break; |
404 |
break; |
Lines 429-435
main(int argc, char *argv[])
Link Here
|
429 |
if (strlen(name) >= sizeof(sunx.sun_path)) |
444 |
if (strlen(name) >= sizeof(sunx.sun_path)) |
430 |
errx(1, "%s path too long, exiting", name); |
445 |
errx(1, "%s path too long, exiting", name); |
431 |
if ((fx = malloc(sizeof(struct funix))) == NULL) |
446 |
if ((fx = malloc(sizeof(struct funix))) == NULL) |
432 |
errx(1, "malloc failed"); |
447 |
err(1, "malloc failed"); |
433 |
fx->s = -1; |
448 |
fx->s = -1; |
434 |
fx->name = name; |
449 |
fx->name = name; |
435 |
fx->mode = mode; |
450 |
fx->mode = mode; |
Lines 551-558
main(int argc, char *argv[])
Link Here
|
551 |
} |
566 |
} |
552 |
increase_rcvbuf(fx->s); |
567 |
increase_rcvbuf(fx->s); |
553 |
} |
568 |
} |
554 |
if (SecureMode <= 1) |
569 |
if (SecureMode <= 1) { |
555 |
finet = socksetup(family, bindhostname); |
570 |
if (STAILQ_EMPTY(&hqueue)) |
|
|
571 |
finet = socksetup(family, NULL); |
572 |
STAILQ_FOREACH(host, &hqueue, next) { |
573 |
int *finet0, total; |
574 |
finet0 = socksetup(family, host->name); |
575 |
if (finet0 && !finet) { |
576 |
finet = finet0; |
577 |
} else if (finet0 && finet) { |
578 |
total = *finet0 + *finet + 1; |
579 |
finet = realloc(finet, total * sizeof(int)); |
580 |
if (finet == NULL) |
581 |
err(1, "realloc failed"); |
582 |
for (i = 1; i <= *finet0; i++) { |
583 |
finet[(*finet)+i] = finet0[i]; |
584 |
} |
585 |
*finet = --total; |
586 |
} |
587 |
} |
588 |
} |
556 |
|
589 |
|
557 |
if (finet) { |
590 |
if (finet) { |
558 |
if (SecureMode) { |
591 |
if (SecureMode) { |
Lines 2727-2732
socksetup(int af, char *bindhostname)
Link Here
|
2727 |
} |
2760 |
} |
2728 |
|
2761 |
|
2729 |
(*socks)++; |
2762 |
(*socks)++; |
|
|
2763 |
dprintf("socksetup: new socket fd is %d\n", *s); |
2730 |
s++; |
2764 |
s++; |
2731 |
} |
2765 |
} |
2732 |
|
2766 |
|