Date: Wed, 29 Aug 2001 22:19:23 -0700 From: Dima Dorfman <dima@unixfreak.org> To: audit@freebsd.org Subject: syslogd option to bind to specific address Message-ID: <20010830051928.775393E2F@bazooka.unixfreak.org>
next in thread | raw e-mail | index | archive | help
Please review the attacehd patch to: 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. Thanks. Index: syslogd.8 =================================================================== RCS file: /home/ncvs/src/usr.sbin/syslogd/syslogd.8,v retrieving revision 1.40 diff -u -r1.40 syslogd.8 --- syslogd.8 2001/08/27 11:04:09 1.40 +++ syslogd.8 2001/08/27 11:11:10 @@ -42,6 +42,7 @@ .Nm .Op Fl 46Adknsuv .Op Fl a Ar allowed_peer +.Op Fl b Ar bind_address .Op Fl f Ar config_file .Op Fl m Ar mark_interval .Op Fl p Ar log_socket @@ -151,6 +152,10 @@ options are ignored if the .Fl s option is also specified. +.It Fl b Ar bind_address +Specify one specific IP address or hostname to bind to. +If a hostname is specified, +the IPv4 or IPv6 address which corresponds to it is used. .It Fl d Put .Nm Index: syslogd.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/syslogd/syslogd.c,v retrieving revision 1.80 diff -u -r1.80 syslogd.c --- syslogd.c 2001/07/19 22:04:09 1.80 +++ syslogd.c 2001/08/27 11:11:11 @@ -291,7 +291,7 @@ void die __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)); @@ -319,13 +319,15 @@ struct sockaddr_storage frominet; FILE *fp; char *p, *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; @@ -342,6 +344,9 @@ if (allowaddr(optarg) == -1) usage(); break; + case 'b': + bindhostname = optarg; + break; case 'd': /* debug */ Debug++; break; @@ -447,7 +452,7 @@ } } if (SecureMode <= 1) - finet = socksetup(family); + finet = socksetup(family, bindhostname); if (finet) { if (SecureMode) { @@ -2235,8 +2240,9 @@ } int * -socksetup(af) +socksetup(af, bindhostname) int af; + const char *bindhostname; { struct addrinfo hints, *res, *r; int error, maxs, *s, *socks; @@ -2245,7 +2251,7 @@ 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; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010830051928.775393E2F>