--- usr.sbin/syslogd/syslogd.c 2006/04/24 19:00:30 1.78 +++ usr.sbin/syslogd/syslogd.c 2006/09/15 20:32:59 1.79 @@ -257,7 +257,7 @@ void die(struct kevent *); /* SIGTERM ke void domark(struct kevent *);/* timer kevent dispatch routine */ void fprintlog(struct filed *, int, char *); int getmsgbufsize(void); -int* socksetup(int); +int* socksetup(int, const char *); void init(struct kevent *); /* SIGHUP kevent dispatch routine */ void logerror(const char *, ...); void logmsg(int, char *, char *, int); @@ -290,6 +290,7 @@ static void dispatch_read_funix(struct k */ static char *linebuf; static size_t linebufsize; +static const char *bindhostname = NULL; #define A_CNT(x) (sizeof((x)) / sizeof((x)[0])) @@ -314,8 +315,11 @@ main(int argc, char *argv[]) (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "dnsSf:m:p:P:ru:g:t:Uv")) != -1) + while ((ch = getopt(argc, argv, "b:dnsSf:m:p:P:ru:g:t:Uv")) != -1) switch(ch) { + case 'b': + bindhostname = optarg; + break; case 'd': /* debug */ Debug++; break; @@ -600,9 +609,10 @@ usage(void) { (void)fprintf(stderr, - "usage: %s [-dnrSsUv] [-f config_file] [-g group] [-m mark_interval]\n" - "\t[-P file_list] [-p log_socket [-p log_socket2 ...]]\n" - "\t[-t chroot_dir] [-u user]\n", getprogname()); + "usage: %s [-dnrSsUv] [-b bind_address] [-f config_file] [-g group]\n" + "\t[-m mark_interval] [-P file_list] [-p log_socket\n" + "\t[-p log_socket2 ...]] [-t chroot_dir] [-u user]\n", + getprogname()); exit(1); } @@ -1784,7 +1788,7 @@ init(struct kevent *ev) } } - finet = socksetup(PF_UNSPEC); + finet = socksetup(PF_UNSPEC, bindhostname); if (finet) { if (SecureMode) { for (i = 0; i < *finet; i++) { @@ -2093,7 +2097,7 @@ getmsgbufsize(void) } int * -socksetup(int af) +socksetup(int af, const char *hostname) { struct addrinfo hints, *res, *r; struct kevent *ev; @@ -2107,7 +2111,7 @@ socksetup(int af) hints.ai_flags = AI_PASSIVE; hints.ai_family = af; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(NULL, "syslog", &hints, &res); + error = getaddrinfo(hostname, "syslog", &hints, &res); if (error) { logerror(gai_strerror(error)); errno = 0;