diff -ur sysklogd-1.4.1.orig/sysklogd.8 sysklogd-1.4.1/sysklogd.8 --- sysklogd-1.4.1.orig/sysklogd.8 Sun Mar 11 22:35:51 2001 +++ sysklogd-1.4.1/sysklogd.8 Mon Oct 8 07:20:31 2001 @@ -15,6 +15,9 @@ .I config file ] .RB [ " \-h " ] +.RB [ " \-i " +.I IP address +] .RB [ " \-l " .I hostlist ] @@ -103,6 +106,13 @@ Specifying this switch on the command line will cause the log daemon to forward any remote messages it receives to forwarding hosts which have been defined. +.TP +.BI "\-i " "IP address" +If +.B syslogd +is configured to accept log input from a UDP port, specify an IP address +to bind to, rather than the default of INADDR_ANY. The address must be in +dotted quad notation, DNS host names are not allowed. .TP .BI "\-l " "hostlist" Specify a hostname that should be logged only with its simple hostname diff -ur sysklogd-1.4.1.orig/syslogd.c sysklogd-1.4.1/syslogd.c --- sysklogd-1.4.1.orig/syslogd.c Sun Mar 11 22:40:10 2001 +++ sysklogd-1.4.1/syslogd.c Mon Oct 8 07:24:41 2001 @@ -736,6 +736,8 @@ int NoHops = 1; /* Can we bounce syslog messages through an intermediate host. */ +char *bind_addr = NULL; /* bind UDP port to this interface only */ + extern int errno; /* Function prototypes. */ @@ -829,7 +831,7 @@ funix[i] = -1; } - while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF) + while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:v")) != EOF) switch((char)ch) { case 'a': if (nfunix < MAXFUNIX) @@ -846,9 +848,17 @@ case 'h': NoHops = 0; break; + case 'i': + if (bind_addr) { + fprintf(stderr, "Only one -i argument allowed, " + "the first one is taken.\n"); + break; + } + bind_addr = optarg; + break; case 'l': if (LocalHosts) { - fprintf (stderr, "Only one -l argument allowed," \ + fprintf(stderr, "Only one -l argument allowed, " "the first one is taken.\n"); break; } @@ -1175,7 +1185,7 @@ int usage() { fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ - " [-s domainlist] [-f conffile]\n"); + " [-s domainlist] [-f conffile] [-i IP address]\n"); exit(1); } @@ -1217,15 +1227,22 @@ int fd, on = 1; struct sockaddr_in sin; + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_port = LogPort; + if (bind_addr) { + if (!inet_aton(bind_addr, &sin.sin_addr)) { + logerror("syslog: not a valid IP address to bind to."); + return -1; + } + } + fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { logerror("syslog: Unknown protocol, suspending inet service."); return fd; } - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_port = LogPort; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \ (char *) &on, sizeof(on)) < 0 ) { logerror("setsockopt(REUSEADDR), suspending inet");