Bug#2363: xntpd fails in 1.3.x kernels
Package: xntp
Version: 3.4x-2
xntpd gets an error and dies when run in a 1.3.x kernel (e.g. x==63).
The reason for this is that these kernels check SO_REUSEADDR for
previously bound wildcard sockets when opening other sockets on the
same port. Apparently this is somewhat unusual since xntpd assumes
that this doesn't matter and disables SO_REUSEADDR for each socket
immediately following the bind() call.
Here is a patch that fixes the bug:
--- xntpd/ntp_io.c.~1~ Sun Jul 30 16:52:22 1995
+++ xntpd/ntp_io.c Tue Feb 20 04:30:33 1996
@@ -799,10 +799,15 @@
* On normal systems it only gets looked at when the address
* is being bound anyway..
*/
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
- (char *)&off, sizeof(off))) {
- syslog(LOG_ERR, "setsockopt SO_REUSEADDR off fails: %m");
- }
+#if defined(SYS_LINUX)
+ /* In kernel 1.3.x, the value of SO_REUSEADDR matters for
+ wildcard sockets; turning it off will cause an error later. */
+ if (ntohl(addr->sin_addr.s_addr) != INADDR_ANY)
+#endif
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
+ (char *)&off, sizeof(off))) {
+ syslog(LOG_ERR, "setsockopt SO_REUSEADDR off fails: %m");
+ }
#ifdef SO_BROADCAST
/* if this interface can support broadcast, set SO_BROADCAST */
Reply to: