1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
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,8 +106,15 @@
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.
This can cause syslog loops that fill up hard disks quite fast and
thus needs to be used with caution.
+.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");
|