diff options
author | Gerrit Pape <pape@smarden.org> | 2007-04-17 07:49:14 +0000 |
---|---|---|
committer | Gerrit Pape <pape@innominate.com> | 2007-04-17 07:49:14 +0000 |
commit | e700f4187491f96d35387e304f5b8c3b9485fc78 (patch) | |
tree | 8d5274e65ba9fd851d758a23a58e7845b230d3bf | |
parent | cf45c27c0b81d495e961ac83a8bbd9b6569047a7 (diff) | |
download | runit-e700f4187491f96d35387e304f5b8c3b9485fc78.tar.gz runit-e700f4187491f96d35387e304f5b8c3b9485fc78.tar.xz runit-e700f4187491f96d35387e304f5b8c3b9485fc78.zip |
svlogd.c: don't statically bind local udp socket
..., but request new source port for each log message sent through udp.
-rw-r--r-- | package/CHANGES | 2 | ||||
-rw-r--r-- | src/svlogd.c | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/package/CHANGES b/package/CHANGES index c87d85a..9a0fae3 100644 --- a/package/CHANGES +++ b/package/CHANGES @@ -4,6 +4,8 @@ in short time. * chpst.c, uidgid.c: improve error reporting if getpwnam() or getgrnam() fails; cleanup. + * svlogd.c: don't statically bind local udp socket, but request new + source port for each log message sent through udp. 1.7.2 Tue, 21 Nov 2006 15:13:47 +0000 diff --git a/src/svlogd.c b/src/svlogd.c index b267b70..5e55a90 100644 --- a/src/svlogd.c +++ b/src/svlogd.c @@ -507,14 +507,6 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { else port =514; ld->udpaddr.sin_port =htons(port); - if (fdudp == -1) { - fdudp =socket(AF_INET, SOCK_DGRAM, 0); - if (fdudp) - if (ndelay_on(fdudp) == -1) { - close(fdudp); - fdudp =-1; - } - } break; case 'p': if (len > 1) { @@ -756,7 +748,7 @@ int main(int argc, const char **argv) { case 2: fmt_ptime(stamp, &now); break; case 3: fmt_ptime_iso8601(stamp, &now); break; } - stamp[25] =' '; stamp[26] =0; + stamp[25] =' '; stamp[26] =0; } if (ch == '\n') break; if (repl) { @@ -784,6 +776,12 @@ int main(int argc, const char **argv) { } if (dir[i].match != '+') continue; if (dir[i].udpaddr.sin_port != 0) { + fdudp =socket(AF_INET, SOCK_DGRAM, 0); + if (fdudp) + if (ndelay_on(fdudp) == -1) { + close(fdudp); + fdudp =-1; + } if (fdudp == -1) { buffer_puts(&dir[i].b, "warning: no udp socket available: "); if (timestamp) buffer_puts(&dir[i].b, stamp); @@ -809,6 +807,7 @@ int main(int argc, const char **argv) { buffer_put(&dir[i].b, sa.s, sa.len); buffer_flush(&dir[i].b); } + close(fdudp); } } if (! dir[i].udponly) { |