diff options
author | dd <dd@FreeBSD.org> | 2001-09-01 08:42:49 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-09-01 08:42:49 +0000 |
commit | 396c50b0c10ef7bd39a5ac7d7232a64ee4e41160 (patch) | |
tree | 6f788de6ece24520f83741e4da05c85409167f99 /usr.sbin/syslogd/syslogd.c | |
parent | c96eebc7a1aa275953e64896ff9b2e3aae631004 (diff) | |
download | FreeBSD-src-396c50b0c10ef7bd39a5ac7d7232a64ee4e41160.zip FreeBSD-src-396c50b0c10ef7bd39a5ac7d7232a64ee4e41160.tar.gz |
Introduce a -b option that allows the user to specify which address to
bind to. This is useful for hosts running jails that need syslog to
maintain an open socket to log to a remote host.
Reviewed by: sheldonh
Diffstat (limited to 'usr.sbin/syslogd/syslogd.c')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index f05f433..2a837aa 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -294,7 +294,7 @@ void die __P((int)); void dodie __P((int)); void domark __P((int)); void fprintlog __P((struct filed *, int, char *)); -int* socksetup __P((int)); +int* socksetup __P((int, const char *)); void init __P((int)); void logerror __P((const char *)); void logmsg __P((int, char *, char *, int)); @@ -324,13 +324,15 @@ main(argc, argv) fd_set *fdsr = NULL; FILE *fp; char *hname, line[MAXLINE + 1]; + const char *bindhostname; struct timeval tv, *tvp; struct sigaction sact; sigset_t mask; pid_t ppid = 1; socklen_t len; - while ((ch = getopt(argc, argv, "46Aa:df:kl:m:np:P:suv")) != -1) + bindhostname = NULL; + while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:np:P:suv")) != -1) switch (ch) { case '4': family = PF_INET; @@ -347,6 +349,9 @@ main(argc, argv) if (allowaddr(optarg) == -1) usage(); break; + case 'b': + bindhostname = optarg; + break; case 'd': /* debug */ Debug++; break; @@ -447,7 +452,7 @@ main(argc, argv) } } if (SecureMode <= 1) - finet = socksetup(family); + finet = socksetup(family, bindhostname); if (finet) { if (SecureMode) { @@ -2292,8 +2297,9 @@ log_deadchild(pid, status, name) } int * -socksetup(af) +socksetup(af, bindhostname) int af; + const char *bindhostname; { struct addrinfo hints, *res, *r; int error, maxs, *s, *socks; @@ -2302,7 +2308,7 @@ socksetup(af) hints.ai_flags = AI_PASSIVE; hints.ai_family = af; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(NULL, "syslog", &hints, &res); + error = getaddrinfo(bindhostname, "syslog", &hints, &res); if (error) { logerror(gai_strerror(error)); errno = 0; |