]> git.pld-linux.org Git - packages/sysklogd.git/blob - sysklogd-bind.patch
- updated for 1.5
[packages/sysklogd.git] / sysklogd-bind.patch
1 --- sysklogd-1.5/sysklogd.8.orig        2007-05-27 14:16:17.000000000 +0200
2 +++ sysklogd-1.5/sysklogd.8     2007-09-03 23:39:50.712669654 +0200
3 @@ -15,6 +15,9 @@
4  .I config file
5  ]
6  .RB [ " \-h " ] 
7 +.RB [ " \-i "
8 +.I IP address
9 +]
10  .RB [ " \-l "
11  .I hostlist
12  ]
13 @@ -103,6 +106,13 @@
14  This can cause syslog loops that fill up hard disks quite fast and
15  thus needs to be used with caution.
16  .TP
17 +.BI "\-i " "IP address"
18 +If
19 +.B syslogd
20 +is configured to accept log input from a UDP port, specify an IP address
21 +to bind to, rather than the default of INADDR_ANY.  The address must be in
22 +dotted quad notation, DNS host names are not allowed.
23 +.TP
24  .BI "\-l " "hostlist"
25  Specify a hostname that should be logged only with its simple hostname
26  and not the fqdn.  Multiple hosts may be specified using the colon
27 diff -ur sysklogd-1.4.1.orig/syslogd.c sysklogd-1.4.1/syslogd.c
28 --- sysklogd-1.4.1.orig/syslogd.c       Sun Mar 11 22:40:10 2001
29 +++ sysklogd-1.4.1/syslogd.c    Mon Oct  8 07:24:41 2001
30 @@ -736,6 +736,8 @@
31  int    NoHops = 1;             /* Can we bounce syslog messages through an
32                                    intermediate host. */
33  
34 +char   *bind_addr = NULL;      /* bind UDP port to this interface only */
35 +
36  extern int errno;
37  
38  /* Function prototypes. */
39 @@ -829,7 +831,7 @@
40                 funix[i]  = -1;
41         }
42  
43 -       while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
44 +       while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:v")) != EOF)
45                 switch((char)ch) {
46                 case 'a':
47                         if (nfunix < MAXFUNIX)
48 @@ -846,9 +848,17 @@
49                 case 'h':
50                         NoHops = 0;
51                         break;
52 +               case 'i':
53 +                       if (bind_addr) {
54 +                               fprintf(stderr, "Only one -i argument allowed, "
55 +                                       "the first one is taken.\n");
56 +                               break;
57 +                       }
58 +                       bind_addr = optarg;
59 +                       break;
60                 case 'l':
61                         if (LocalHosts) {
62 -                               fprintf (stderr, "Only one -l argument allowed," \
63 +                               fprintf(stderr, "Only one -l argument allowed, "
64                                         "the first one is taken.\n");
65                                 break;
66                         }
67 @@ -1175,7 +1185,7 @@
68  int usage()
69  {
70         fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
71 -               " [-s domainlist] [-f conffile]\n");
72 +               " [-s domainlist] [-f conffile] [-i IP address]\n");
73         exit(1);
74  }
75  
76 @@ -1217,15 +1227,22 @@
77         int fd, on = 1;
78         struct sockaddr_in sin;
79  
80 +       memset(&sin, 0, sizeof(sin));
81 +       sin.sin_family = AF_INET;
82 +       sin.sin_port = LogPort;
83 +       if (bind_addr) {
84 +               if (!inet_aton(bind_addr, &sin.sin_addr)) {
85 +                       logerror("syslog: not a valid IP address to bind to.");
86 +                       return -1;
87 +               }
88 +       }
89 +
90         fd = socket(AF_INET, SOCK_DGRAM, 0);
91         if (fd < 0) {
92                 logerror("syslog: Unknown protocol, suspending inet service.");
93                 return fd;
94         }
95  
96 -       memset(&sin, 0, sizeof(sin));
97 -       sin.sin_family = AF_INET;
98 -       sin.sin_port = LogPort;
99         if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \
100                        (char *) &on, sizeof(on)) < 0 ) {
101                 logerror("setsockopt(REUSEADDR), suspending inet");
This page took 0.425623 seconds and 4 git commands to generate.