summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-09-01 08:42:49 +0000
committerdd <dd@FreeBSD.org>2001-09-01 08:42:49 +0000
commit396c50b0c10ef7bd39a5ac7d7232a64ee4e41160 (patch)
tree6f788de6ece24520f83741e4da05c85409167f99 /usr.sbin
parentc96eebc7a1aa275953e64896ff9b2e3aae631004 (diff)
downloadFreeBSD-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')
-rw-r--r--usr.sbin/syslogd/syslogd.85
-rw-r--r--usr.sbin/syslogd/syslogd.c16
2 files changed, 16 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index 5e56d25..641bb4a 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -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 @@ The
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
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;
OpenPOWER on IntegriCloud