diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95b8f3e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/ntp-4.2.6p5.tar.gz +SOURCES/ntpstat-0.2.tgz diff --git a/.ntp.metadata b/.ntp.metadata new file mode 100644 index 0000000..ffc3452 --- /dev/null +++ b/.ntp.metadata @@ -0,0 +1,2 @@ +4a5353a4791b6f4315a66c28d504ec6c7926b192 SOURCES/ntp-4.2.6p5.tar.gz +9b6baf20b5943651a6bf8d6cf9a78e318573b541 SOURCES/ntpstat-0.2.tgz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/ntp-4.2.4p7-getprecision.patch b/SOURCES/ntp-4.2.4p7-getprecision.patch new file mode 100644 index 0000000..ecf6def --- /dev/null +++ b/SOURCES/ntp-4.2.4p7-getprecision.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.4p7/ntpd/ntp_proto.c.getprecision ntp-4.2.4p7/ntpd/ntp_proto.c +--- ntp-4.2.4p7/ntpd/ntp_proto.c.getprecision 2009-09-29 14:16:22.000000000 +0200 ++++ ntp-4.2.4p7/ntpd/ntp_proto.c 2009-09-29 14:18:13.000000000 +0200 +@@ -3099,7 +3099,7 @@ peer_unfit( + /* + * Find the precision of this particular machine + */ +-#define MINSTEP 100e-9 /* minimum clock increment (s) */ ++#define MINSTEP 10e-9 /* minimum clock increment (s) */ + #define MAXSTEP 20e-3 /* maximum clock increment (s) */ + #define MINLOOPS 5 /* minimum number of step samples */ + diff --git a/SOURCES/ntp-4.2.6p1-cmsgalign.patch b/SOURCES/ntp-4.2.6p1-cmsgalign.patch new file mode 100644 index 0000000..0e4b8cc --- /dev/null +++ b/SOURCES/ntp-4.2.6p1-cmsgalign.patch @@ -0,0 +1,14 @@ +diff -up ntp-4.2.6p1/ntpd/ntp_io.c.cmsgalign ntp-4.2.6p1/ntpd/ntp_io.c +--- ntp-4.2.6p1/ntpd/ntp_io.c.cmsgalign 2010-03-04 18:28:53.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntp_io.c 2010-03-04 18:30:34.000000000 +0100 +@@ -3194,8 +3194,8 @@ read_network_packet( + msghdr.msg_namelen = fromlen; + msghdr.msg_iov = &iovec; + msghdr.msg_iovlen = 1; +- msghdr.msg_control = (void *)&control; +- msghdr.msg_controllen = sizeof(control); ++ msghdr.msg_control = (void *)((long)(control + 7) & -8); /* align to 8 bytes */ ++ msghdr.msg_controllen = sizeof(control) - 8; + msghdr.msg_flags = 0; + rb->recv_length = recvmsg(fd, &msghdr, 0); + #endif diff --git a/SOURCES/ntp-4.2.6p1-linkfastmath.patch b/SOURCES/ntp-4.2.6p1-linkfastmath.patch new file mode 100644 index 0000000..5a859d3 --- /dev/null +++ b/SOURCES/ntp-4.2.6p1-linkfastmath.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p1/ntpd/Makefile.in.linkfastmath ntp-4.2.6p1/ntpd/Makefile.in +--- ntp-4.2.6p1/ntpd/Makefile.in.linkfastmath 2010-02-09 11:19:25.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/Makefile.in 2010-03-03 16:57:40.000000000 +0100 +@@ -365,7 +365,7 @@ man_MANS = $(srcdir)/ntpd.1 + # sqrt ntp_control.o + # floor refclock_wwv.o + # which are (usually) provided by -lm. +-ntpd_LDADD = $(LDADD) $(LIBOPTS_LDADD) ../libntp/libntp.a -lm @LCRYPTO@ @LSCF@ ++ntpd_LDADD = $(LDADD) $(LIBOPTS_LDADD) ../libntp/libntp.a -lm -ffast-math @LCRYPTO@ @LSCF@ + ntpdsim_LDADD = $(LDADD) $(LIBOPTS_LDADD) ../libntp/libntpsim.a -lm @LCRYPTO@ @LSCF@ + ntpdsim_CFLAGS = $(CFLAGS) -DSIM + check_y2k_LDADD = $(LDADD) ../libntp/libntp.a diff --git a/SOURCES/ntp-4.2.6p1-retcode.patch b/SOURCES/ntp-4.2.6p1-retcode.patch new file mode 100644 index 0000000..6d676d2 --- /dev/null +++ b/SOURCES/ntp-4.2.6p1-retcode.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p1/ntpd/ntp_proto.c.retcode ntp-4.2.6p1/ntpd/ntp_proto.c +--- ntp-4.2.6p1/ntpd/ntp_proto.c.retcode 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntp_proto.c 2010-03-03 16:06:00.000000000 +0100 +@@ -269,7 +269,7 @@ transmit( + "ntpd: no servers found"); + printf( + "ntpd: no servers found\n"); +- exit (0); ++ exit (1); + } + } + } diff --git a/SOURCES/ntp-4.2.6p1-sleep.patch b/SOURCES/ntp-4.2.6p1-sleep.patch new file mode 100644 index 0000000..577ef26 --- /dev/null +++ b/SOURCES/ntp-4.2.6p1-sleep.patch @@ -0,0 +1,495 @@ +diff -up ntp-4.2.6p1/include/ntp_refclock.h.sleep ntp-4.2.6p1/include/ntp_refclock.h +--- ntp-4.2.6p1/include/ntp_refclock.h.sleep 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p1/include/ntp_refclock.h 2010-03-10 19:27:46.000000000 +0100 +@@ -260,6 +260,7 @@ extern void refclock_control (sockaddr_u + struct refclockstat *); + extern int refclock_open (char *, u_int, u_int); + extern int refclock_setup (int, u_int, u_int); ++extern int refclock_timer_needed (struct peer *); + extern void refclock_timer (struct peer *); + extern void refclock_transmit (struct peer *); + extern int refclock_ioctl (int, u_int); +diff -up ntp-4.2.6p1/include/ntp_stdlib.h.sleep ntp-4.2.6p1/include/ntp_stdlib.h +--- ntp-4.2.6p1/include/ntp_stdlib.h.sleep 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p1/include/ntp_stdlib.h 2010-03-10 19:27:46.000000000 +0100 +@@ -116,6 +116,7 @@ extern const char * FindConfig (const ch + extern void signal_no_reset (int, RETSIGTYPE (*func)(int)); + + extern void getauthkeys (const char *); ++extern int auth_agekeys_needed (void); + extern void auth_agekeys (void); + extern void rereadkeys (void); + +diff -up ntp-4.2.6p1/include/ntpd.h.sleep ntp-4.2.6p1/include/ntpd.h +--- ntp-4.2.6p1/include/ntpd.h.sleep 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p1/include/ntpd.h 2010-03-10 19:27:46.000000000 +0100 +@@ -112,8 +112,10 @@ extern void block_io_and_alarm (void); + /* ntp_loopfilter.c */ + extern void init_loopfilter(void); + extern int local_clock(struct peer *, double); +-extern void adj_host_clock(void); ++extern int adj_host_clock_needed(void); ++extern void adj_host_clock(int); + extern void loop_config(int, double); ++extern int huffpuff_enabled(void); + extern void huffpuff(void); + extern u_long sys_clocktime; + extern u_int sys_tai; +@@ -219,6 +221,8 @@ extern void hack_restrict (int, sockaddr + /* ntp_timer.c */ + extern void init_timer (void); + extern void reinit_timer (void); ++extern double get_timeout (l_fp *); ++extern int timer_elapsed (l_fp, int); + extern void timer (void); + extern void timer_clr_stats (void); + extern void timer_interfacetimeout (u_long); +diff -up ntp-4.2.6p1/libntp/authkeys.c.sleep ntp-4.2.6p1/libntp/authkeys.c +--- ntp-4.2.6p1/libntp/authkeys.c.sleep 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p1/libntp/authkeys.c 2010-03-10 19:27:46.000000000 +0100 +@@ -445,6 +445,25 @@ auth_delkeys(void) + } + } + ++int ++auth_agekeys_needed(void) { ++ struct savekey *sk; ++ int i; ++ ++ if (authnumkeys > 20) ++ return 1; ++ ++ for (i = 0; i < HASHSIZE; i++) { ++ sk = key_hash[i]; ++ while (sk != 0) { ++ if (sk->lifetime > 0) ++ return 1; ++ sk = sk->next; ++ } ++ } ++ return 0; ++} ++ + /* + * auth_agekeys - delete keys whose lifetimes have expired + */ +diff -up ntp-4.2.6p1/ntpd/ntp_loopfilter.c.sleep ntp-4.2.6p1/ntpd/ntp_loopfilter.c +--- ntp-4.2.6p1/ntpd/ntp_loopfilter.c.sleep 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntp_loopfilter.c 2010-03-10 19:27:46.000000000 +0100 +@@ -677,6 +677,13 @@ local_clock( + #endif /* LOCKCLOCK */ + } + ++int ++adj_host_clock_needed(void) ++{ ++ return !(!ntp_enable || mode_ntpdate || (pll_control && ++ kern_enable)); ++} ++ + + /* + * adj_host_clock - Called once every second to update the local clock. +@@ -686,7 +693,7 @@ local_clock( + */ + void + adj_host_clock( +- void ++ int time_elapsed + ) + { + double adjustment; +@@ -698,7 +705,7 @@ adj_host_clock( + * since the poll interval can exceed one day, the old test + * would be counterproductive. + */ +- sys_rootdisp += clock_phi; ++ sys_rootdisp += clock_phi * time_elapsed; + + #ifndef LOCKCLOCK + /* +@@ -819,6 +826,12 @@ set_freq( + #endif /* KERNEL_PLL */ + } + ++int ++huffpuff_enabled(void) ++{ ++ return sys_huffpuff != NULL; ++} ++ + /* + * huff-n'-puff filter + */ +diff -up ntp-4.2.6p1/ntpd/ntp_refclock.c.sleep ntp-4.2.6p1/ntpd/ntp_refclock.c +--- ntp-4.2.6p1/ntpd/ntp_refclock.c.sleep 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntp_refclock.c 2010-03-10 19:27:46.000000000 +0100 +@@ -268,6 +268,21 @@ refclock_unpeer( + } + + ++int ++refclock_timer_needed( ++ struct peer *peer /* peer structure pointer */ ++ ) ++{ ++ u_char clktype; ++ int unit; ++ ++ clktype = peer->refclktype; ++ unit = peer->refclkunit; ++ if (refclock_conf[clktype]->clock_timer != noentry) ++ return 1; ++ return 0; ++} ++ + /* + * refclock_timer - called once per second for housekeeping. + */ +diff -up ntp-4.2.6p1/ntpd/ntp_timer.c.sleep ntp-4.2.6p1/ntpd/ntp_timer.c +--- ntp-4.2.6p1/ntpd/ntp_timer.c.sleep 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntp_timer.c 2010-03-11 15:23:59.000000000 +0100 +@@ -56,7 +56,6 @@ static u_long adjust_timer; /* second ti + static u_long stats_timer; /* stats timer */ + static u_long huffpuff_timer; /* huff-n'-puff timer */ + u_long leapsec; /* leapseconds countdown */ +-l_fp sys_time; /* current system time */ + #ifdef OPENSSL + static u_long revoke_timer; /* keys revoke timer */ + static u_long keys_timer; /* session key timer */ +@@ -74,6 +73,12 @@ volatile u_long alarm_overflow; + #define DAY (24 * HOUR) + + u_long current_time; /* seconds since startup */ ++l_fp timer_base; ++int time_elapsed; ++ ++#define TIMEOUT_TS_SIZE 2 ++l_fp timeout_ts[TIMEOUT_TS_SIZE]; ++unsigned int timeout_ts_index; + + /* + * Stats. Number of overflows and number of calls to transmit(). +@@ -110,6 +115,8 @@ static RETSIGTYPE alarming (int); + void + reinit_timer(void) + { ++ get_systime(&timer_base); ++#if 0 + #if !defined(SYS_WINNT) && !defined(VMS) + # if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME) + timer_gettime(ntpd_timerid, &itimer); +@@ -143,6 +150,7 @@ reinit_timer(void) + setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); + # endif + # endif /* VMS */ ++#endif + } + + /* +@@ -165,6 +173,12 @@ init_timer(void) + timer_xmtcalls = 0; + timer_timereset = 0; + ++ get_systime(&timer_base); ++ ++ for (timeout_ts_index = 0; timeout_ts_index < TIMEOUT_TS_SIZE; timeout_ts_index++) ++ L_CLR(&timeout_ts[timeout_ts_index]); ++ timeout_ts_index = 0; ++#if 0 + #if !defined(SYS_WINNT) + /* + * Set up the alarm interrupt. The first comes 2**EVENT_TIMEOUT +@@ -226,6 +240,7 @@ init_timer(void) + } + + #endif /* SYS_WINNT */ ++#endif + } + + #if defined(SYS_WINNT) +@@ -236,6 +251,104 @@ get_timer_handle(void) + } + #endif + ++double ++get_timeout(l_fp *now) ++{ ++ register struct peer *peer, *next_peer; ++ u_int n; ++ double r; ++ int next; ++ l_fp ts; ++ ++ ts = *now; ++ L_SUB(&ts, &timeout_ts[timeout_ts_index]); ++ timeout_ts[timeout_ts_index] = *now; ++ timeout_ts_index = (timeout_ts_index + 1) % TIMEOUT_TS_SIZE; ++ ++ /* don't waste CPU time if called too frequently */ ++ if (ts.l_ui == 0) { ++ next = 1; ++ goto finish; ++ } ++ ++ next = current_time + HOUR; ++ ++ if (adj_host_clock_needed()) { ++ next = 1; ++ goto finish; ++ } ++ for (n = 0; n < NTP_HASH_SIZE; n++) { ++ for (peer = peer_hash[n]; peer != 0; peer = next_peer) { ++ next_peer = peer->next; ++#ifdef REFCLOCK ++ if (peer->flags & FLAG_REFCLOCK && refclock_timer_needed(peer)) { ++ next = 1; ++ goto finish; ++ } ++#endif /* REFCLOCK */ ++ if (peer->action) ++ next = min(next, peer->nextaction); ++ next = min(next, peer->nextdate); ++ } ++ } ++ ++ if (leapsec > 0) ++ next = min(next, leapsec); ++ ++ if (huffpuff_enabled()) ++ next = min(next, huffpuff_timer); ++ ++#ifdef OPENSSL ++ if (auth_agekeys_needed()) ++ next = min(next, keys_timer); ++ if (sys_leap != LEAP_NOTINSYNC) ++ next = min(next, revoke_timer); ++#endif /* OPENSSL */ ++ ++ if (interface_interval) ++ next = min(next, interface_timer); ++ ++ next = min(next, stats_timer); ++ ++ next -= current_time; ++ if (next <= 0) ++ next = 1; ++finish: ++ ts = timer_base; ++ ts.l_ui += next; ++ L_SUB(&ts, now); ++ LFPTOD(&ts, r); ++#ifdef DEBUG ++ DPRINTF(2, ("timer: timeout %f\n", r)); ++#endif ++ ++ return r; ++} ++ ++int ++timer_elapsed(l_fp now, int timeout) ++{ ++ int elapsed; ++ ++ L_SUB(&now, &timer_base); ++ elapsed = now.l_i; ++ if (elapsed < 0 || elapsed > timeout + 10) { ++#ifdef DEBUG ++ DPRINTF(2, ("timer: unexpected time jump\n")); ++#endif ++ elapsed = 0; ++ reinit_timer(); ++ ++ } ++ timer_base.l_ui += elapsed; ++ time_elapsed += elapsed; ++ current_time += elapsed; ++#ifdef DEBUG ++ DPRINTF(2, ("timer: time elapsed %d\n", time_elapsed)); ++#endif ++ return time_elapsed; ++} ++ + /* + * timer - event timer + */ +@@ -251,11 +364,9 @@ timer(void) + * kiss-o'-deatch function and implement the association + * polling function.. + */ +- current_time++; +- get_systime(&sys_time); + if (adjust_timer <= current_time) { +- adjust_timer += 1; +- adj_host_clock(); ++ adjust_timer += time_elapsed; ++ adj_host_clock(time_elapsed); + #ifdef REFCLOCK + for (n = 0; n < NTP_HASH_SIZE; n++) { + for (peer = peer_hash[n]; peer != 0; peer = next_peer) { +@@ -286,7 +397,7 @@ timer(void) + * 128 s or less. + */ + if (peer->throttle > 0) +- peer->throttle--; ++ peer->throttle -= min(peer->throttle, time_elapsed); + if (peer->nextdate <= current_time) { + #ifdef REFCLOCK + if (peer->flags & FLAG_REFCLOCK) +@@ -333,7 +444,7 @@ timer(void) + * set. + */ + if (leapsec > 0) { +- leapsec--; ++ leapsec -= min(leapsec, time_elapsed); + if (leapsec == 0) { + sys_leap = LEAP_NOWARNING; + sys_tai = leap_tai; +@@ -398,11 +509,15 @@ timer(void) + * Finally, write hourly stats. + */ + if (stats_timer <= current_time) { ++ l_fp sys_time; ++ get_systime(&sys_time); + stats_timer += HOUR; + write_stats(); + if (sys_tai != 0 && sys_time.l_ui > leap_expire) + report_event(EVNT_LEAPVAL, NULL, NULL); + } ++ ++ time_elapsed = 0; + } + + +diff -up ntp-4.2.6p1/ntpd/ntpd.c.sleep ntp-4.2.6p1/ntpd/ntpd.c +--- ntp-4.2.6p1/ntpd/ntpd.c.sleep 2010-03-10 19:27:46.000000000 +0100 ++++ ntp-4.2.6p1/ntpd/ntpd.c 2010-03-10 19:27:46.000000000 +0100 +@@ -195,8 +195,6 @@ extern const char *Version; + + char const *progname; + +-int was_alarmed; +- + #ifdef DECL_SYSCALL + /* + * We put this here, since the argument profile is syscall-specific +@@ -1033,7 +1031,7 @@ getgroup: + #else /* normal I/O */ + + BLOCK_IO_AND_ALARM(); +- was_alarmed = 0; ++ + for (;;) + { + # if !defined(HAVE_SIGNALED_IO) +@@ -1041,42 +1039,39 @@ getgroup: + extern int maxactivefd; + + fd_set rdfdes; +- int nfound; +-# endif ++ int nfound, time_elapsed; + +- if (alarm_flag) /* alarmed? */ +- { +- was_alarmed = 1; +- alarm_flag = 0; +- } ++ time_elapsed = 0; ++# endif + +- if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE) ++ if (has_full_recv_buffer() == ISC_FALSE) + { + /* + * Nothing to do. Wait for something. + */ + # ifndef HAVE_SIGNALED_IO ++ double timeout; ++ + rdfdes = activefds; +-# if defined(VMS) || defined(SYS_VXWORKS) +- /* make select() wake up after one second */ +- { +- struct timeval t1; ++ get_systime(&now); ++ timeout = get_timeout(&now); + +- t1.tv_sec = 1; t1.tv_usec = 0; ++ if (timeout > 0.0) { ++ struct timeval t1; ++ ++ t1.tv_sec = timeout; ++ t1.tv_usec = (timeout - t1.tv_sec) * 1000000; + nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, + (fd_set *)0, &t1); +- } +-# else +- nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0, +- (fd_set *)0, (struct timeval *)0); +-# endif /* VMS */ +- if (nfound > 0) +- { +- l_fp ts; ++ get_systime(&now); ++ } else ++ nfound = 0; + +- get_systime(&ts); ++ time_elapsed = timer_elapsed(now, timeout); + +- (void)input_handler(&ts); ++ if (nfound > 0) ++ { ++ (void)input_handler(&now); + } + else if (nfound == -1 && errno != EINTR) + msyslog(LOG_ERR, "select() error: %m"); +@@ -1085,17 +1080,13 @@ getgroup: + msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound); + # endif /* DEBUG */ + # else /* HAVE_SIGNALED_IO */ ++# error not supported by sleep patch + + wait_for_signal(); + # endif /* HAVE_SIGNALED_IO */ +- if (alarm_flag) /* alarmed? */ +- { +- was_alarmed = 1; +- alarm_flag = 0; +- } + } + +- if (was_alarmed) ++ if (time_elapsed > 0) + { + UNBLOCK_IO_AND_ALARM(); + /* +@@ -1103,7 +1094,6 @@ getgroup: + * to process expiry. + */ + timer(); +- was_alarmed = 0; + BLOCK_IO_AND_ALARM(); + } + +@@ -1121,19 +1111,8 @@ getgroup: + rbuf = get_full_recv_buffer(); + while (rbuf != NULL) + { +- if (alarm_flag) +- { +- was_alarmed = 1; +- alarm_flag = 0; +- } + UNBLOCK_IO_AND_ALARM(); + +- if (was_alarmed) +- { /* avoid timer starvation during lengthy I/O handling */ +- timer(); +- was_alarmed = 0; +- } +- + /* + * Call the data procedure to handle each received + * packet. diff --git a/SOURCES/ntp-4.2.6p3-bcast.patch b/SOURCES/ntp-4.2.6p3-bcast.patch new file mode 100644 index 0000000..57581f3 --- /dev/null +++ b/SOURCES/ntp-4.2.6p3-bcast.patch @@ -0,0 +1,93 @@ +diff -up ntp-4.2.6p3/ntpd/ntp_io.c.bcast ntp-4.2.6p3/ntpd/ntp_io.c +--- ntp-4.2.6p3/ntpd/ntp_io.c.bcast 2010-12-25 10:40:36.000000000 +0100 ++++ ntp-4.2.6p3/ntpd/ntp_io.c 2011-01-05 17:46:13.820049150 +0100 +@@ -151,6 +151,8 @@ int ninterfaces; /* Total number of in + + int disable_dynamic_updates; /* scan interfaces once only */ + ++static int pktinfo_status = 0; /* is IP_PKTINFO on wildipv4 iface enabled? */ ++ + #ifdef REFCLOCK + /* + * Refclock stuff. We keep a chain of structures with data concerning +@@ -2254,6 +2256,17 @@ set_reuseaddr( + #endif /* ! SO_EXCLUSIVEADDRUSE */ + } + ++static void ++set_pktinfo(int flag) ++{ ++ if (wildipv4 == NULL) ++ return; ++ if (setsockopt(wildipv4->fd, SOL_IP, IP_PKTINFO, &flag, sizeof (flag))) { ++ msyslog(LOG_ERR, "set_pktinfo: setsockopt(IP_PKTINFO, %s) failed: %m", flag ? "on" : "off"); ++ } else ++ pktinfo_status = flag; ++} ++ + /* + * This is just a wrapper around an internal function so we can + * make other changes as necessary later on +@@ -2659,6 +2672,7 @@ io_setbclient(void) + } + } + set_reuseaddr(0); ++ set_pktinfo(1); + if (nif > 0) + DPRINTF(1, ("io_setbclient: Opened broadcast clients\n")); + else if (!nif) +@@ -2685,6 +2699,7 @@ io_unsetbclient(void) + continue; + socket_broadcast_disable(ep, &ep->sin); + } ++ set_pktinfo(0); + } + + /* +@@ -3392,7 +3407,8 @@ read_network_packet( + #ifdef HAVE_TIMESTAMP + struct msghdr msghdr; + struct iovec iovec; +- char control[TIMESTAMP_CTLMSGBUF_SIZE]; ++ char control[sizeof (struct cmsghdr) * 2 + sizeof (struct timeval) + ++ sizeof (struct in_pktinfo) + 32]; + #endif + + /* +@@ -3403,7 +3419,7 @@ read_network_packet( + */ + + rb = get_free_recv_buffer(); +- if (NULL == rb || itf->ignore_packets) { ++ if (NULL == rb || (itf->ignore_packets && !(pktinfo_status && itf == wildipv4))) { + char buf[RX_BUFF_SIZE]; + sockaddr_u from; + +@@ -3463,6 +3479,27 @@ read_network_packet( + return (buflen); + } + ++ if (pktinfo_status && itf->ignore_packets && itf == wildipv4) { ++ /* check for broadcast on 255.255.255.255, exception allowed on wildipv4 */ ++ struct cmsghdr *cmsg; ++ struct in_pktinfo *pktinfo = NULL; ++ ++ if ((cmsg = CMSG_FIRSTHDR(&msghdr))) ++ do { ++ if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO) ++ pktinfo = (struct in_pktinfo *) CMSG_DATA(cmsg); ++ } while ((cmsg = CMSG_NXTHDR(&msghdr, cmsg))); ++ if (pktinfo && pktinfo->ipi_addr.s_addr == INADDR_BROADCAST) { ++ DPRINTF(4, ("INADDR_BROADCAST\n")); ++ } else { ++ DPRINTF(4, ("%s on (%lu) fd=%d from %s\n", "ignore", ++ free_recvbuffs(), fd, stoa(&rb->recv_srcadr))); ++ packets_ignored++; ++ freerecvbuf(rb); ++ return (buflen); ++ } ++ } ++ + DPRINTF(3, ("read_network_packet: fd=%d length %d from %s\n", + fd, buflen, stoa(&rb->recv_srcadr))); + diff --git a/SOURCES/ntp-4.2.6p3-broadcastdelay.patch b/SOURCES/ntp-4.2.6p3-broadcastdelay.patch new file mode 100644 index 0000000..f9c1929 --- /dev/null +++ b/SOURCES/ntp-4.2.6p3-broadcastdelay.patch @@ -0,0 +1,31 @@ +==== ntpd/ntp_proto.c ==== +2010-10-22 01:55:45-04:00, stenn@deacon.udel.edu +2 -5 + [Bug 1670] Fix peer->bias and broadcastdelay + +--- 1.307/ntpd/ntp_proto.c 2010-10-11 21:06:05 -07:00 ++++ 1.308/ntpd/ntp_proto.c 2010-10-21 22:55:45 -07:00 +@@ -929,7 +929,6 @@ receive( + + } else { + peer->delay = sys_bdelay; +- peer->bias = -sys_bdelay / 2.; + } + break; + } +@@ -1570,7 +1569,6 @@ process_packet( + p_del = fabs(t21 - t34); + p_offset = (t21 + t34) / 2.; + } +- p_offset += peer->bias; + p_disp = LOGTOD(sys_precision) + LOGTOD(peer->precision) + + clock_phi * p_del; + +@@ -1647,7 +1645,7 @@ process_packet( + /* + * That was awesome. Now hand off to the clock filter. + */ +- clock_filter(peer, p_offset, p_del, p_disp); ++ clock_filter(peer, p_offset + peer->bias, p_del, p_disp); + + /* + * If we are in broadcast calibrate mode, return to broadcast diff --git a/SOURCES/ntp-4.2.6p4-droproot.patch b/SOURCES/ntp-4.2.6p4-droproot.patch new file mode 100644 index 0000000..1d953d1 --- /dev/null +++ b/SOURCES/ntp-4.2.6p4-droproot.patch @@ -0,0 +1,207 @@ +diff -up ntp-4.2.6p4/html/ntpdate.html.droproot ntp-4.2.6p4/html/ntpdate.html +--- ntp-4.2.6p4/html/ntpdate.html.droproot 2011-07-11 04:18:25.000000000 +0200 ++++ ntp-4.2.6p4/html/ntpdate.html 2011-10-05 15:47:29.643634928 +0200 +@@ -18,7 +18,7 @@ +
+

Disclaimer: The functionality of this program is now available in the ntpd program. See the -q command line option in the ntpd - Network Time Protocol (NTP) daemon page. After a suitable period of mourning, the ntpdate program is to be retired from this distribution

+

Synopsis

+- ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t timeout ] server [ ... ] ++ ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t timeout ] [ -U user_name ] server [ ... ] +

Description

+

ntpdate sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the server arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of ntpdate depends on the number of servers, the number of polls each time it is run and the interval between runs.

+

ntpdate can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon ntpd. It is also possible to run ntpdate from a cron script. However, it is important to note that ntpdate with contrived cron scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use. Finally, since ntpdate does not discipline the host clock frequency as does ntpd, the accuracy using ntpdate is limited.

+@@ -58,6 +58,10 @@ +
Direct ntpdate to use an unprivileged port for outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronize with hosts beyond the firewall. Note that the -d option always uses unprivileged ports. +
-v +
Be verbose. This option will cause ntpdate's version identification string to be logged. ++
-U user_name
++
ntpdate process drops root privileges and changes user ID to ++ user_name and group ID to the primary group of ++ server_user. + +

Diagnostics

+ ntpdate's exit status is zero if it finds a server and updates the clock, and nonzero otherwise. +diff -up ntp-4.2.6p4/ntpdate/ntpdate.c.droproot ntp-4.2.6p4/ntpdate/ntpdate.c +--- ntp-4.2.6p4/ntpdate/ntpdate.c.droproot 2011-05-25 07:06:09.000000000 +0200 ++++ ntp-4.2.6p4/ntpdate/ntpdate.c 2011-10-05 15:45:39.570555972 +0200 +@@ -49,6 +49,12 @@ + + #include + ++/* Linux capabilities */ ++#include ++#include ++#include ++#include ++ + #ifdef SYS_VXWORKS + # include "ioLib.h" + # include "sockLib.h" +@@ -153,6 +159,11 @@ int simple_query = 0; + int unpriv_port = 0; + + /* ++ * Use capabilities to drop privileges and switch uids ++ */ ++char *server_user; ++ ++/* + * Program name. + */ + char *progname; +@@ -294,6 +305,88 @@ void clear_globals() + static ni_namelist *getnetinfoservers (void); + #endif + ++/* This patch is adapted (copied) from Chris Wings drop root patch ++ * for xntpd. ++ */ ++void drop_root(uid_t server_uid, gid_t server_gid) ++{ ++ cap_t caps; ++ ++ if (prctl(PR_SET_KEEPCAPS, 1)) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "prctl(PR_SET_KEEPCAPS, 1) failed"); ++ } ++ else { ++ fprintf(stderr, "prctl(PR_SET_KEEPCAPS, 1) failed.\n"); ++ } ++ exit(1); ++ } ++ ++ if ( setgroups(0, NULL) == -1 ) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "setgroups failed."); ++ } ++ else { ++ fprintf(stderr, "setgroups failed.\n"); ++ } ++ exit(1); ++ } ++ ++ if ( setegid(server_gid) == -1 || seteuid(server_uid) == -1 ) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "setegid/seteuid to uid=%d/gid=%d failed.", server_uid, ++ server_gid); ++ } ++ else { ++ fprintf(stderr, "setegid/seteuid to uid=%d/gid=%d failed.\n", server_uid, ++ server_gid); ++ } ++ exit(1); ++ } ++ ++ caps = cap_from_text("cap_sys_time=epi"); ++ if (caps == NULL) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "cap_from_text failed."); ++ } ++ else { ++ fprintf(stderr, "cap_from_text failed.\n"); ++ } ++ exit(1); ++ } ++ ++ if (cap_set_proc(caps) == -1) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "cap_set_proc failed."); ++ } ++ else { ++ fprintf(stderr, "cap_set_proc failed.\n"); ++ } ++ exit(1); ++ } ++ ++ /* Try to free the memory from cap_from_text */ ++ cap_free( caps ); ++ ++ if ( setregid(server_gid, server_gid) == -1 || ++ setreuid(server_uid, server_uid) == -1 ) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "setregid/setreuid to uid=%d/gid=%d failed.", ++ server_uid, server_gid); ++ } ++ else { ++ fprintf(stderr, "setregid/setreuid to uid=%d/gid=%d failed.\n", ++ server_uid, server_gid); ++ } ++ exit(1); ++ } ++ ++ if (syslogit) { ++ msyslog(LOG_DEBUG, "running as uid(%d)/gid(%d) euid(%d)/egid(%d).", ++ getuid(), getgid(), geteuid(), getegid()); ++ } ++} ++ + /* + * Main program. Initialize us and loop waiting for I/O and/or + * timer expiries. +@@ -341,6 +434,8 @@ ntpdatemain ( + + init_lib(); /* sets up ipv4_works, ipv6_works */ + ++ server_user = NULL; ++ + /* Check to see if we have IPv6. Otherwise default to IPv4 */ + if (!ipv6_works) + ai_fam_templ = AF_INET; +@@ -352,7 +447,7 @@ ntpdatemain ( + /* + * Decode argument list + */ +- while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qst:uv")) != EOF) ++ while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qst:uvU:")) != EOF) + switch (c) + { + case '4': +@@ -429,6 +524,14 @@ ntpdatemain ( + case 'u': + unpriv_port = 1; + break; ++ case 'U': ++ if (ntp_optarg) { ++ server_user = strdup(ntp_optarg); ++ } ++ else { ++ ++errflg; ++ } ++ break; + case '?': + ++errflg; + break; +@@ -438,7 +541,7 @@ ntpdatemain ( + + if (errflg) { + (void) fprintf(stderr, +- "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] server ...\n", ++ "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] [-U username] server ...\n", + progname); + exit(2); + } +@@ -544,6 +647,24 @@ ntpdatemain ( + initializing = 0; + was_alarmed = 0; + ++ if (server_user) { ++ struct passwd *pwd = NULL; ++ ++ /* Lookup server_user uid/gid before chroot/chdir */ ++ pwd = getpwnam( server_user ); ++ if ( pwd == NULL ) { ++ if (syslogit) { ++ msyslog(LOG_ERR, "Failed to lookup user '%s'.", server_user); ++ } ++ else { ++ fprintf(stderr, "Failed to lookup user '%s'.\n", server_user); ++ } ++ exit(1); ++ } ++ drop_root(pwd->pw_uid, pwd->pw_gid); ++ } ++ ++ + while (complete_servers < sys_numservers) { + #ifdef HAVE_POLL_H + struct pollfd* rdfdes; diff --git a/SOURCES/ntp-4.2.6p4-htmldoc.patch b/SOURCES/ntp-4.2.6p4-htmldoc.patch new file mode 100644 index 0000000..8558224 --- /dev/null +++ b/SOURCES/ntp-4.2.6p4-htmldoc.patch @@ -0,0 +1,172 @@ +diff -up ntp-4.2.6p5/html/accopt.html.htmldoc ntp-4.2.6p5/html/accopt.html +--- ntp-4.2.6p5/html/accopt.html.htmldoc 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/html/accopt.html 2015-02-10 14:55:24.467289637 +0100 +@@ -94,8 +94,10 @@ time) in log2 s with default + +
restrict address [mask mask] [flag][...]
+
The address argument expressed in dotted-quad form is the +- address of a host or network. Alternatively, the address argument +- can be a valid host DNS name. The mask argument expressed in ++ address of a host or network. Alternatively, the address argument can be a ++ valid host DNS name, but it must be resolvable at the time when ntpd is started and ++ if it's resolved to multiple addresses, only the first address will be added to the list. ++ The mask argument expressed in + dotted-quad form defaults to 255.255.255.255, meaning that the address is + treated as the address of an individual host. A default entry (address 0.0.0.0, + mask 0.0.0.0) is always included and is always the first entry in the list. +diff -up ntp-4.2.6p5/html/authopt.html.htmldoc ntp-4.2.6p5/html/authopt.html +--- ntp-4.2.6p5/html/authopt.html.htmldoc 2011-07-11 04:18:25.000000000 +0200 ++++ ntp-4.2.6p5/html/authopt.html 2013-03-28 18:04:38.581260191 +0100 +@@ -364,7 +364,7 @@ UTC

+ are left unspecified, the default names are used as described below. Unless + the complete path and name of the file are specified, the location of a file + is relative to the keys directory specified in the keysdir configuration +- command or default /usr/local/etc. Following are the options.
++ command or default /etc/ntp/crypto. Following are the options. + +
+ +@@ -396,7 +396,7 @@ UTC

+
Specifies the complete path to the MD5 key file containing the keys and key IDs used by ntpd, ntpq and ntpdc when operating with symmetric key cryptography. This is the same operation as the -k command line option. Note that the directory path for Autokey media is specified by the keysdir command.
+ +
keysdir pathK
+-
This command specifies the default directory path for Autokey cryptographic keys, parameters and certificates. The default is /usr/local/etc/. Note that the path for the symmetric keys file is specified by the keys command.
++
This command specifies the default directory path for Autokey cryptographic keys, parameters and certificates. The default is /etc/ntp/crypto. Note that the path for the symmetric keys file is specified by the keys command.
+ +
requestkey keyid
+
Specifies the key ID to use with the +diff -up ntp-4.2.6p5/html/keygen.html.htmldoc ntp-4.2.6p5/html/keygen.html +--- ntp-4.2.6p5/html/keygen.html.htmldoc 2011-07-11 04:18:26.000000000 +0200 ++++ ntp-4.2.6p5/html/keygen.html 2013-03-28 18:04:38.581260191 +0100 +@@ -206,7 +206,6 @@ +

All cryptographically sound key generation schemes must have means to randomize the entropy seed used to initialize the internal pseudo-random number generator used by the OpenSSL library routines. If a site supports ssh, it is very likely that means to do this are already available. The entropy seed used by the OpenSSL library is contained in a file, usually called .rnd, which must be available when starting the ntp-keygen program or ntpd daemon.

+ +

The OpenSSL library looks for the file using the path specified by the RANDFILE environment variable in the user home directory, whether root or some other user. If the RANDFILE environment variable is not present, the library looks for the .rnd file in the user home directory. Since both the ntp-keygen program and ntpd daemon must run as root, the logical place to put this file is in /.rnd or /root/.rnd. If the file is not available or cannot be written, the program exits with a message to the system log.

+-

On systems that provide /dev/urandom, the randomness device is used instead and the file specified by the randfile subcommand or the RANDFILE environment variable is ignored.

+ +

Cryptographic Data Files

+ +diff -up ntp-4.2.6p5/html/ntpd.html.htmldoc ntp-4.2.6p5/html/ntpd.html +--- ntp-4.2.6p5/html/ntpd.html.htmldoc 2011-07-11 04:18:26.000000000 +0200 ++++ ntp-4.2.6p5/html/ntpd.html 2017-03-22 11:08:46.864272061 +0100 +@@ -35,12 +35,12 @@ + ntpd [ -46aAbdDgLnNqx ] [ -c conffile ] [ -f driftfile ] [ -i jaildir ] [ -I iface ] [ -k keyfile ] [ -l logfile ] [ -p pidfile ] [ -P priority ] [ -r broadcastdelay ] [ -s statsdir ] [ -t key ] [ -u user[:group] ] [ -U interface_update_interval ] [ -v variable ] [ -V variable ] +

Description

+

The ntpd program is an operating system daemon that synchronises the system clock with remote NTP time servers or local reference clocks. It is a complete implementation of the Network Time Protocol (NTP) version 4, but also retains compatibility with version 3, as defined by RFC-1305, and version 1 and 2, as defined by RFC-1059 and RFC-1119, respectively. The program can operate in any of several modes, as described on the Association Management page, and with both symmetric key and public key cryptography, as described on the Authentication Options page.

+-

The ntpd program ordinarily requires a configuration file as desccribe on the Configuration Commands and Options collection above. However a client can discover remote servers and configure them automatically. This makes it possible to deploy a fleet of workstations without specifying configuration details specific to the local environment. Further details are on the Automatic Server Discovery page.

++

The ntpd program ordinarily requires a configuration file as described on the Configuration Commands and Options collection above. However a client can discover remote servers and configure them automatically. This makes it possible to deploy a fleet of workstations without specifying configuration details specific to the local environment. Further details are on the Automatic Server Discovery page.

+

Once the NTP software distribution has been compiled and installed and the configuration file constructed, the next step is to verify correct operation and fix any bugs that may result. Usually, the command line that starts the daemon is included in the system startup file, so it is executed only at system boot time; however, the daemon can be stopped and restarted from root at any time. Once started, the daemon will begin sending and receiving messages, as specified in the configuration file.

+

Setting the Time and Frequency

+

The ntpd program operates by exchanging messages with one or more servers at designated intervals ranging from about one minute to about 17 minutes. When started, the program requires several exchanges while the algorithms accumulate and groom the data before setting the clock. The initial delay to set the clock can be reduced using options on the Server Options page.

+-

Most compters today incorporate a time-of-year (TOY) chip to maintain the time during periods when the power is off. When the machine is booted, the chip is used to initialize the operating system time. In case there is no TOY chip or the TOY time is more than 1000 s from the server time, ntpd assumes something must be terribly wrong and exits with a panic message to the system operator. With the -g option the clock will be initially set to the server time regardless of the chip time. However, once the clock has been set, an error greater than 1000 s will cause ntpd to exit anyway.

+-

Under ordinary conditions, ntpd slews the clock so that the time is effectively continuous and never runs backwards. If due to extreme network congestion an error spike exceeds the step threshold, by default 128 ms, the spike is discarded. However, if the error persists for more than the stepout threshold, by default 900 s, the system clock is stepped to the correct value. In practice the need for a step has is extremely rare and almost always the result of a hardware failure. With the -x option the step threshold is increased to 600 s. Other options are available using the tinker command on the Miscellaneous Options page.

++

Most computers today incorporate a time-of-year (TOY) chip to maintain the time during periods when the power is off. When the machine is booted, the chip is used to initialize the operating system time. In case there is no TOY chip or the TOY time is more than 1000 s from the server time, ntpd assumes something must be terribly wrong and exits with a panic message to the system operator. With the -g option the clock will be initially set to the server time regardless of the chip time. However, once the clock has been set, an error greater than 1000 s will cause ntpd to exit anyway.

++

Under ordinary conditions, ntpd slews the clock so that the time is effectively continuous and never runs backwards. If due to extreme network congestion an error spike exceeds the step threshold, by default 128 ms, the spike is discarded. However, if the error persists for more than the stepout threshold, by default 900 s, the system clock is stepped to the correct value. In practice the need for a step is extremely rare and is almost always the result of a hardware failure. With the -x option the step threshold is increased to 600 s. Other options are available using the tinker command on the Miscellaneous Options page.

+

The issues should be carefully considered before using these options. The maximum slew rate possible is limited to 500 parts-per-million (PPM) by the Unix kernel. As a result, the clock can take 2000 s for each second the clock is outside the acceptable range. During this interval the clock will not be consistent with any other network clock and the system cannot be used for distributed applications that require correctly synchronized network time.

+

The frequency file, usually called ntp.drift, contains the latest estimate of clock frequency. If this file does not exist when ntpd is started, it enters a special mode designed to measure the particular frequency directly. The measurement takes 15 minutes, after which the frequency is set and ntpd resumes normal mode where the time and frequency are continuously adjusted. The frequency file is updated at intervals of an hour or more depending on the measured clock stability.

+

Operating Modes

+@@ -70,7 +70,7 @@ + tally the leap warning bits of surviving servers and reference clocks. + When a majority of the survivors show warning, a leap is programmed + at the end of the current month. During the month and day of insertion, +- they operate as above. In this way the leap is is propagated at all ++ they operate as above. In this way the leap is propagated at all + dependent servers and clients.

+

Additional Features

+

A new experimental feature called interleaved modes can be used in NTP +@@ -143,26 +143,8 @@ +

Specify a user, and optionally a group, to switch to. This option is only available if the OS supports running the server without full root privileges. Currently, this option is supported under NetBSD (configure with --enable-clockctl) and Linux (configure with --enable-linuxcaps).
+
-U interface update interval
+
Number of seconds to wait between interface list scans to pick up new and delete network interface. Set to 0 to disable dynamic interface list updating. The default is to scan every 5 minutes.
+-
-v variable
+-
-V variable
+-
Add a system variable listed by default.
+
-x
+
Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the -g and -q options. See the tinker command for other options. Note: The kernel time discipline is disabled with this option.
+-
--pccfreq frequency
+-
Substitute processor cycle counter for QueryPerformanceCounter unconditionally +- using the given frequency (in Hz). --pccfreq can be used on systems +- which do not use the PCC to implement QueryPerformanceCounter +- and have a fixed PCC frequency. The frequency specified must +- be accurate within 0.5 percent. --usepcc is equivalent on many systems and should +- be tried first, as it does not require determining the frequency +- of the processor cycle counter. For x86-compatible processors, the PCC is +- also referred to as RDTSC, which is the assembly-language instruction to retrieve +- the current value.  (Windows only)
+-
--usepcc
+-
Substitute processor cycle counter for QueryPerformanceCounter if they +- appear equivalent. This option should be used only if the PCC +- frequency is fixed. Power-saving functionality on many laptops varies the +- PCC frequency. (Windows only)
+
+

The Configuration File

+

Ordinarily, ntpd reads the ntp.conf configuration file at startup in order to determine the synchronization sources and operating modes. It is also possible to specify a working, although limited, configuration entirely on the command line, obviating the need for a configuration file. This may be particularly useful when the local host is to be configured as a broadcast client, with servers determined by listening to broadcasts at run time.

+@@ -214,14 +196,14 @@ + + + statistics path +- /var/NTP ++ /var/log/ntpstats/ + -s + statsdir + + + keys path +- /usr/local/etc +- -k ++ /etc/ntp/crypto ++ none + keysdir + + +diff -up ntp-4.2.6p5/html/ntpdate.html.htmldoc ntp-4.2.6p5/html/ntpdate.html +--- ntp-4.2.6p5/html/ntpdate.html.htmldoc 2013-03-28 18:04:38.556260210 +0100 ++++ ntp-4.2.6p5/html/ntpdate.html 2013-03-28 18:04:38.582260190 +0100 +@@ -43,7 +43,7 @@ +
-e authdelay +
Specify the processing delay to perform an authentication function as the value authdelay, in seconds and fraction (see ntpd for details). This number is usually small enough to be negligible for most purposes, though specifying a value may improve timekeeping on very slow CPU's. +
-k keyfile +-
Specify the path for the authentication key file as the string keyfile. The default is /etc/ntp.keys. This file should be in the format described in ntpd. ++
Specify the path for the authentication key file as the string keyfile. The default is /etc/ntp/keys. This file should be in the format described in ntpd. +
-o version +
Specify the NTP version for outgoing packets as the integer version, which can be 1 or 2. The default is 4. This allows ntpdate to be used with older NTP versions. +
-p samples +@@ -66,7 +66,7 @@ +

Diagnostics

+ ntpdate's exit status is zero if it finds a server and updates the clock, and nonzero otherwise. +

Files

+- /etc/ntp.keys - encryption keys used by ntpdate. ++ /etc/ntp/keys - encryption keys used by ntpdate. +

Bugs

+ The slew adjustment is actually 50% larger than the measured offset, since this (it is argued) will tend to keep a badly drifting clock more accurate. This is probably not a good idea and may cause a troubling hunt for some values of the kernel variables tick and tickadj.  +
+diff -up ntp-4.2.6p5/html/ntptime.html.htmldoc ntp-4.2.6p5/html/ntptime.html +--- ntp-4.2.6p5/html/ntptime.html.htmldoc 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/html/ntptime.html 2013-03-28 18:13:56.921842773 +0100 +@@ -17,7 +17,7 @@ +
+
+

Synopsis

+- ntptime [ -chr ] [ -e est_error ] [ -f frequency ] [ -m max_error ] [ -o offset ] [ -s status ] [ -t time_constant] ++ ntptime [ -MNchr ] [ -e est_error ] [ -f frequency ] [ -m max_error ] [ -o offset ] [ -s status ] [ -t time_constant] [ -T tai_offset ] +

Description

+

This program is useful only with special kernels described in the A Kernel Model for Precision Timekeeping page. It reads and displays time-related kernel variables using the ntp_gettime() system call. A similar display can be obtained using the ntpdc program and kerninfo command.

+

Options

+@@ -40,9 +40,15 @@ +
Specify clock status. Better know what you are doing. +
-t time_constant +
Specify time constant, an integer in the range 0-10. ++
-M ++
Switch to microsecond mode. ++
-N ++
Switch to nanosecond mode. ++
-T tai_offset ++
Set TAI offset. + +
+ + + +- +\ No newline at end of file ++ diff --git a/SOURCES/ntp-4.2.6p5-backfwdstep.patch b/SOURCES/ntp-4.2.6p5-backfwdstep.patch new file mode 100644 index 0000000..4ceb210 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-backfwdstep.patch @@ -0,0 +1,180 @@ +diff -up ntp-4.2.6p5/html/miscopt.html.backfwdstep ntp-4.2.6p5/html/miscopt.html +--- ntp-4.2.6p5/html/miscopt.html.backfwdstep 2015-05-13 17:07:13.553206904 +0200 ++++ ntp-4.2.6p5/html/miscopt.html 2015-05-13 17:55:59.226133427 +0200 +@@ -70,7 +70,7 @@ +
Specify the directory in which to write configuration snapshots requested with ntpq's saveconfig command. If saveconfigdir does not appear in the configuration file, saveconfig requests are rejected by ntpd.
+
setvar variable [default]
+
This command adds an additional system variable. These variables can be used to distribute additional information such as the access policy. If the variable of the form name = value is followed by the default keyword, the variable will be listed as part of the default system variables (ntpq rv command). These additional variables serve informational purposes only. They are not related to the protocol other that they can be listed. The known protocol variables will always override any variables defined via the setvar mechanism. There are three special variables that contain the names of all variable of the same group. The sys_var_list holds the names of all system variables. The peer_var_list holds the names of all peer variables and the clock_var_list holds the names of the reference clock variables.
+-
tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepout stepout ]
++
tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepback step | stepfwd step | stepout stepout ]
+
This command alters certain system variables used by the clock discipline algorithm. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs. The options are as follows:
+
+
allan allan
+@@ -89,6 +89,10 @@ + occur. Note: The kernel time discipline is disabled if + the step threshold is set to zero or greater than 0.5 + s and the threshold is applied also to leap second corrections.
++
stepback step
++
Specifies the step threshold, but only in the backward direction.
++
stepfwd step
++
Specifies the step threshold, but only in the forward direction. To avoid problems with frequency stabilization after large slews it's not recommended to set one direction to a value greater than 0.5 s without setting also the other direction to at least 0.5 s.
+
stepout stepout
+
Specifies the stepout threshold in seconds. The default without this + command is 900 s. If set to zero, popcorn spikes will +diff -up ntp-4.2.6p5/include/ntp.h.backfwdstep ntp-4.2.6p5/include/ntp.h +--- ntp-4.2.6p5/include/ntp.h.backfwdstep 2011-12-01 03:55:17.000000000 +0100 ++++ ntp-4.2.6p5/include/ntp.h 2015-05-13 17:23:19.953372541 +0200 +@@ -725,6 +725,8 @@ struct pkt { + #define LOOP_KERN_CLEAR 11 /* reset kernel pll parameters */ + #define LOOP_CODEC 12 /* set audio codec frequency */ + #define LOOP_LEAP 13 /* insert leap after second 23:59 */ ++#define LOOP_MAX_BACK 14 /* set bacward-step offset */ ++#define LOOP_MAX_FWD 15 /* set forward-step offset */ + + /* + * Configuration items for the stats printer +diff -up ntp-4.2.6p5/include/ntpd.h.backfwdstep ntp-4.2.6p5/include/ntpd.h +--- ntp-4.2.6p5/include/ntpd.h.backfwdstep 2015-05-13 17:07:13.498212244 +0200 ++++ ntp-4.2.6p5/include/ntpd.h 2015-05-13 17:28:42.516052737 +0200 +@@ -345,7 +345,8 @@ extern int maxactivefd; + /* ntp_loopfilter.c */ + extern double drift_comp; /* clock frequency (s/s) */ + extern double clock_stability; /* clock stability (s/s) */ +-extern double clock_max; /* max offset before step (s) */ ++extern double clock_max_back; /* max backward offset before step (s) */ ++extern double clock_max_fwd; /* max forward offset before step (s) */ + extern double clock_panic; /* max offset before panic (s) */ + extern double clock_phi; /* dispersion rate (s/s) */ + extern double clock_minstep; /* step timeout (s) */ +diff -up ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep ntp-4.2.6p5/ntpd/cmd_args.c +--- ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep 2009-12-25 10:03:41.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/cmd_args.c 2015-05-13 17:25:05.726102347 +0200 +@@ -161,8 +161,7 @@ getCmdOpts( + } + + if (HAVE_OPT( SLEW )) { +- clock_max = 600; +- kern_enable = 0; ++ loop_config(LOOP_MAX, 600); + } + if (HAVE_OPT( UPDATEINTERVAL )) { + long val = OPT_VALUE_UPDATEINTERVAL; +diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep ntp-4.2.6p5/ntpd/keyword-gen.c +--- ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep 2010-04-18 10:05:39.000000000 +0200 ++++ ntp-4.2.6p5/ntpd/keyword-gen.c 2015-05-13 17:39:08.889233906 +0200 +@@ -173,6 +173,8 @@ struct key_tok ntp_keywords[] = { + { "stats", T_Stats, FOLLBY_TOKEN }, + /* tinker_option */ + { "step", T_Step, FOLLBY_TOKEN }, ++{ "stepback", T_Stepback, FOLLBY_TOKEN }, ++{ "stepfwd", T_Stepfwd, FOLLBY_TOKEN }, + { "panic", T_Panic, FOLLBY_TOKEN }, + { "dispersion", T_Dispersion, FOLLBY_TOKEN }, + { "stepout", T_Stepout, FOLLBY_TOKEN }, +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep 2015-05-13 17:07:13.534208748 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2015-05-13 17:36:12.929319050 +0200 +@@ -2407,6 +2407,14 @@ config_tinker( + item = LOOP_MAX; + break; + ++ case T_Stepback: ++ item = LOOP_MAX_BACK; ++ break; ++ ++ case T_Stepfwd: ++ item = LOOP_MAX_FWD; ++ break; ++ + case T_Stepout: + item = LOOP_MINSTEP; + break; +diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_loopfilter.c +--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep 2015-05-13 17:07:13.499212146 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c 2015-05-13 17:20:42.362674093 +0200 +@@ -107,7 +107,8 @@ + /* + * Program variables that can be tinkered. + */ +-double clock_max = CLOCK_MAX; /* step threshold */ ++double clock_max_back = CLOCK_MAX; /* step threshold */ ++double clock_max_fwd = CLOCK_MAX; /* step threshold */ + double clock_minstep = CLOCK_MINSTEP; /* stepout threshold */ + double clock_panic = CLOCK_PANIC; /* panic threshold */ + double clock_phi = CLOCK_PHI; /* dispersion rate (s/s) */ +@@ -257,7 +258,8 @@ local_clock( + * directly to the terminal. + */ + if (mode_ntpdate) { +- if (fabs(fp_offset) > clock_max && clock_max > 0) { ++ if ( ( fp_offset > clock_max_fwd && clock_max_fwd > 0) ++ || (-fp_offset > clock_max_back && clock_max_back > 0)) { + step_systime(fp_offset); + msyslog(LOG_NOTICE, "ntpd: time set %+.6f s", + fp_offset); +@@ -319,7 +321,8 @@ local_clock( + mu = current_time - clock_epoch; + clock_frequency = drift_comp; + rval = 1; +- if (fabs(fp_offset) > clock_max && clock_max > 0) { ++ if ( ( fp_offset > clock_max_fwd && clock_max_fwd > 0) ++ || (-fp_offset > clock_max_back && clock_max_back > 0)) { + switch (state) { + + /* +@@ -1007,8 +1010,20 @@ loop_config( + break; + + case LOOP_MAX: /* step threshold (step) */ +- clock_max = freq; +- if (clock_max == 0 || clock_max > 0.5) ++ clock_max_fwd = clock_max_back = freq; ++ if (freq == 0 || freq > 0.5) ++ kern_enable = 0; ++ break; ++ ++ case LOOP_MAX_BACK: /* step threshold (step) */ ++ clock_max_back = freq; ++ if (freq == 0 || freq > 0.5) ++ kern_enable = 0; ++ break; ++ ++ case LOOP_MAX_FWD: /* step threshold (step) */ ++ clock_max_fwd = freq; ++ if (freq == 0 || freq > 0.5) + kern_enable = 0; + break; + +diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep ntp-4.2.6p5/ntpd/ntp_parser.y +--- ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep 2010-10-24 08:29:35.000000000 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_parser.y 2015-05-13 17:40:45.207881673 +0200 +@@ -190,6 +190,8 @@ + %token T_Stats + %token T_Statsdir + %token T_Step ++%token T_Stepback ++%token T_Stepfwd + %token T_Stepout + %token T_Stratum + %token T_String +@@ -899,6 +901,8 @@ tinker_option_keyword + | T_Huffpuff + | T_Panic + | T_Step ++ | T_Stepback ++ | T_Stepfwd + | T_Stepout + ; + +diff -up ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_timer.c +--- ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep 2015-05-13 17:07:13.554206806 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_timer.c 2015-05-13 17:27:45.659573319 +0200 +@@ -450,7 +450,7 @@ timer(void) + sys_tai = leap_tai; + #ifdef KERNEL_PLL + if (!pll_control || !kern_enable) { +- if (clock_max < 1.0 && clock_max > 0.0) { ++ if (clock_max_back < 1.0 && clock_max_back > 0.0) { + step_systime(-1.0); + msyslog(LOG_NOTICE, "Inserting positive leap second"); + } else { diff --git a/SOURCES/ntp-4.2.6p5-clockstate.patch b/SOURCES/ntp-4.2.6p5-clockstate.patch new file mode 100644 index 0000000..487cf62 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-clockstate.patch @@ -0,0 +1,118 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.clockstate ntp-4.2.6p5/ntpd/ntp_loopfilter.c +--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.clockstate 2015-12-04 13:42:45.807689201 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c 2015-12-04 15:21:34.252296997 +0100 +@@ -189,6 +189,51 @@ init_loopfilter(void) + clock_jitter = LOGTOD(sys_precision); + } + ++#ifdef KERNEL_PLL ++/* ++ * ntp_adjtime_wrapper - call ntp_adjtime() and print errors and clock state ++ * changes related to leap seconds ++ */ ++static int ++ntp_adjtime_wrapper(struct timex *timex) ++{ ++ static int last_ret = TIME_OK; ++ int ret; ++ ++ ret = ntp_adjtime(timex); ++ ++ if (ret < 0) { ++ msyslog(LOG_ERR, "ntp_adjtime() failed: %s", strerror(errno)); ++ return ret; ++ } ++ ++ if (ret == last_ret || ret == TIME_ERROR) ++ return ret; ++ ++ switch (ret) { ++ case TIME_OK: ++ if (last_ret != TIME_INS && last_ret != TIME_DEL) ++ break; ++ msyslog(LOG_INFO, "kernel leap second %s cancelled", ++ last_ret == TIME_INS ? "insertion" : "deletion"); ++ break; ++ case TIME_INS: ++ msyslog(LOG_INFO, "kernel reports leap second insertion scheduled"); ++ break; ++ case TIME_DEL: ++ msyslog(LOG_INFO, "kernel reports leap second deletion scheduled"); ++ break; ++ case TIME_WAIT: ++ msyslog(LOG_INFO, "kernel reports leap second has occurred"); ++ break; ++ } ++ ++ last_ret = ret; ++ ++ return ret; ++} ++#endif ++ + /* + * local_clock - the NTP logical clock loop filter. + * +@@ -566,7 +611,7 @@ local_clock( + * the pps. In any case, fetch the kernel offset, + * frequency and jitter. + */ +- if (ntp_adjtime(&ntv) == TIME_ERROR) { ++ if (ntp_adjtime_wrapper(&ntv) == TIME_ERROR) { + if (!(ntv.status & STA_PPSSIGNAL)) + report_event(EVNT_KERN, NULL, + "PPS no signal"); +@@ -598,7 +643,7 @@ local_clock( + loop_tai = sys_tai; + ntv.modes = MOD_TAI; + ntv.constant = sys_tai; +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + } + #endif /* STA_NANO */ + } +@@ -775,7 +820,7 @@ direct_freq( + */ + if (pll_control && kern_enable) { + memset(&ntv, 0, sizeof(ntv)); +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + #ifdef STA_NANO + clock_offset = ntv.offset / 1e9; + #else /* STA_NANO */ +@@ -811,7 +856,7 @@ set_freq( + memset(&ntv, 0, sizeof(ntv)); + ntv.modes = MOD_FREQUENCY; + ntv.freq = DTOFREQ(drift_comp); +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + snprintf(tbuf, sizeof(tbuf), "kernel %.3f PPM", + drift_comp * 1e6); + report_event(EVNT_FSET, NULL, tbuf); +@@ -905,7 +950,7 @@ loop_config( + pll_control = 0; + } + if (sigsetjmp(env, 1) == 0) +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + if ((sigaction(SIGSYS, &sigsys, + (struct sigaction *)NULL))) { + msyslog(LOG_ERR, +@@ -913,7 +958,7 @@ loop_config( + pll_control = 0; + } + #else /* SIGSYS */ +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + #endif /* SIGSYS */ + + /* +@@ -964,7 +1009,7 @@ loop_config( + memset((char *)&ntv, 0, sizeof(ntv)); + ntv.modes = MOD_STATUS; + ntv.status = STA_UNSYNC; +- ntp_adjtime(&ntv); ++ ntp_adjtime_wrapper(&ntv); + report_event(EVNT_KERN, NULL, + "kernel time sync disabledx"); + } diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9293.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9293.patch new file mode 100644 index 0000000..62ad523 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9293.patch @@ -0,0 +1,35 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.cve-2014-9293 ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.cve-2014-9293 2014-12-19 16:24:18.297578337 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2014-12-19 16:24:18.311578368 +0100 +@@ -1866,13 +1866,16 @@ config_auth( + req_hashlen = digest_len; + #endif + } else { +- int rankey; ++ unsigned char rankey[16]; ++ ++ if (ntp_crypto_random_buf(rankey, sizeof (rankey))) { ++ msyslog(LOG_ERR, "ntp_crypto_random_buf() failed."); ++ exit(1); ++ } + +- rankey = ntp_random(); + req_keytype = NID_md5; + req_hashlen = 16; +- MD5auth_setkey(req_keyid, req_keytype, +- (u_char *)&rankey, sizeof(rankey)); ++ MD5auth_setkey(req_keyid, req_keytype, rankey, sizeof(rankey)); + authtrust(req_keyid, 1); + } + +diff -up ntp-4.2.6p5/ntpd/ntpd.c.cve-2014-9293 ntp-4.2.6p5/ntpd/ntpd.c +--- ntp-4.2.6p5/ntpd/ntpd.c.cve-2014-9293 2014-12-19 16:24:02.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntpd.c 2014-12-19 16:24:18.298578339 +0100 +@@ -593,6 +593,7 @@ ntpdmain( + get_systime(&now); + + ntp_srandom((int)(now.l_i * now.l_uf)); ++ ntp_crypto_srandom(); + + #if !defined(VMS) + # ifndef NODETACH diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9294.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9294.patch new file mode 100644 index 0000000..808ca11 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9294.patch @@ -0,0 +1,108 @@ +diff -up ntp-4.2.6p5/include/ntp_random.h.orig ntp-4.2.6p5/include/ntp_random.h +--- ntp-4.2.6p5/include/ntp_random.h.orig 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p5/include/ntp_random.h 2014-12-19 16:01:32.450628801 +0100 +@@ -1,6 +1,9 @@ + + #include + ++void ntp_crypto_srandom(void); ++int ntp_crypto_random_buf(void *buf, size_t nbytes); ++ + long ntp_random (void); + void ntp_srandom (unsigned long); + void ntp_srandomdev (void); +diff -up ntp-4.2.6p5/libntp/ntp_random.c.orig ntp-4.2.6p5/libntp/ntp_random.c +--- ntp-4.2.6p5/libntp/ntp_random.c.orig 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/libntp/ntp_random.c 2014-12-19 16:04:32.069016676 +0100 +@@ -481,3 +481,63 @@ ntp_random( void ) + } + return(i); + } ++ ++/* ++ * Crypto-quality random number functions ++ * ++ * Author: Harlan Stenn, 2014 ++ * ++ * This file is Copyright (c) 2014 by Network Time Foundation. ++ * BSD terms apply: see the file COPYRIGHT in the distribution root for details. ++ */ ++ ++#include ++#include ++ ++int crypto_rand_init = 0; ++ ++/* ++ * ntp_crypto_srandom: ++ * ++ * Initialize the random number generator, if needed by the underlying ++ * crypto random number generation mechanism. ++ */ ++ ++void ++ntp_crypto_srandom( ++ void ++ ) ++{ ++ if (!crypto_rand_init) { ++ RAND_poll(); ++ crypto_rand_init = 1; ++ } ++} ++ ++/* ++ * ntp_crypto_random_buf: ++ * ++ * Returns 0 on success, -1 on error. ++ */ ++int ++ntp_crypto_random_buf( ++ void *buf, ++ size_t nbytes ++ ) ++{ ++ int rc; ++ ++ rc = RAND_bytes(buf, nbytes); ++ if (1 != rc) { ++ unsigned long err; ++ char *err_str; ++ ++ err = ERR_get_error(); ++ err_str = ERR_error_string(err, NULL); ++ /* XXX: Log the error */ ++ ++ return -1; ++ } ++ return 0; ++} ++ +diff -up ntp-4.2.6p5/util/ntp-keygen.c.orig ntp-4.2.6p5/util/ntp-keygen.c +--- ntp-4.2.6p5/util/ntp-keygen.c.orig 2014-12-19 15:27:38.375236349 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen.c 2014-12-19 15:58:00.006170042 +0100 +@@ -263,6 +263,8 @@ main( + ssl_check_version(); + #endif /* OPENSSL */ + ++ ntp_crypto_srandom(); ++ + /* + * Process options, initialize host name and timestamp. + */ +@@ -743,7 +745,14 @@ gen_md5( + int temp; + + while (1) { +- temp = ntp_random() & 0xff; ++ int rc; ++ ++ rc = ntp_crypto_random_buf(&temp, 1); ++ if (-1 == rc) { ++ fprintf(stderr, "ntp_crypto_random_buf() failed.\n"); ++ exit (-1); ++ } ++ temp &= 0xff; + if (temp == '#') + continue; + diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9295.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9295.patch new file mode 100644 index 0000000..97fcc3a --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9295.patch @@ -0,0 +1,110 @@ +2014-12-12 11:06:03+00:00, stenn@psp-fb1.ntp.org +12 -3 + [Sec 2667] buffer overflow in crypto_recv() + +--- 1.168/ntpd/ntp_crypto.c 2014-11-15 04:41:02 +00:00 ++++ 1.169/ntpd/ntp_crypto.c 2014-12-12 11:06:03 +00:00 +@@ -820,15 +820,24 @@ crypto_recv( + * errors. + */ + if (vallen == (u_int)EVP_PKEY_size(host_pkey)) { ++ u_int32 *cookiebuf = malloc( ++ RSA_size(host_pkey->pkey.rsa)); ++ if (!cookiebuf) { ++ rval = XEVNT_CKY; ++ break; ++ } ++ + if (RSA_private_decrypt(vallen, + (u_char *)ep->pkt, +- (u_char *)&temp32, ++ (u_char *)cookiebuf, + host_pkey->pkey.rsa, +- RSA_PKCS1_OAEP_PADDING) <= 0) { ++ RSA_PKCS1_OAEP_PADDING) != 4) { + rval = XEVNT_CKY; ++ free(cookiebuf); + break; + } else { +- cookie = ntohl(temp32); ++ cookie = ntohl(*cookiebuf); ++ free(cookiebuf); + } + } else { + rval = XEVNT_CKY; + +2014-12-12 11:13:40+00:00, stenn@psp-fb1.ntp.org +16 -1 + [Sec 2668] buffer overflow in ctl_putdata() + +--- 1.190/ntpd/ntp_control.c 2014-11-15 04:41:02 +00:00 ++++ 1.191/ntpd/ntp_control.c 2014-12-12 11:13:40 +00:00 +@@ -801,6 +801,10 @@ static char *reqend; + static char *reqpt; + static char *reqend; + ++#ifndef MIN ++#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) ++#endif ++ + /* + * init_control - initialize request data + */ +@@ -1316,6 +1320,7 @@ ctl_putdata( + ) + { + int overhead; ++ unsigned int currentlen; + + overhead = 0; + if (!bin) { +@@ -1338,12 +1343,22 @@ ctl_putdata( + /* + * Save room for trailing junk + */ +- if (dlen + overhead + datapt > dataend) { ++ while (dlen + overhead + datapt > dataend) { + /* + * Not enough room in this one, flush it out. + */ ++ currentlen = MIN(dlen, dataend - datapt); ++ ++ memcpy(datapt, dp, currentlen); ++ ++ datapt += currentlen; ++ dp += currentlen; ++ dlen -= currentlen; ++ datalinelen += currentlen; ++ + ctl_flushpkt(CTL_MORE); + } ++ + memmove((char *)datapt, dp, (unsigned)dlen); + datapt += dlen; + datalinelen += dlen; + +2014-12-12 11:19:37+00:00, stenn@psp-fb1.ntp.org +14 -0 + [Sec 2669] buffer overflow in configure() + +--- 1.191/ntpd/ntp_control.c 2014-12-12 11:13:40 +00:00 ++++ 1.192/ntpd/ntp_control.c 2014-12-12 11:19:37 +00:00 +@@ -3290,6 +3290,20 @@ static void configure( + + /* Initialize the remote config buffer */ + data_count = reqend - reqpt; ++ ++ if (data_count > sizeof(remote_config.buffer) - 2) { ++ snprintf(remote_config.err_msg, ++ sizeof(remote_config.err_msg), ++ "runtime configuration failed: request too long"); ++ ctl_putdata(remote_config.err_msg, ++ strlen(remote_config.err_msg), 0); ++ ctl_flushpkt(0); ++ msyslog(LOG_NOTICE, ++ "runtime config from %s rejected: request too long", ++ stoa(&rbufp->recv_srcadr)); ++ return; ++ } ++ + memcpy(remote_config.buffer, reqpt, data_count); + if (data_count > 0 + && '\n' != remote_config.buffer[data_count - 1]) + diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9296.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9296.patch new file mode 100644 index 0000000..323c67b --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9296.patch @@ -0,0 +1,14 @@ +2014-12-12 11:24:22+00:00, stenn@psp-fb1.ntp.org +1 -0 + [Sec 2670] Missing return; from error clause + +--- 1.350/ntpd/ntp_proto.c 2014-11-21 11:06:57 +00:00 ++++ 1.351/ntpd/ntp_proto.c 2014-12-12 11:24:22 +00:00 +@@ -1089,6 +1089,7 @@ receive( + fast_xmit(rbufp, MODE_ACTIVE, 0, + restrict_mask); + sys_restricted++; ++ return; + } + } + + diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9297.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9297.patch new file mode 100644 index 0000000..1364e8c --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9297.patch @@ -0,0 +1,375 @@ +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=54abb266In81wLNAqIaovtP8f2UmUw +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=54a7c595jlwS3KmAxBML75HFGLR_pQ +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=5492d353ncauuWt_PONxaDhC5Qv_SA + +diff -up ntp-4.2.6p5/ntpd/ntp_crypto.c.cve-2014-9297 ntp-4.2.6p5/ntpd/ntp_crypto.c +--- ntp-4.2.6p5/ntpd/ntp_crypto.c.cve-2014-9297 2015-02-04 11:37:44.488673076 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_crypto.c 2015-02-04 11:37:44.491673082 +0100 +@@ -109,6 +109,7 @@ + #define TAI_1972 10 /* initial TAI offset (s) */ + #define MAX_LEAP 100 /* max UTC leapseconds (s) */ + #define VALUE_LEN (6 * 4) /* min response field length */ ++#define MAX_VALLEN (65535 - VALUE_LEN) + #define YEAR (60 * 60 * 24 * 365) /* seconds in year */ + + /* +@@ -147,8 +148,8 @@ static char *rand_file = NULL; /* random + */ + static int crypto_verify (struct exten *, struct value *, + struct peer *); +-static int crypto_encrypt (struct exten *, struct value *, +- keyid_t *); ++static int crypto_encrypt (const u_char *, u_int, keyid_t *, ++ struct value *); + static int crypto_alice (struct peer *, struct value *); + static int crypto_alice2 (struct peer *, struct value *); + static int crypto_alice3 (struct peer *, struct value *); +@@ -444,6 +445,12 @@ crypto_recv( + tstamp = ntohl(ep->tstamp); + fstamp = ntohl(ep->fstamp); + vallen = ntohl(ep->vallen); ++ /* ++ * Bug 2761: I hope this isn't too early... ++ */ ++ if ( vallen == 0 ++ || len - VALUE_LEN < vallen) ++ return XEVNT_LEN; + } + switch (code) { + +@@ -494,8 +501,9 @@ crypto_recv( + rval = XEVNT_ERR; + break; + } ++ INSIST(len >= VALUE_LEN); + if (vallen == 0 || vallen > MAXHOSTNAME || +- len < VALUE_LEN + vallen) { ++ len - VALUE_LEN < vallen) { + rval = XEVNT_LEN; + break; + } +@@ -1162,11 +1170,11 @@ crypto_xmit( + * choice. + */ + case CRYPTO_CERT | CRYPTO_RESP: +- vallen = ntohl(ep->vallen); +- if (vallen == 0 || vallen > MAXHOSTNAME) { ++ vallen = ntohl(ep->vallen); /* Must be <64k */ ++ if (vallen == 0 || vallen > MAXHOSTNAME || ++ len - VALUE_LEN < vallen) { + rval = XEVNT_LEN; + break; +- + } else { + memcpy(certname, ep->pkt, vallen); + certname[vallen] = '\0'; +@@ -1315,7 +1323,10 @@ crypto_xmit( + * anything goes wrong. + */ + case CRYPTO_COOK | CRYPTO_RESP: +- if ((opcode & 0xffff) < VALUE_LEN) { ++ vallen = ntohl(ep->vallen); /* Must be <64k */ ++ if ( vallen == 0 ++ || (vallen >= MAX_VALLEN) ++ || (opcode & 0x0000ffff) < VALUE_LEN + vallen) { + rval = XEVNT_LEN; + break; + } +@@ -1323,8 +1334,8 @@ crypto_xmit( + tcookie = cookie; + else + tcookie = peer->hcookie; +- if ((rval = crypto_encrypt(ep, &vtemp, &tcookie)) == +- XEVNT_OK) { ++ if ((rval = crypto_encrypt((const u_char *)ep->pkt, vallen, &tcookie, &vtemp)) ++ == XEVNT_OK) { + len = crypto_send(fp, &vtemp, start); + value_free(&vtemp); + } +@@ -1464,13 +1475,16 @@ crypto_verify( + * up to the next word (4 octets). + */ + vallen = ntohl(ep->vallen); +- if (vallen == 0) ++ if ( vallen == 0 ++ || vallen > MAX_VALLEN) + return (XEVNT_LEN); + + i = (vallen + 3) / 4; + siglen = ntohl(ep->pkt[i++]); +- if (len < VALUE_LEN + ((vallen + 3) / 4) * 4 + ((siglen + 3) / +- 4) * 4) ++ if ( siglen > MAX_VALLEN ++ || len - VALUE_LEN < ((vallen + 3) / 4) * 4 ++ || len - VALUE_LEN - ((vallen + 3) / 4) * 4 ++ < ((siglen + 3) / 4) * 4) + return (XEVNT_LEN); + + /* +@@ -1528,6 +1542,7 @@ crypto_verify( + * proventic bit. What a relief. + */ + EVP_VerifyInit(&ctx, peer->digest); ++ /* XXX: the "+ 12" needs to be at least documented... */ + EVP_VerifyUpdate(&ctx, (u_char *)&ep->tstamp, vallen + 12); + if (EVP_VerifyFinal(&ctx, (u_char *)&ep->pkt[i], siglen, + pkey) <= 0) +@@ -1540,34 +1555,32 @@ crypto_verify( + + + /* +- * crypto_encrypt - construct encrypted cookie and signature from +- * extension field and cookie ++ * crypto_encrypt - construct vp (encrypted cookie and signature) from ++ * the public key and cookie. + * +- * Returns ++ * Returns: + * XEVNT_OK success + * XEVNT_CKY bad or missing cookie + * XEVNT_PUB bad or missing public key + */ + static int + crypto_encrypt( +- struct exten *ep, /* extension pointer */ +- struct value *vp, /* value pointer */ +- keyid_t *cookie /* server cookie */ ++ const u_char *ptr, /* Public Key */ ++ u_int vallen, /* Length of Public Key */ ++ keyid_t *cookie, /* server cookie */ ++ struct value *vp /* value pointer */ + ) + { + EVP_PKEY *pkey; /* public key */ + EVP_MD_CTX ctx; /* signature context */ + tstamp_t tstamp; /* NTP timestamp */ + u_int32 temp32; +- u_int len; +- u_char *ptr; ++ u_char *puch; + + /* + * Extract the public key from the request. + */ +- len = ntohl(ep->vallen); +- ptr = (u_char *)ep->pkt; +- pkey = d2i_PublicKey(EVP_PKEY_RSA, NULL, &ptr, len); ++ pkey = d2i_PublicKey(EVP_PKEY_RSA, NULL, &ptr, vallen); + if (pkey == NULL) { + msyslog(LOG_ERR, "crypto_encrypt: %s", + ERR_error_string(ERR_get_error(), NULL)); +@@ -1581,12 +1594,12 @@ crypto_encrypt( + tstamp = crypto_time(); + vp->tstamp = htonl(tstamp); + vp->fstamp = hostval.tstamp; +- len = EVP_PKEY_size(pkey); +- vp->vallen = htonl(len); +- vp->ptr = emalloc(len); +- ptr = vp->ptr; ++ vallen = EVP_PKEY_size(pkey); ++ vp->vallen = htonl(vallen); ++ vp->ptr = emalloc(vallen); ++ puch = vp->ptr; + temp32 = htonl(*cookie); +- if (RSA_public_encrypt(4, (u_char *)&temp32, ptr, ++ if (RSA_public_encrypt(4, (u_char *)&temp32, puch, + pkey->pkey.rsa, RSA_PKCS1_OAEP_PADDING) <= 0) { + msyslog(LOG_ERR, "crypto_encrypt: %s", + ERR_error_string(ERR_get_error(), NULL)); +@@ -1601,8 +1614,8 @@ crypto_encrypt( + vp->sig = emalloc(sign_siglen); + EVP_SignInit(&ctx, sign_digest); + EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); +- EVP_SignUpdate(&ctx, vp->ptr, len); +- if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) ++ EVP_SignUpdate(&ctx, vp->ptr, vallen); ++ if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) + vp->siglen = htonl(sign_siglen); + return (XEVNT_OK); + } +@@ -1673,6 +1686,9 @@ crypto_ident( + * call in the protocol module. + * + * Returns extension field pointer (no errors) ++ * ++ * XXX: opcode and len should really be 32-bit quantities and ++ * we should make sure that str is not too big. + */ + struct exten * + crypto_args( +@@ -1685,24 +1701,31 @@ crypto_args( + tstamp_t tstamp; /* NTP timestamp */ + struct exten *ep; /* extension field pointer */ + u_int len; /* extension field length */ ++ size_t slen; + + tstamp = crypto_time(); + len = sizeof(struct exten); +- if (str != NULL) +- len += strlen(str); ++ if (str != NULL) { ++ slen = strlen(str); ++ INSIST(slen < MAX_VALLEN); ++ len += slen; ++ } + ep = emalloc(len); + memset(ep, 0, len); + if (opcode == 0) + return (ep); + ++ REQUIRE(0 == (len & ~0x0000ffff)); ++ REQUIRE(0 == (opcode & ~0xffff0000)); ++ + ep->opcode = htonl(opcode + len); + ep->associd = htonl(associd); + ep->tstamp = htonl(tstamp); + ep->fstamp = hostval.tstamp; + ep->vallen = 0; + if (str != NULL) { +- ep->vallen = htonl(strlen(str)); +- memcpy((char *)ep->pkt, str, strlen(str)); ++ ep->vallen = htonl(slen); ++ memcpy((char *)ep->pkt, str, slen); + } + return (ep); + } +@@ -1715,6 +1738,8 @@ crypto_args( + * Note: it is not polite to send a nonempty signature with zero + * timestamp or a nonzero timestamp with an empty signature, but those + * rules are not enforced here. ++ * ++ * XXX This code won't work on a box with 16-bit ints. + */ + int + crypto_send( +@@ -1730,8 +1755,9 @@ crypto_send( + * Calculate extension field length and check for buffer + * overflow. Leave room for the MAC. + */ +- len = 16; ++ len = 16; /* XXX Document! */ + vallen = ntohl(vp->vallen); ++ INSIST(vallen <= MAX_VALLEN); + len += ((vallen + 3) / 4 + 1) * 4; + siglen = ntohl(vp->siglen); + len += ((siglen + 3) / 4 + 1) * 4; +@@ -1772,6 +1798,7 @@ crypto_send( + } + opcode = ntohl(ep->opcode); + ep->opcode = htonl((opcode & 0xffff0000) | len); ++ ENSURE(len <= MAX_VALLEN); + return (len); + } + +@@ -1807,7 +1834,6 @@ crypto_update(void) + if (hostval.tstamp == 0) + return; + +- + /* + * Sign public key and timestamps. The filestamp is derived from + * the host key file extension from wherever the file was +@@ -2108,7 +2134,8 @@ crypto_bob( + tstamp_t tstamp; /* NTP timestamp */ + BIGNUM *bn, *bk, *r; + u_char *ptr; +- u_int len; ++ u_int len; /* extension field length */ ++ u_int vallen = 0; /* value length */ + + /* + * If the IFF parameters are not valid, something awful +@@ -2123,8 +2150,11 @@ crypto_bob( + /* + * Extract r from the challenge. + */ +- len = ntohl(ep->vallen); +- if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { ++ vallen = ntohl(ep->vallen); ++ len = ntohl(ep->opcode) & 0x0000ffff; ++ if (vallen == 0 || len < VALUE_LEN || len - VALUE_LEN < vallen) ++ return XEVNT_LEN; ++ if ((r = BN_bin2bn((u_char *)ep->pkt, vallen, NULL)) == NULL) { + msyslog(LOG_ERR, "crypto_bob: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (XEVNT_ERR); +@@ -2136,7 +2166,7 @@ crypto_bob( + */ + bctx = BN_CTX_new(); bk = BN_new(); bn = BN_new(); + sdsa = DSA_SIG_new(); +- BN_rand(bk, len * 8, -1, 1); /* k */ ++ BN_rand(bk, vallen * 8, -1, 1); /* k */ + BN_mod_mul(bn, dsa->priv_key, r, dsa->q, bctx); /* b r mod q */ + BN_add(bn, bn, bk); + BN_mod(bn, bn, dsa->q, bctx); /* k + b r mod q */ +@@ -2155,30 +2185,37 @@ crypto_bob( + * Encode the values in ASN.1 and sign. The filestamp is from + * the local file. + */ +- len = i2d_DSA_SIG(sdsa, NULL); +- if (len == 0) { ++ vallen = i2d_DSA_SIG(sdsa, NULL); ++ if (vallen == 0) { + msyslog(LOG_ERR, "crypto_bob: %s", + ERR_error_string(ERR_get_error(), NULL)); + DSA_SIG_free(sdsa); + return (XEVNT_ERR); + } ++ if (vallen > MAX_VALLEN) { ++ msyslog(LOG_ERR, "crypto_bob: signature is too big: %d", ++ vallen); ++ DSA_SIG_free(sdsa); ++ return (XEVNT_LEN); ++ } + memset(vp, 0, sizeof(struct value)); + tstamp = crypto_time(); + vp->tstamp = htonl(tstamp); + vp->fstamp = htonl(iffkey_info->fstamp); +- vp->vallen = htonl(len); +- ptr = emalloc(len); ++ vp->vallen = htonl(vallen); ++ ptr = emalloc(vallen); + vp->ptr = ptr; + i2d_DSA_SIG(sdsa, &ptr); + DSA_SIG_free(sdsa); + if (tstamp == 0) + return (XEVNT_OK); + ++ /* XXX: more validation to make sure the sign fits... */ + vp->sig = emalloc(sign_siglen); + EVP_SignInit(&ctx, sign_digest); + EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); +- EVP_SignUpdate(&ctx, vp->ptr, len); +- if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) ++ EVP_SignUpdate(&ctx, vp->ptr, vallen); ++ if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) + vp->siglen = htonl(sign_siglen); + return (XEVNT_OK); + } +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2014-9297 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2014-9297 2015-02-04 11:37:44.490673080 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-02-04 11:47:42.653868627 +0100 +@@ -431,7 +431,7 @@ receive( + */ + authlen = LEN_PKT_NOMAC; + has_mac = rbufp->recv_length - authlen; +- while (has_mac != 0) { ++ while (has_mac > 0) { + u_int32 len; + + if (has_mac % 4 != 0 || has_mac < MIN_MAC_LEN) { +@@ -456,6 +456,14 @@ receive( + } + + /* ++ * If has_mac is < 0 we had a malformed packet. ++ */ ++ if (has_mac < 0) { ++ sys_badlength++; ++ return; /* bad length */ ++ } ++ ++ /* + * If authentication required, a MAC must be present. + */ + if (restrict_mask & RES_DONTTRUST && has_mac == 0) { diff --git a/SOURCES/ntp-4.2.6p5-cve-2014-9298.patch b/SOURCES/ntp-4.2.6p5-cve-2014-9298.patch new file mode 100644 index 0000000..525e2a0 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2014-9298.patch @@ -0,0 +1,38 @@ +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=54922b65gDSbE4G7c3JjkuK1Tv33qQ +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=5492d2879rotbnnuVch_ZC3RAfS8AA +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=5496213frLaEz5PHLZVhuYjM7Lalkw +http://bk.ntp.org/ntp-stable/?PAGE=patch&REV=54c2228bpOp4_zrX9aGXdMEZJEGzkg + +diff -up ntp-4.2.6p5/ntpd/ntp_io.c.cve-2014-9298 ntp-4.2.6p5/ntpd/ntp_io.c +--- ntp-4.2.6p5/ntpd/ntp_io.c.cve-2014-9298 2015-02-04 11:49:30.506083987 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_io.c 2015-02-04 12:09:12.638449788 +0100 +@@ -3498,6 +3498,29 @@ read_network_packet( + fd, buflen, stoa(&rb->recv_srcadr))); + + /* ++ ** Bug 2672: Some OSes (MacOSX and Linux) don't block spoofed ::1 ++ */ ++ ++ if (AF_INET6 == itf->family) { ++ DPRINTF(2, ("Got an IPv6 packet, from <%s> (%d) to <%s> (%d)\n", ++ stoa(&rb->recv_srcadr), ++ IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr)), ++ stoa(&itf->sin), ++ !IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin)) ++ )); ++ ++ if ( IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&rb->recv_srcadr)) ++ && !IN6_IS_ADDR_LOOPBACK(PSOCK_ADDR6(&itf->sin)) ++ ) { ++ packets_dropped++; ++ DPRINTF(2, ("DROPPING that packet\n")); ++ freerecvbuf(rb); ++ return buflen; ++ } ++ DPRINTF(2, ("processing that packet\n")); ++ } ++ ++ /* + * Got one. Mark how and when it got here, + * put it on the full list and do bookkeeping. + */ diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-1798.patch b/SOURCES/ntp-4.2.6p5-cve-2015-1798.patch new file mode 100644 index 0000000..413573d --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-1798.patch @@ -0,0 +1,28 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-1798 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-1798 2015-04-08 12:50:57.997021032 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-04-08 12:50:58.005021047 +0200 +@@ -1130,18 +1130,20 @@ receive( + return; + + /* +- * If the digest fails, the client cannot authenticate a server ++ * If the digest fails or it's missing for authenticated ++ * associations, the client cannot authenticate a server + * reply to a client packet previously sent. The loopback check + * is designed to avoid a bait-and-switch attack, which was + * possible in past versions. If symmetric modes, return a + * crypto-NAK. The peer should restart the protocol. + */ +- } else if (!AUTH(has_mac || (restrict_mask & RES_DONTTRUST), +- is_authentic)) { ++ } else if (!AUTH(peer->keyid || has_mac || ++ (restrict_mask & RES_DONTTRUST), is_authentic)) { + report_event(PEVNT_AUTH, peer, "digest"); + peer->flash |= TEST5; /* bad auth */ + peer->badauth++; +- if (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE) ++ if (has_mac && ++ (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)) + fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask); + if (peer->flags & FLAG_PREEMPT) { + unpeer(peer); diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-1799.patch b/SOURCES/ntp-4.2.6p5-cve-2015-1799.patch new file mode 100644 index 0000000..10548ab --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-1799.patch @@ -0,0 +1,37 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-1799 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-1799 2015-04-08 13:06:43.083810350 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-04-08 13:08:12.679980322 +0200 +@@ -1101,16 +1101,6 @@ receive( + } + + /* +- * Update the state variables. +- */ +- if (peer->flip == 0) { +- if (hismode != MODE_BROADCAST) +- peer->rec = p_xmt; +- peer->dst = rbufp->recv_time; +- } +- peer->xmt = p_xmt; +- +- /* + * If this is a crypto_NAK, the server cannot authenticate a + * client packet. The server might have just changed keys. Clear + * the association and restart the protocol. +@@ -1157,6 +1147,16 @@ receive( + } + + /* ++ * Update the state variables. ++ */ ++ if (peer->flip == 0) { ++ if (hismode != MODE_BROADCAST) ++ peer->rec = p_xmt; ++ peer->dst = rbufp->recv_time; ++ } ++ peer->xmt = p_xmt; ++ ++ /* + * Set the peer ppoll to the maximum of the packet ppoll and the + * peer minpoll. If a kiss-o'-death, set the peer minpoll to + * this maximumn and advance the headway to give the sender some diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-3405.patch b/SOURCES/ntp-4.2.6p5-cve-2015-3405.patch new file mode 100644 index 0000000..7cd238d --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-3405.patch @@ -0,0 +1,31 @@ +diff -up ntp-4.2.6p5/util/ntp-keygen.c.bigkeygen ntp-4.2.6p5/util/ntp-keygen.c +--- ntp-4.2.6p5/util/ntp-keygen.c.bigkeygen 2015-04-14 09:47:54.205534510 +0200 ++++ ntp-4.2.6p5/util/ntp-keygen.c 2015-04-14 09:50:04.068927862 +0200 +@@ -742,24 +742,23 @@ gen_md5( + ntp_srandom((u_long)epoch); + for (i = 1; i <= MD5KEYS; i++) { + for (j = 0; j < MD5SIZE; j++) { +- int temp; ++ u_char temp; + + while (1) { + int rc; + +- rc = ntp_crypto_random_buf(&temp, 1); ++ rc = ntp_crypto_random_buf(&temp, sizeof(temp)); + if (-1 == rc) { + fprintf(stderr, "ntp_crypto_random_buf() failed.\n"); + exit (-1); + } +- temp &= 0xff; + if (temp == '#') + continue; + + if (temp > 0x20 && temp < 0x7f) + break; + } +- md5key[j] = (u_char)temp; ++ md5key[j] = temp; + } + md5key[j] = '\0'; + fprintf(str, "%2d MD5 %s # MD5 key\n", i, diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-5194.patch b/SOURCES/ntp-4.2.6p5-cve-2015-5194.patch new file mode 100644 index 0000000..a774749 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-5194.patch @@ -0,0 +1,42 @@ +commit 553f2fa65865c31c5e3c48812cfd46176cffdd27 +Author: +Date: Wed Jul 28 05:33:53 2010 +0000 + + [Bug 1593] ntpd abort in free() with logconfig syntax error. + +diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y +index b3f7ac3..cf8942f 100644 +--- a/ntpd/ntp_parser.y ++++ b/ntpd/ntp_parser.y +@@ -995,14 +995,24 @@ log_config_list + log_config_command + : T_String + { +- char prefix = $1[0]; +- char *type = $1 + 1; ++ char prefix; ++ char * type; + +- if (prefix != '+' && prefix != '-' && prefix != '=') { +- yyerror("Logconfig prefix is not '+', '-' or '='\n"); +- } +- else +- $$ = create_attr_sval(prefix, estrdup(type)); ++ switch ($1[0]) { ++ ++ case '+': ++ case '-': ++ case '=': ++ prefix = $1[0]; ++ type = $1 + 1; ++ break; ++ ++ default: ++ prefix = '='; ++ type = $1; ++ } ++ ++ $$ = create_attr_sval(prefix, estrdup(type)); + YYFREE($1); + } + ; diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-5195.patch b/SOURCES/ntp-4.2.6p5-cve-2015-5195.patch new file mode 100644 index 0000000..3b2d9c3 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-5195.patch @@ -0,0 +1,31 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.cve-2015-5195 ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.cve-2015-5195 2015-08-20 12:14:23.911585026 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2015-08-20 12:15:14.850462173 +0200 +@@ -2019,6 +2019,13 @@ config_monitor( + while (pfilegen_token != NULL) { + filegen_string = keyword(*pfilegen_token); + filegen = filegen_get(filegen_string); ++ if (NULL == filegen) { ++ msyslog(LOG_ERR, ++ "stats %s unrecognized", ++ filegen_string); ++ pfilegen_token = next_node(pfilegen_token); ++ continue; ++ } + + DPRINTF(4, ("enabling filegen for %s statistics '%s%s'\n", + filegen_string, filegen->prefix, +@@ -2032,6 +2039,13 @@ config_monitor( + while (my_node != NULL) { + filegen_file = keyword(my_node->filegen_token); + filegen = filegen_get(filegen_file); ++ if (NULL == filegen) { ++ msyslog(LOG_ERR, ++ "filegen category '%s' unrecognized", ++ filegen_file); ++ my_node = next_node(my_node); ++ continue; ++ } + + /* Initialize the filegen variables to their pre-configurtion states */ + filegen_flag = filegen->flag; diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-5219.patch b/SOURCES/ntp-4.2.6p5-cve-2015-5219.patch new file mode 100644 index 0000000..fba2051 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-5219.patch @@ -0,0 +1,23 @@ +commit 5f295cd05c3c136d39f5b3e500a2d781bdbb59c8 +Author: +Date: Wed Apr 24 19:13:53 2013 -0400 + + [Bug 2382] Implement LOGTOD using ldexp() instead of shifting + +diff --git a/include/ntp.h b/include/ntp.h +index aa45e16..95b2542 100644 +--- a/include/ntp.h ++++ b/include/ntp.h +@@ -156,10 +156,9 @@ typedef char s_char; + #define SQUARE(x) ((x) * (x)) + #define SQRT(x) (sqrt(x)) + #define DIFF(x, y) (SQUARE((x) - (y))) +-#define LOGTOD(a) ((a) < 0 ? 1. / (1L << -(a)) : \ +- 1L << (int)(a)) /* log2 to double */ ++#define LOGTOD(a) ldexp(1., (int)(a)) /* log2 to double */ + #define UNIVAR(x) (SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */ +-#define ULOGTOD(a) (1L << (int)(a)) /* ulog2 to double */ ++#define ULOGTOD(a) ldexp(1., (int)(a)) /* ulog2 to double */ + + #define EVENT_TIMEOUT 0 /* one second, that is */ + diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-5300.patch b/SOURCES/ntp-4.2.6p5-cve-2015-5300.patch new file mode 100644 index 0000000..ebb7541 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-5300.patch @@ -0,0 +1,11 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.allowpanic ntp-4.2.6p5/ntpd/ntp_loopfilter.c +--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.allowpanic 2015-10-08 16:10:57.927295885 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c 2015-10-08 16:11:00.501628644 +0200 +@@ -389,6 +389,7 @@ local_clock( + report_event(EVNT_CLOCKRESET, NULL, tbuf); + step_systime(fp_offset); + reinit_timer(); ++ allow_panic = FALSE; + tc_counter = 0; + clock_jitter = LOGTOD(sys_precision); + rval = 2; diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7691_7692_7702.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7691_7692_7702.patch new file mode 100644 index 0000000..d920200 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7691_7692_7702.patch @@ -0,0 +1,217 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_crypto.c.cve-2015-7691_7692_7702 ntp-4.2.6p5/ntpd/ntp_crypto.c +--- ntp-4.2.6p5/ntpd/ntp_crypto.c.cve-2015-7691_7692_7702 2015-10-22 13:05:34.696482937 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_crypto.c 2015-10-22 13:14:12.473848919 +0200 +@@ -170,6 +170,7 @@ static void cert_free (struct cert_info + static struct pkey_info *crypto_key (char *, char *, sockaddr_u *); + static void bighash (BIGNUM *, BIGNUM *); + static struct cert_info *crypto_cert (char *); ++static u_int exten_payload_size(const struct exten *); + + #ifdef SYS_WINNT + int +@@ -389,7 +390,7 @@ crypto_recv( + struct autokey *ap, *bp; /* autokey pointer */ + struct exten *ep, *fp; /* extension pointers */ + struct cert_info *xinfo; /* certificate info pointer */ +- int has_mac; /* length of MAC field */ ++ int macbytes; /* length of MAC field, signed by intention */ + int authlen; /* offset of MAC field */ + associd_t associd; /* association ID */ + tstamp_t tstamp = 0; /* timestamp */ +@@ -417,7 +418,11 @@ crypto_recv( + */ + authlen = LEN_PKT_NOMAC; + hismode = (int)PKT_MODE((&rbufp->recv_pkt)->li_vn_mode); +- while ((has_mac = rbufp->recv_length - authlen) > MAX_MAC_LEN) { ++ while ((macbytes = rbufp->recv_length - authlen) > (int)MAX_MAC_LEN) { ++ /* We can be reasonably sure that we can read at least ++ * the opcode and the size field here. More stringent ++ * checks follow up shortly. ++ */ + pkt = (u_int32 *)&rbufp->recv_pkt + authlen / 4; + ep = (struct exten *)pkt; + code = ntohl(ep->opcode) & 0xffff0000; +@@ -441,6 +446,18 @@ crypto_recv( + code |= CRYPTO_ERROR; + } + ++ /* Check if the declared size fits into the remaining ++ * buffer. ++ */ ++ if (len > macbytes) { ++ DPRINTF(1, ("crypto_recv: possible attack detected, associd %d\n", ++ associd)); ++ return XEVNT_LEN; ++ } ++ ++ /* Check if the paylod of the extension fits into the ++ * declared frame. ++ */ + if (len >= VALUE_LEN) { + tstamp = ntohl(ep->tstamp); + fstamp = ntohl(ep->fstamp); +@@ -1170,9 +1187,8 @@ crypto_xmit( + * choice. + */ + case CRYPTO_CERT | CRYPTO_RESP: +- vallen = ntohl(ep->vallen); /* Must be <64k */ +- if (vallen == 0 || vallen > MAXHOSTNAME || +- len - VALUE_LEN < vallen) { ++ vallen = exten_payload_size(ep); /* Must be <64k */ ++ if (vallen == 0 || vallen >= sizeof(certname) ) { + rval = XEVNT_LEN; + break; + } else { +@@ -2134,8 +2150,7 @@ crypto_bob( + tstamp_t tstamp; /* NTP timestamp */ + BIGNUM *bn, *bk, *r; + u_char *ptr; +- u_int len; /* extension field length */ +- u_int vallen = 0; /* value length */ ++ u_int len; /* extension field value length */ + + /* + * If the IFF parameters are not valid, something awful +@@ -2150,11 +2165,10 @@ crypto_bob( + /* + * Extract r from the challenge. + */ +- vallen = ntohl(ep->vallen); +- len = ntohl(ep->opcode) & 0x0000ffff; +- if (vallen == 0 || len < VALUE_LEN || len - VALUE_LEN < vallen) +- return XEVNT_LEN; +- if ((r = BN_bin2bn((u_char *)ep->pkt, vallen, NULL)) == NULL) { ++ len = exten_payload_size(ep); ++ if (len == 0 || len > MAX_VALLEN) ++ return (XEVNT_LEN); ++ if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { + msyslog(LOG_ERR, "crypto_bob: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (XEVNT_ERR); +@@ -2166,7 +2180,7 @@ crypto_bob( + */ + bctx = BN_CTX_new(); bk = BN_new(); bn = BN_new(); + sdsa = DSA_SIG_new(); +- BN_rand(bk, vallen * 8, -1, 1); /* k */ ++ BN_rand(bk, len * 8, -1, 1); /* k */ + BN_mod_mul(bn, dsa->priv_key, r, dsa->q, bctx); /* b r mod q */ + BN_add(bn, bn, bk); + BN_mod(bn, bn, dsa->q, bctx); /* k + b r mod q */ +@@ -2185,16 +2199,16 @@ crypto_bob( + * Encode the values in ASN.1 and sign. The filestamp is from + * the local file. + */ +- vallen = i2d_DSA_SIG(sdsa, NULL); +- if (vallen == 0) { ++ len = i2d_DSA_SIG(sdsa, NULL); ++ if (len == 0) { + msyslog(LOG_ERR, "crypto_bob: %s", + ERR_error_string(ERR_get_error(), NULL)); + DSA_SIG_free(sdsa); + return (XEVNT_ERR); + } +- if (vallen > MAX_VALLEN) { +- msyslog(LOG_ERR, "crypto_bob: signature is too big: %d", +- vallen); ++ if (len > MAX_VALLEN) { ++ msyslog(LOG_ERR, "crypto_bob: signature is too big: %u", ++ len); + DSA_SIG_free(sdsa); + return (XEVNT_LEN); + } +@@ -2202,8 +2216,8 @@ crypto_bob( + tstamp = crypto_time(); + vp->tstamp = htonl(tstamp); + vp->fstamp = htonl(iffkey_info->fstamp); +- vp->vallen = htonl(vallen); +- ptr = emalloc(vallen); ++ vp->vallen = htonl(len); ++ ptr = emalloc(len); + vp->ptr = ptr; + i2d_DSA_SIG(sdsa, &ptr); + DSA_SIG_free(sdsa); +@@ -2214,9 +2228,9 @@ crypto_bob( + vp->sig = emalloc(sign_siglen); + EVP_SignInit(&ctx, sign_digest); + EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12); +- EVP_SignUpdate(&ctx, vp->ptr, vallen); +- if (EVP_SignFinal(&ctx, vp->sig, &vallen, sign_pkey)) +- vp->siglen = htonl(sign_siglen); ++ EVP_SignUpdate(&ctx, vp->ptr, len); ++ if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey)) ++ vp->siglen = htonl(len); + return (XEVNT_OK); + } + +@@ -2462,7 +2476,9 @@ crypto_bob2( + /* + * Extract r from the challenge. + */ +- len = ntohl(ep->vallen); ++ len = exten_payload_size(ep); ++ if (len == 0 || len > MAX_VALLEN) ++ return (XEVNT_LEN); + if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { + msyslog(LOG_ERR, "crypto_bob2: %s", + ERR_error_string(ERR_get_error(), NULL)); +@@ -2787,7 +2803,9 @@ crypto_bob3( + /* + * Extract r from the challenge. + */ +- len = ntohl(ep->vallen); ++ len = exten_payload_size(ep); ++ if (len == 0 || len > MAX_VALLEN) ++ return (XEVNT_LEN); + if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) { + msyslog(LOG_ERR, "crypto_bob3: %s", + ERR_error_string(ERR_get_error(), NULL)); +@@ -3002,8 +3020,11 @@ cert_sign( + if (tstamp == 0) + return (XEVNT_TSP); + ++ len = exten_payload_size(ep); ++ if (len == 0 || len > MAX_VALLEN) ++ return (XEVNT_LEN); + ptr = (u_char *)ep->pkt; +- if ((req = d2i_X509(NULL, &ptr, ntohl(ep->vallen))) == NULL) { ++ if ((req = d2i_X509(NULL, &ptr, len)) == NULL) { + msyslog(LOG_ERR, "cert_sign: %s", + ERR_error_string(ERR_get_error(), NULL)); + return (XEVNT_CRT); +@@ -3968,6 +3989,36 @@ crypto_config( + break; + } + } ++ ++/* ++ * Get payload size (internal value length) of an extension packet. If ++ * the inner value length does not match the outer packet length (that ++ * is, the value would end behind the frame given by the opcode/size ++ * field) the function will efectively return UINT_MAX. If the frame is ++ * too short to holda variable-sized value, the return value is zero. ++ */ ++static u_int ++exten_payload_size( ++ const struct exten * ep) ++{ ++ typedef const u_char *BPTR; ++ ++ size_t extn_size; ++ size_t data_size; ++ size_t head_size; ++ ++ data_size = 0; ++ if (NULL != ep) { ++ head_size = (BPTR)(&ep->vallen + 1) - (BPTR)ep; ++ extn_size = (uint16_t)(ntohl(ep->opcode) & 0x0000ffff); ++ if (extn_size >= head_size) { ++ data_size = (uint32_t)ntohl(ep->vallen); ++ if (data_size > extn_size - head_size) ++ data_size = ~(size_t)0u; ++ } ++ } ++ return (u_int)data_size; ++} + # else + int ntp_crypto_bs_pubkey; + # endif /* OPENSSL */ diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7701.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7701.patch new file mode 100644 index 0000000..2015c9a --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7701.patch @@ -0,0 +1,19 @@ +commit d7cd5e186034340402f1393e0813c7d2b14ea6ca +Author: +Date: Mon Sep 28 18:22:06 2015 +0200 + + [Bug 2909] - Slow memory leak in CRYPTO_ASSOC + - added missing call to 'free()' in ntp_crypto.c. + +diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c +index e9cd6c2..a7b693f 100644 +--- a/ntpd/ntp_crypto.c ++++ b/ntpd/ntp_crypto.c +@@ -508,6 +508,7 @@ crypto_recv( + rval = XEVNT_ERR; + break; + } ++ free(peer->cmmd); /* will be set again! */ + } + fp = emalloc(len); + memcpy(fp, ep, len); diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7703.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7703.patch new file mode 100644 index 0000000..2b0cb00 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7703.patch @@ -0,0 +1,52 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.cve-2015-7703 ntp-4.2.6p5/ntpd/ntp_parser.y +--- ntp-4.2.6p5/ntpd/ntp_parser.y.cve-2015-7703 2015-08-20 12:21:43.206525550 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_parser.y 2015-08-20 12:31:04.223172507 +0200 +@@ -1005,23 +1005,43 @@ misc_cmd_int_keyword + + misc_cmd_str_keyword + : T_Leapfile +- | T_Pidfile + | T_Qos + ; + + misc_cmd_str_lcl_keyword + : T_Logfile ++ | T_Pidfile + | T_Saveconfigdir + ; + + drift_parm + : T_String +- { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); } ++ { ++ if (input_from_file) { ++ enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); ++ } else { ++ YYFREE($1); ++ yyerror("driftfile remote configuration ignored"); ++ } ++ } + | T_String T_Double +- { enqueue(cfgt.vars, create_attr_dval(T_WanderThreshold, $2)); +- enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); } ++ { ++ if (input_from_file) { ++ enqueue(cfgt.vars, create_attr_dval(T_WanderThreshold, $2)); ++ enqueue(cfgt.vars, create_attr_sval(T_Driftfile, $1)); ++ } else { ++ YYFREE($1); ++ yyerror("driftfile remote configuration ignored"); ++ } ++ } + | /* Null driftfile, indicated by null string "\0" */ +- { enqueue(cfgt.vars, create_attr_sval(T_Driftfile, "\0")); } ++ { ++ if (input_from_file) { ++ enqueue(cfgt.vars, create_attr_sval(T_Driftfile, estrdup(""))); ++ } else { ++ yyerror("driftfile remote configuration ignored"); ++ } ++ } + ; + + variable_assign diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7704.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7704.patch new file mode 100644 index 0000000..a3e0d27 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7704.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.kodtest ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.kodtest 2015-09-24 18:20:19.121981664 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-09-24 18:20:54.596594166 +0200 +@@ -1165,7 +1165,7 @@ receive( + peer->ppoll = max(peer->minpoll, pkt->ppoll); + if (hismode == MODE_SERVER && hisleap == LEAP_NOTINSYNC && + hisstratum == STRATUM_UNSPEC && memcmp(&pkt->refid, +- "RATE", 4) == 0) { ++ "RATE", 4) == 0 && !(peer->flash & PKT_TEST_MASK)) { + peer->selbroken++; + report_event(PEVNT_RATE, peer, NULL); + if (pkt->ppoll > peer->minpoll) diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7852.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7852.patch new file mode 100644 index 0000000..1bac599 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7852.patch @@ -0,0 +1,22 @@ +diff -up ntp-4.2.6p5/ntpq/ntpq.c.cve-2015-7852 ntp-4.2.6p5/ntpq/ntpq.c +--- ntp-4.2.6p5/ntpq/ntpq.c.cve-2015-7852 2015-10-21 19:38:34.008129649 +0200 ++++ ntp-4.2.6p5/ntpq/ntpq.c 2015-10-21 19:39:40.207742621 +0200 +@@ -3449,12 +3449,17 @@ cookedprint( + char bv[401]; + int len; + ++ /* TALOS-CAN-0063: avoid buffer overrun */ + atoascii(name, MAXVARLEN, bn, sizeof(bn)); +- atoascii(value, MAXVARLEN, bv, sizeof(bv)); + if (output_raw != '*') { ++ atoascii(value, MAXVALLEN, ++ bv, sizeof(bv) - 1); + len = strlen(bv); + bv[len] = output_raw; + bv[len+1] = '\0'; ++ } else { ++ atoascii(value, MAXVALLEN, ++ bv, sizeof(bv)); + } + output(fp, bn, bv); + } diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7974.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7974.patch new file mode 100644 index 0000000..2f05130 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7974.patch @@ -0,0 +1,20 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-7974 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-7974 2016-01-21 14:06:18.958346184 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2016-01-21 14:16:34.894828262 +0100 +@@ -674,10 +674,13 @@ receive( + * succeed in bloating the key cache. If an autokey, + * purge it immediately, since we won't be needing it + * again. If the packet is authentic, it can mobilize an +- * association. Note that there is no key zero. ++ * association. If it's a persistent association using a ++ * symmetric key, the key ID has to match the configured ++ * value. Note that there is no key zero. + */ +- if (!authdecrypt(skeyid, (u_int32 *)pkt, authlen, +- has_mac)) ++ if ((peer && !(peer->flags & FLAG_PREEMPT) && ++ peer->keyid <= NTP_MAXKEY && skeyid != peer->keyid) || ++ !authdecrypt(skeyid, (u_int32 *)pkt, authlen, has_mac)) + is_authentic = AUTH_ERROR; + else + is_authentic = AUTH_OK; diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7977_7978.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7977_7978.patch new file mode 100644 index 0000000..ddcd91a --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7977_7978.patch @@ -0,0 +1,183 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_request.c.cve-2015-7977_7978 ntp-4.2.6p5/ntpd/ntp_request.c +--- ntp-4.2.6p5/ntpd/ntp_request.c.cve-2015-7977_7978 2011-12-01 03:55:17.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_request.c 2016-01-20 11:14:20.855586406 +0100 +@@ -1730,56 +1730,143 @@ setclr_flags( + loop_config(LOOP_DRIFTCOMP, drift_comp); + } + ++/* There have been some issues with the restrict list processing, ++ * ranging from problems with deep recursion (resulting in stack ++ * overflows) and overfull reply buffers. ++ * ++ * To avoid this trouble the list reversal is done iteratively using a ++ * scratch pad. ++ */ ++typedef struct RestrictStack RestrictStackT; ++struct RestrictStack { ++ RestrictStackT *link; ++ size_t fcnt; ++ const restrict_u *pres[63]; ++}; ++ ++static size_t ++getStackSheetSize( ++ RestrictStackT *sp ++ ) ++{ ++ if (sp) ++ return sizeof(sp->pres)/sizeof(sp->pres[0]); ++ return 0u; ++} ++ ++static int/*BOOL*/ ++pushRestriction( ++ RestrictStackT **spp, ++ const restrict_u *ptr ++ ) ++{ ++ RestrictStackT *sp; ++ ++ if (NULL == (sp = *spp) || 0 == sp->fcnt) { ++ /* need another sheet in the scratch pad */ ++ sp = emalloc(sizeof(*sp)); ++ sp->link = *spp; ++ sp->fcnt = getStackSheetSize(sp); ++ *spp = sp; ++ } ++ sp->pres[--sp->fcnt] = ptr; ++ return TRUE; ++} ++ ++static int/*BOOL*/ ++popRestriction( ++ RestrictStackT **spp, ++ const restrict_u **opp ++ ) ++{ ++ RestrictStackT *sp; ++ ++ if (NULL == (sp = *spp) || sp->fcnt >= getStackSheetSize(sp)) ++ return FALSE; ++ ++ *opp = sp->pres[sp->fcnt++]; ++ if (sp->fcnt >= getStackSheetSize(sp)) { ++ /* discard sheet from scratch pad */ ++ *spp = sp->link; ++ free(sp); ++ } ++ return TRUE; ++} ++ ++static void ++flushRestrictionStack( ++ RestrictStackT **spp ++ ) ++{ ++ RestrictStackT *sp; ++ ++ while (NULL != (sp = *spp)) { ++ *spp = sp->link; ++ free(sp); ++ } ++} ++ + /* +- * list_restrict4 - recursive helper for list_restrict dumps IPv4 ++ * list_restrict4 - iterative helper for list_restrict dumps IPv4 + * restriction list in reverse order. + */ + static void + list_restrict4( +- restrict_u * res, ++ const restrict_u * res, + struct info_restrict ** ppir + ) + { ++ RestrictStackT * rpad; + struct info_restrict * pir; + +- if (res->link != NULL) +- list_restrict4(res->link, ppir); +- + pir = *ppir; +- pir->addr = htonl(res->u.v4.addr); +- if (client_v6_capable) +- pir->v6_flag = 0; +- pir->mask = htonl(res->u.v4.mask); +- pir->count = htonl(res->count); +- pir->flags = htons(res->flags); +- pir->mflags = htons(res->mflags); +- *ppir = (struct info_restrict *)more_pkt(); ++ for (rpad = NULL; res; res = res->link) ++ if (!pushRestriction(&rpad, res)) ++ break; ++ ++ while (pir && popRestriction(&rpad, &res)) { ++ pir->addr = htonl(res->u.v4.addr); ++ if (client_v6_capable) ++ pir->v6_flag = 0; ++ pir->mask = htonl(res->u.v4.mask); ++ pir->count = htonl(res->count); ++ pir->flags = htons(res->flags); ++ pir->mflags = htons(res->mflags); ++ pir = (struct info_restrict *)more_pkt(); ++ } ++ flushRestrictionStack(&rpad); ++ *ppir = pir; + } + +- + /* +- * list_restrict6 - recursive helper for list_restrict dumps IPv6 ++ * list_restrict6 - iterative helper for list_restrict dumps IPv6 + * restriction list in reverse order. + */ + static void + list_restrict6( +- restrict_u * res, ++ const restrict_u * res, + struct info_restrict ** ppir + ) + { ++ RestrictStackT * rpad; + struct info_restrict * pir; + +- if (res->link != NULL) +- list_restrict6(res->link, ppir); +- + pir = *ppir; +- pir->addr6 = res->u.v6.addr; +- pir->mask6 = res->u.v6.mask; +- pir->v6_flag = 1; +- pir->count = htonl(res->count); +- pir->flags = htons(res->flags); +- pir->mflags = htons(res->mflags); +- *ppir = (struct info_restrict *)more_pkt(); ++ for (rpad = NULL; res; res = res->link) ++ if (!pushRestriction(&rpad, res)) ++ break; ++ ++ while (pir && popRestriction(&rpad, &res)) { ++ pir->addr6 = res->u.v6.addr; ++ pir->mask6 = res->u.v6.mask; ++ pir->v6_flag = 1; ++ pir->count = htonl(res->count); ++ pir->flags = htons(res->flags); ++ pir->mflags = htons(res->mflags); ++ pir = (struct info_restrict *)more_pkt(); ++ } ++ flushRestrictionStack(&rpad); ++ *ppir = pir; + } + + +@@ -1803,8 +1890,7 @@ list_restrict( + /* + * The restriction lists are kept sorted in the reverse order + * than they were originally. To preserve the output semantics, +- * dump each list in reverse order. A recursive helper function +- * achieves that. ++ * dump each list in reverse order. The workers take care of that. + */ + list_restrict4(restrictlist4, &ir); + if (client_v6_capable) diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-7979.patch b/SOURCES/ntp-4.2.6p5-cve-2015-7979.patch new file mode 100644 index 0000000..ac9c006 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-7979.patch @@ -0,0 +1,23 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-7979 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2015-7979 2016-01-21 14:20:45.760431895 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2016-01-21 14:46:13.027106826 +0100 +@@ -1127,7 +1127,8 @@ receive( + report_event(PEVNT_AUTH, peer, "crypto_NAK"); + peer->flash |= TEST5; /* bad auth */ + peer->badauth++; +- if (peer->flags & FLAG_PREEMPT) { ++ if (peer->flags & FLAG_PREEMPT && hismode != MODE_BROADCAST && ++ !(peer->flash & (TEST2 | TEST3))) { + unpeer(peer); + return; + } +@@ -1153,7 +1154,8 @@ receive( + if (has_mac && + (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)) + fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask); +- if (peer->flags & FLAG_PREEMPT) { ++ if (peer->flags & FLAG_PREEMPT && hismode != MODE_BROADCAST && ++ !(peer->flash & (TEST2 | TEST3))) { + unpeer(peer); + return; + } diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-8138.patch b/SOURCES/ntp-4.2.6p5-cve-2015-8138.patch new file mode 100644 index 0000000..e8d9b91 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-8138.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.orig ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.orig 2015-11-06 10:48:42.672684827 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-11-06 13:03:14.284092484 +0100 +@@ -1069,7 +1069,7 @@ receive( + * the packet is not bogus in symmetric interleaved mode. + */ + } else if (peer->flip == 0) { +- if (!L_ISEQU(&p_org, &peer->aorg)) { ++ if (L_ISZERO(&p_org) || !L_ISEQU(&p_org, &peer->aorg)) { + peer->bogusorg++; + peer->flash |= TEST2; /* bogus */ + if (!L_ISZERO(&peer->dst) && L_ISEQU(&p_org, diff --git a/SOURCES/ntp-4.2.6p5-cve-2015-8158.patch b/SOURCES/ntp-4.2.6p5-cve-2015-8158.patch new file mode 100644 index 0000000..0767b30 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2015-8158.patch @@ -0,0 +1,126 @@ +diff -U0 ntp-4.2.6p5/ChangeLog.cve-2015-8158 ntp-4.2.6p5/ChangeLog +diff -up ntp-4.2.6p5/ntpdc/ntpdc.c.cve-2015-8158 ntp-4.2.6p5/ntpdc/ntpdc.c +--- ntp-4.2.6p5/ntpdc/ntpdc.c.cve-2015-8158 2016-01-20 14:06:21.035659659 +0100 ++++ ntp-4.2.6p5/ntpdc/ntpdc.c 2016-01-20 14:25:39.734622168 +0100 +@@ -657,6 +657,10 @@ getresponse( + fd_set fds; + int n; + int pad; ++ /* absolute timeout checks. Not 'time_t' by intention! */ ++ uint32_t tobase; /* base value for timeout */ ++ uint32_t tospan; /* timeout span (max delay) */ ++ uint32_t todiff; /* current delay */ + + /* + * This is pretty tricky. We may get between 1 and many packets +@@ -673,12 +677,14 @@ getresponse( + lastseq = 999; /* too big to be a sequence number */ + memset(haveseq, 0, sizeof(haveseq)); + FD_ZERO(&fds); ++ tobase = (uint32_t)time(NULL); + + again: + if (firstpkt) + tvo = tvout; + else + tvo = tvsout; ++ tospan = (uint32_t)tvo.tv_sec + (tvo.tv_usec != 0); + + FD_SET(sockfd, &fds); + n = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvo); +@@ -687,6 +693,17 @@ getresponse( + warning("select fails", "", ""); + return -1; + } ++ ++ /* ++ * Check if this is already too late. Trash the data and fake a ++ * timeout if this is so. ++ */ ++ todiff = (((uint32_t)time(NULL)) - tobase) & 0x7FFFFFFFu; ++ if ((n > 0) && (todiff > tospan)) { ++ n = recv(sockfd, (char *)&rpkt, sizeof(rpkt), 0); ++ n = 0; /* faked timeout return from 'select()'*/ ++ } ++ + if (n == 0) { + /* + * Timed out. Return what we have +@@ -831,8 +848,10 @@ getresponse( + } + + /* +- * So far, so good. Copy this data into the output array. ++ * So far, so good. Copy this data into the output array. Bump ++ * the timeout base, in case we expect more data. + */ ++ tobase = (uint32_t)time(NULL); + if ((datap + datasize + (pad * items)) > (pktdata + pktdatasize)) { + int offset = datap - pktdata; + growpktdata(); +diff -up ntp-4.2.6p5/ntpq/ntpq.c.cve-2015-8158 ntp-4.2.6p5/ntpq/ntpq.c +--- ntp-4.2.6p5/ntpq/ntpq.c.cve-2015-8158 2016-01-20 14:06:21.493660755 +0100 ++++ ntp-4.2.6p5/ntpq/ntpq.c 2016-01-20 14:13:56.132819820 +0100 +@@ -836,6 +836,10 @@ getresponse( + int len; + int first; + char *data; ++ /* absolute timeout checks. Not 'time_t' by intention! */ ++ uint32_t tobase; /* base value for timeout */ ++ uint32_t tospan; /* timeout span (max delay) */ ++ uint32_t todiff; /* current delay */ + + /* + * This is pretty tricky. We may get between 1 and MAXFRAG packets +@@ -852,6 +856,8 @@ getresponse( + numfrags = 0; + seenlastfrag = 0; + ++ tobase = (uint32_t)time(NULL); ++ + FD_ZERO(&fds); + + /* +@@ -864,7 +870,8 @@ getresponse( + tvo = tvout; + else + tvo = tvsout; +- ++ tospan = (uint32_t)tvo.tv_sec + (tvo.tv_usec != 0); ++ + FD_SET(sockfd, &fds); + n = select(sockfd + 1, &fds, NULL, NULL, &tvo); + +@@ -872,6 +879,17 @@ getresponse( + warning("select fails", "", ""); + return -1; + } ++ ++ /* ++ * Check if this is already too late. Trash the data and ++ * fake a timeout if this is so. ++ */ ++ todiff = (((uint32_t)time(NULL)) - tobase) & 0x7FFFFFFFu; ++ if ((n > 0) && (todiff > tospan)) { ++ n = recv(sockfd, (char *)&rpkt, sizeof(rpkt), 0); ++ n = 0; /* faked timeout return from 'select()'*/ ++ } ++ + if (n == 0) { + /* + * Timed out. Return what we have +@@ -1166,10 +1184,13 @@ getresponse( + } + + /* +- * Copy the data into the data buffer. ++ * Copy the data into the data buffer, and bump the ++ * timout base in case we need more. + */ + memcpy((char *)pktdata + offset, rpkt.data, count); + ++ tobase = (uint32_t)time(NULL); ++ + /* + * If we've seen the last fragment, look for holes in the sequence. + * If there aren't any, we're done. diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-1548.patch b/SOURCES/ntp-4.2.6p5-cve-2016-1548.patch new file mode 100644 index 0000000..f273c99 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-1548.patch @@ -0,0 +1,63 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-1548 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-1548 2016-04-28 08:37:42.513561354 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2016-04-28 09:30:59.450347729 +0200 +@@ -306,6 +306,7 @@ receive( + int authlen; /* offset of MAC field */ + int is_authentic = 0; /* cryptosum ok */ + int retcode = AM_NOMATCH; /* match code */ ++ int xleave_mismatch = 0; /* mismatch in xleave mode */ + keyid_t skeyid = 0; /* key IDs */ + u_int32 opcode = 0; /* extension field opcode */ + sockaddr_u *dstadr_sin; /* active runway */ +@@ -1067,9 +1068,8 @@ receive( + } + + /* +- * Check for bogus packet in basic mode. If found, switch to +- * interleaved mode and resynchronize, but only after confirming +- * the packet is not bogus in symmetric interleaved mode. ++ * Check for bogus packet in basic mode. If found, check if it's not ++ * a valid packet in symmetric interleaved mode. + */ + } else if (peer->flip == 0) { + if (L_ISZERO(&p_org) || !L_ISEQU(&p_org, &peer->aorg)) { +@@ -1077,8 +1077,7 @@ receive( + peer->flash |= TEST2; /* bogus */ + if (!L_ISZERO(&peer->dst) && L_ISEQU(&p_org, + &peer->dst)) { +- peer->flip = 1; +- report_event(PEVNT_XLEAVE, peer, NULL); ++ xleave_mismatch = 1; + } + } else { + L_CLR(&peer->aorg); +@@ -1152,6 +1151,16 @@ receive( + } + + /* ++ * If the packet is bogus in basic mode but not in symmetric ++ * interleaved mode and it passed the authentication check, ++ * enable the mode and resynchronize. ++ */ ++ if (xleave_mismatch && hismode == MODE_ACTIVE) { ++ peer->flip = 1; ++ report_event(PEVNT_XLEAVE, peer, NULL); ++ } ++ ++ /* + * Update the state variables. + */ + if (peer->flip == 0) { +@@ -1715,5 +1723,12 @@ clock_update( + sys_rootdelay = peer->delay + peer->rootdelay; + sys_reftime = peer->dst; ++ ++ /* Randomize the fraction part of the reference time to not reveal ++ peer->dst to NTP clients as it could be used in a DoS attack ++ enabling the symmetric interleaved mode with spoofed packets */ ++ ntp_crypto_random_buf(&sys_reftime.l_uf, sizeof (sys_reftime.l_uf)); ++ if (L_ISHIS(&sys_reftime, &peer->dst)) ++ sys_reftime.l_ui--; + + #ifdef DEBUG + if (debug) diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-1550.patch b/SOURCES/ntp-4.2.6p5-cve-2016-1550.patch new file mode 100644 index 0000000..22dbfb9 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-1550.patch @@ -0,0 +1,24 @@ +diff -up ntp-4.2.6p5/libntp/a_md5encrypt.c.cve-2016-1550 ntp-4.2.6p5/libntp/a_md5encrypt.c +--- ntp-4.2.6p5/libntp/a_md5encrypt.c.cve-2016-1550 2016-04-27 15:11:40.955168086 +0200 ++++ ntp-4.2.6p5/libntp/a_md5encrypt.c 2016-04-27 15:13:41.126499861 +0200 +@@ -88,7 +88,7 @@ MD5authdecrypt( + "MAC decrypt: MAC length error"); + return (0); + } +- return (!memcmp(digest, (char *)pkt + length + 4, len)); ++ return (!CRYPTO_memcmp(digest, (char *)pkt + length + 4, len)); + } + + /* +diff -up ntp-4.2.6p5/sntp/crypto.c.cve-2016-1550 ntp-4.2.6p5/sntp/crypto.c +--- ntp-4.2.6p5/sntp/crypto.c.cve-2016-1550 2010-11-14 09:47:00.000000000 +0100 ++++ ntp-4.2.6p5/sntp/crypto.c 2016-04-27 15:13:41.126499861 +0200 +@@ -58,7 +58,7 @@ auth_md5( + if (!hash_len) + authentic = FALSE; + else +- authentic = !memcmp(digest, pkt_data + pkt_size + 4, ++ authentic = !CRYPTO_memcmp(digest, pkt_data + pkt_size + 4, + hash_len); + return authentic; + } diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-2518.patch b/SOURCES/ntp-4.2.6p5-cve-2016-2518.patch new file mode 100644 index 0000000..ed68938 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-2518.patch @@ -0,0 +1,19 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_request.c.cve-2016-2518 ntp-4.2.6p5/ntpd/ntp_request.c +--- ntp-4.2.6p5/ntpd/ntp_request.c.cve-2016-2518 2016-04-29 13:41:22.690006470 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_request.c 2016-04-29 13:56:12.039936978 +0200 +@@ -1342,7 +1342,6 @@ do_conf( + memset(&temp_cp, 0, sizeof(struct conf_peer)); + memcpy(&temp_cp, (char *)cp, INFO_ITEMSIZE(inpkt->mbz_itemsize)); + +-#if 0 /* paranoid checking - these are done in newpeer() */ + fl = 0; + while (items-- > 0 && !fl) { + if (((temp_cp.version) > NTP_VERSION) +@@ -1363,7 +1362,6 @@ do_conf( + req_ack(srcadr, inter, inpkt, INFO_ERR_FMT); + return; + } +-#endif /* end paranoid checking */ + + /* + * Looks okay, try it out diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-7426.patch b/SOURCES/ntp-4.2.6p5-cve-2016-7426.patch new file mode 100644 index 0000000..5f24774 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-7426.patch @@ -0,0 +1,74 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-7426 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-7426 2016-11-21 16:14:42.804048665 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2016-11-21 17:32:45.619107824 +0100 +@@ -473,30 +473,7 @@ receive( + } + + /* +- * Update the MRU list and finger the cloggers. It can be a +- * little expensive, so turn it off for production use. +- */ +- restrict_mask = ntp_monitor(rbufp, restrict_mask); +- if (restrict_mask & RES_LIMITED) { +- sys_limitrejected++; +- if (!(restrict_mask & RES_KOD) || MODE_BROADCAST == +- hismode || MODE_SERVER == hismode) +- return; /* rate exceeded */ +- +- if (hismode == MODE_CLIENT) +- fast_xmit(rbufp, MODE_SERVER, skeyid, +- restrict_mask); +- else +- fast_xmit(rbufp, MODE_ACTIVE, skeyid, +- restrict_mask); +- return; /* rate exceeded */ +- } +- restrict_mask &= ~RES_KOD; +- +- /* +- * We have tossed out as many buggy packets as possible early in +- * the game to reduce the exposure to a clogging attack. now we +- * have to burn some cycles to find the association and ++ * now we have to burn some cycles to find the association and + * authenticate the packet if required. Note that we burn only + * MD5 cycles, again to reduce exposure. There may be no + * matching association and that's okay. +@@ -519,6 +496,27 @@ receive( + NTOHL_FP(&pkt->xmt, &p_xmt); + + /* ++ * Update the MRU list and finger the cloggers. It can be a ++ * little expensive, so turn it off for production use. ++ */ ++ restrict_mask = ntp_monitor(rbufp, restrict_mask); ++ if (restrict_mask & RES_LIMITED && retcode == AM_FXMIT) { ++ sys_limitrejected++; ++ if (!(restrict_mask & RES_KOD) || MODE_BROADCAST == ++ hismode || MODE_SERVER == hismode) ++ return; /* rate exceeded */ ++ ++ if (hismode == MODE_CLIENT) ++ fast_xmit(rbufp, MODE_SERVER, skeyid, ++ restrict_mask); ++ else ++ fast_xmit(rbufp, MODE_ACTIVE, skeyid, ++ restrict_mask); ++ return; /* rate exceeded */ ++ } ++ restrict_mask &= ~RES_KOD; ++ ++ /* + * Authentication is conditioned by three switches: + * + * NOPEER (RES_NOPEER) do not mobilize an association unless +@@ -940,6 +938,10 @@ receive( + case AM_NEWPASS: + if (!AUTH(sys_authenticate | (restrict_mask & + (RES_NOPEER | RES_DONTTRUST)), is_authentic)) { ++ if (restrict_mask & RES_LIMITED) { ++ sys_limitrejected++; ++ return; ++ } + + /* + * If authenticated but cannot mobilize an diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-7429.patch b/SOURCES/ntp-4.2.6p5-cve-2016-7429.patch new file mode 100644 index 0000000..ddaffeb --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-7429.patch @@ -0,0 +1,39 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_peer.c.cve-2016-7429 ntp-4.2.6p5/ntpd/ntp_peer.c +--- ntp-4.2.6p5/ntpd/ntp_peer.c.cve-2016-7429 2016-11-21 16:47:51.738767270 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_peer.c 2016-11-21 16:52:02.434034046 +0100 +@@ -241,7 +241,8 @@ findpeer( + hash = NTP_HASH_ADDR(srcadr); + for (p = peer_hash[hash]; p != NULL; p = p->next) { + if (SOCK_EQ(srcadr, &p->srcadr) && +- NSRCPORT(srcadr) == NSRCPORT(&p->srcadr)) { ++ NSRCPORT(srcadr) == NSRCPORT(&p->srcadr) && ++ (p->hmode == MODE_BCLIENT || p->dstadr == rbufp->dstadr)) { + + /* + * if the association matching rules determine +@@ -288,13 +289,6 @@ findpeer( + */ + if (NULL == p) { + *action = MATCH_ASSOC(NO_PEER, pkt_mode); +- } else if (p->dstadr != rbufp->dstadr) { +- set_peerdstadr(p, rbufp->dstadr); +- if (p->dstadr == rbufp->dstadr) { +- DPRINTF(1, ("Changed %s local address to match response\n", +- stoa(&p->srcadr))); +- return findpeer(rbufp, pkt_mode, action); +- } + } + return p; + } +@@ -548,6 +542,11 @@ set_peerdstadr( + { + struct peer * unlinked; + ++ DEBUG_INSIST(p != NULL); ++ ++ if (p == NULL) ++ return; ++ + if (p->dstadr == dstadr) + return; + diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-7433.patch b/SOURCES/ntp-4.2.6p5-cve-2016-7433.patch new file mode 100644 index 0000000..16dba95 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-7433.patch @@ -0,0 +1,23 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-7433 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2016-7433 2016-11-21 17:54:29.604704343 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2016-11-21 17:55:04.231569928 +0100 +@@ -2914,8 +2914,7 @@ root_distance( + * where: + * delta is the round-trip delay + * DELTA is the root delay +- * epsilon is the remote server precision + local precision +- * + (15 usec each second) ++ * epsilon is the peer dispersion (15 usec each second) + * EPSILON is the root dispersion + * phi is the peer jitter statistic + * +@@ -2926,8 +2925,7 @@ root_distance( + * other worse choices. + */ + dtemp = (peer->delay + peer->rootdelay) / 2 +- + LOGTOD(peer->precision) +- + LOGTOD(sys_precision) ++ + peer->disp + + clock_phi * (current_time - peer->update) + + peer->rootdisp + + peer->jitter; diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-9310.patch b/SOURCES/ntp-4.2.6p5-cve-2016-9310.patch new file mode 100644 index 0000000..c5eb750 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-9310.patch @@ -0,0 +1,16 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_control.c.cve-2016-9310 ntp-4.2.6p5/ntpd/ntp_control.c +--- ntp-4.2.6p5/ntpd/ntp_control.c.cve-2016-9310 2016-11-21 16:30:56.826396891 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_control.c 2016-11-21 16:31:54.171830390 +0100 +@@ -88,9 +88,9 @@ static struct ctl_proc control_codes[] = + { CTL_OP_READVAR, NOAUTH, read_variables }, + { CTL_OP_WRITEVAR, AUTH, write_variables }, + { CTL_OP_READCLOCK, NOAUTH, read_clock_status }, +- { CTL_OP_WRITECLOCK, NOAUTH, write_clock_status }, +- { CTL_OP_SETTRAP, NOAUTH, set_trap }, +- { CTL_OP_UNSETTRAP, NOAUTH, unset_trap }, ++ { CTL_OP_WRITECLOCK, AUTH, write_clock_status }, ++ { CTL_OP_SETTRAP, AUTH, set_trap }, ++ { CTL_OP_UNSETTRAP, AUTH, unset_trap }, + { CTL_OP_SAVECONFIG, AUTH, save_config }, + { CTL_OP_CONFIGURE, AUTH, configure }, + { NO_REQUEST, 0 } diff --git a/SOURCES/ntp-4.2.6p5-cve-2016-9311.patch b/SOURCES/ntp-4.2.6p5-cve-2016-9311.patch new file mode 100644 index 0000000..8be2dfd --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2016-9311.patch @@ -0,0 +1,36 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_control.c.cve-2016-9311 ntp-4.2.6p5/ntpd/ntp_control.c +--- ntp-4.2.6p5/ntpd/ntp_control.c.cve-2016-9311 2016-11-21 16:14:42.800048565 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_control.c 2016-11-21 16:18:24.484590147 +0100 +@@ -3080,6 +3080,22 @@ report_event( + if (num_ctl_traps <= 0) + return; + ++ /* [Bug 3119] ++ * Peer Events should be associated with a peer -- hence the ++ * name. But there are instances where this function is called ++ * *without* a valid peer. This happens e.g. with an unsolicited ++ * CryptoNAK, or when a leap second alarm is going off while ++ * currently without a system peer. ++ * ++ * The most sensible approach to this seems to bail out here if ++ * this happens. Avoiding to call this function would also ++ * bypass the log reporting in the first part of this function, ++ * and this is probably not the best of all options. ++ * -*-perlinger@ntp.org-*- ++ */ ++ if ((err & PEER_EVENT) && !peer) ++ return; ++ + /* + * Set up the outgoing packet variables + */ +@@ -3104,8 +3120,7 @@ report_event( + #endif /* OPENSSL */ + ctl_putsys(i); + } +- } else { +- NTP_INSIST(peer != NULL); ++ } else if (NULL != peer) { /* paranoia -- skip output */ + rpkt.associd = htons(peer->associd); + rpkt.status = htons(ctlpeerstatus(peer)); + diff --git a/SOURCES/ntp-4.2.6p5-cve-2017-6462.patch b/SOURCES/ntp-4.2.6p5-cve-2017-6462.patch new file mode 100644 index 0000000..a7e4a24 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2017-6462.patch @@ -0,0 +1,47 @@ +2017-02-12 13:46:35+01:00, perlinger@ntp.org + [Sec 3388] NTP-01-014: Buffer Overflow in DPTS Clock + +diff -up ntp-4.2.6p5/ntpd/refclock_datum.c.cve-2017-6462 ntp-4.2.6p5/ntpd/refclock_datum.c +--- ntp-4.2.6p5/ntpd/refclock_datum.c.cve-2017-6462 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/refclock_datum.c 2017-03-22 13:34:48.851357820 +0100 +@@ -584,7 +584,7 @@ datum_pts_receive( + struct recvbuf *rbufp + ) + { +- int i; ++ int i, nb; + l_fp tstmp; + struct datum_pts_unit *datum_pts; + char *dpt; +@@ -623,22 +623,23 @@ datum_pts_receive( + ** received to reduce the jitter. + */ + +- if (datum_pts->nbytes == 0) { ++ nb = datum_pts->nbytes; ++ if (nb == 0) { + datum_pts->lastrec = rbufp->recv_time; + } + + /* + ** Increment our count to the number of bytes received so far. Return if we + ** haven't gotten all seven bytes yet. ++ ** [Sec 3388] make sure we do not overrun the buffer. ++ ** TODO: what to do with excessive bytes, if we ever get them? + */ +- +- for (i=0; iretbuf[datum_pts->nbytes+i] = dpt[i]; ++ for (i=0; (i < dpend) && (nb < sizeof(datum_pts->retbuf)); i++, nb++) { ++ datum_pts->retbuf[nb] = dpt[i]; + } +- +- datum_pts->nbytes += dpend; +- +- if (datum_pts->nbytes != 7) { ++ datum_pts->nbytes = nb; ++ ++ if (nb < 7) { + return; + } + diff --git a/SOURCES/ntp-4.2.6p5-cve-2017-6463.patch b/SOURCES/ntp-4.2.6p5-cve-2017-6463.patch new file mode 100644 index 0000000..4067582 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2017-6463.patch @@ -0,0 +1,30 @@ +2017-02-12 11:08:16+01:00, perlinger@ntp.org + [Sec 3387] NTP-01-012: Authenticated DoS via Malicious Config Option + +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.cve-2017-6463 ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.cve-2017-6463 2017-03-22 14:28:51.342870650 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2017-03-22 15:20:44.970380429 +0100 +@@ -1264,7 +1264,8 @@ destroy_address_node( + struct address_node *my_node + ) + { +- NTP_REQUIRE(NULL != my_node); ++ if (NULL == my_node) ++ return; + NTP_REQUIRE(NULL != my_node->address); + + free(my_node->address); +@@ -3563,10 +3564,10 @@ config_unpeers( + curr_unpeer = next_node(curr_unpeer)) { + + /* +- * Either AssocID will be zero, and we unpeer by name/ +- * address addr, or it is nonzero and addr NULL. ++ * If we have no address attached, assume we have to ++ * unpeer by AssocID. + */ +- if (curr_unpeer->assocID) { ++ if (!curr_unpeer->addr) { + peer = findpeerbyassoc((u_int)curr_unpeer->assocID); + if (peer != NULL) { + peer_clear(peer, "GONE"); diff --git a/SOURCES/ntp-4.2.6p5-cve-2017-6464.patch b/SOURCES/ntp-4.2.6p5-cve-2017-6464.patch new file mode 100644 index 0000000..6725c83 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-cve-2017-6464.patch @@ -0,0 +1,86 @@ +2017-02-12 09:49:29+01:00, perlinger@ntp.org + [Sec 3389] NTP-01-016: Denial of Service via Malformed Config + +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.cve-2017-6464 ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.cve-2017-6464 2017-03-22 12:54:11.257454635 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2017-03-22 12:57:06.919024166 +0100 +@@ -311,6 +311,9 @@ void ntpd_set_tod_using(const char *); + static u_int32 get_pfxmatch(const char **, struct masks *); + static u_int32 get_match(const char *, struct masks *); + static u_int32 get_logmask(const char *); ++static int/*BOOL*/ is_refclk_addr(const struct address_node * addr); ++ ++ + static int getnetnum(const char *num,sockaddr_u *addr, int complain, + enum gnn_type a_type); + static int get_multiple_netnums(const char *num, sockaddr_u *addr, +@@ -1342,7 +1344,10 @@ create_peer_node( + break; + + case T_Ttl: +- if (my_node->ttl >= MAX_TTL) { ++ if (is_refclk_addr(addr)) { ++ msyslog(LOG_ERR, "'ttl' does not apply for refclocks"); ++ errflag = 1; ++ } else if (option->value.i < 0 || option->value.i >= MAX_TTL) { + msyslog(LOG_ERR, "ttl: invalid argument"); + errflag = 1; + } +@@ -1351,7 +1355,12 @@ create_peer_node( + break; + + case T_Mode: +- my_node->ttl = option->value.i; ++ if (is_refclk_addr(addr)) { ++ my_node->ttl = option->value.i; ++ } else { ++ msyslog(LOG_ERR, "'mode' does not apply for network peers"); ++ errflag = 1; ++ } + break; + + case T_Key: +@@ -2674,6 +2685,16 @@ apply_enable_disable( + } + } + ++/* Hack to disambiguate 'server' statements for refclocks and network peers. ++ * Please note the qualification 'hack'. It's just that. ++ */ ++static int/*BOOL*/ ++is_refclk_addr( ++ const struct address_node * addr ++ ) ++{ ++ return addr && addr->address && !strncmp(addr->address, "127.127.", 8); ++} + + static void + config_system_opts( +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2017-6464 ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.cve-2017-6464 2017-03-22 12:54:11.270454677 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2017-03-22 12:54:11.279454706 +0100 +@@ -3017,8 +3017,9 @@ peer_xmit( + } + } + peer->t21_bytes = sendlen; +- sendpkt(&peer->srcadr, peer->dstadr, sys_ttl[peer->ttl], +- &xpkt, sendlen); ++ sendpkt(&peer->srcadr, peer->dstadr, ++ sys_ttl[(peer->ttl >= sys_ttlmax) ? sys_ttlmax : peer->ttl], ++ &xpkt, sendlen); + peer->sent++; + peer->throttle += (1 << peer->minpoll) - 2; + +@@ -3330,8 +3331,9 @@ peer_xmit( + exit (-1); + } + peer->t21_bytes = sendlen; +- sendpkt(&peer->srcadr, peer->dstadr, sys_ttl[peer->ttl], &xpkt, +- sendlen); ++ sendpkt(&peer->srcadr, peer->dstadr, ++ sys_ttl[(peer->ttl >= sys_ttlmax) ? sys_ttlmax : peer->ttl], ++ &xpkt, sendlen); + peer->sent++; + peer->throttle += (1 << peer->minpoll) - 2; + diff --git a/SOURCES/ntp-4.2.6p5-defreqkey.patch b/SOURCES/ntp-4.2.6p5-defreqkey.patch new file mode 100644 index 0000000..07f3062 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-defreqkey.patch @@ -0,0 +1,14 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.defreqkey ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.defreqkey 2017-04-13 15:29:13.287254279 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2017-04-13 15:40:49.776307282 +0200 +@@ -1870,8 +1870,8 @@ config_auth( + exit(1); + } + +- req_keytype = NID_md5; +- req_hashlen = 16; ++ req_keytype = NID_sha1; ++ req_hashlen = 20; + MD5auth_setkey(req_keyid, req_keytype, rankey, sizeof(rankey)); + authtrust(req_keyid, 1); + } diff --git a/SOURCES/ntp-4.2.6p5-delaycalib.patch b/SOURCES/ntp-4.2.6p5-delaycalib.patch new file mode 100644 index 0000000..7e9a310 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-delaycalib.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.delaycalib ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.delaycalib 2012-02-28 15:57:57.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2012-02-28 16:01:30.080135978 +0100 +@@ -1514,7 +1514,7 @@ process_packet( + */ + if (FLAG_BC_VOL & peer->flags) { + peer->flags &= ~FLAG_BC_VOL; +- peer->delay = (peer->offset - p_offset) * 2; ++ peer->delay = fabs(peer->offset - p_offset) * 2; + } + p_del = peer->delay; + p_offset += p_del / 2; diff --git a/SOURCES/ntp-4.2.6p5-dscp.patch b/SOURCES/ntp-4.2.6p5-dscp.patch new file mode 100644 index 0000000..6b91e2c --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-dscp.patch @@ -0,0 +1,163 @@ +diff -up ntp-4.2.6p5/html/miscopt.html.dscp ntp-4.2.6p5/html/miscopt.html +--- ntp-4.2.6p5/html/miscopt.html.dscp 2015-06-04 15:50:44.726240345 +0200 ++++ ntp-4.2.6p5/html/miscopt.html 2015-06-04 15:50:44.734240368 +0200 +@@ -132,6 +132,8 @@ +
The trap receiver will generally log event messages and other information from the server in a log file. While such monitor programs may also request their own trap dynamically, configuring a trap receiver will ensure that no messages are lost when the server is started.
+
ttl hop ...
+
This command specifies a list of TTL values in increasing order. up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
++
dscp dscp
++
This command specifies the Differentiated Services Code Point (DSCP) value that is used in sent NTP packets. The default value is 48 for Class Selector 6 (CS6).
+ +
+ +diff -up ntp-4.2.6p5/include/ntp_io.h.dscp ntp-4.2.6p5/include/ntp_io.h +--- ntp-4.2.6p5/include/ntp_io.h.dscp 2010-12-25 10:40:34.000000000 +0100 ++++ ntp-4.2.6p5/include/ntp_io.h 2015-06-04 15:50:44.734240368 +0200 +@@ -80,6 +80,7 @@ typedef enum { + } nic_rule_action; + + ++extern int qos; + isc_boolean_t get_broadcastclient_flag(void); + extern int is_ip_address(const char *, sockaddr_u *); + extern void sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *); +diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.dscp ntp-4.2.6p5/ntpd/keyword-gen.c +--- ntp-4.2.6p5/ntpd/keyword-gen.c.dscp 2015-06-04 15:50:44.727240348 +0200 ++++ ntp-4.2.6p5/ntpd/keyword-gen.c 2015-06-04 15:50:44.734240368 +0200 +@@ -38,6 +38,7 @@ struct key_tok ntp_keywords[] = { + { "calldelay", T_Calldelay, FOLLBY_TOKEN }, + { "disable", T_Disable, FOLLBY_TOKEN }, + { "driftfile", T_Driftfile, FOLLBY_STRING }, ++{ "dscp", T_Dscp, FOLLBY_TOKEN }, + { "enable", T_Enable, FOLLBY_TOKEN }, + { "end", T_End, FOLLBY_TOKEN }, + { "filegen", T_Filegen, FOLLBY_TOKEN }, +diff -up ntp-4.2.6p5/ntpd/ntp_config.c.dscp ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.dscp 2015-06-04 15:50:44.728240351 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2015-06-04 15:50:44.735240371 +0200 +@@ -204,9 +204,6 @@ int cryptosw; /* crypto command called + extern int sys_maxclock; + extern char *stats_drift_file; /* name of the driftfile */ + extern char *leapseconds_file_name; /*name of the leapseconds file */ +-#ifdef HAVE_IPTOS_SUPPORT +-extern unsigned int qos; /* QoS setting */ +-#endif /* HAVE_IPTOS_SUPPORT */ + + #ifdef BC_LIST_FRAMEWORK_NOT_YET_USED + /* +@@ -3201,6 +3198,10 @@ config_vars( + } else + stats_config(STATS_FREQ_FILE, curr_var->value.s); + break; ++ case T_Dscp: ++ /* DSCP is in the upper 6 bits of the IP TOS/DS field */ ++ qos = curr_var->value.i << 2; ++ break; + case T_WanderThreshold: + wander_threshold = curr_var->value.d; + break; +@@ -3737,7 +3738,6 @@ config_ntpd( + ) + { + config_nic_rules(ptree); +- io_open_sockets(); + config_monitor(ptree); + config_auth(ptree); + config_tos(ptree); +@@ -3750,6 +3750,9 @@ config_ntpd( + config_ttl(ptree); + config_trap(ptree); + config_vars(ptree); ++ ++ io_open_sockets(); ++ + config_other_modes(ptree); + config_peers(ptree); + config_unpeers(ptree); +diff -up ntp-4.2.6p5/ntpd/ntp_io.c.dscp ntp-4.2.6p5/ntpd/ntp_io.c +--- ntp-4.2.6p5/ntpd/ntp_io.c.dscp 2015-06-04 15:50:44.725240342 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_io.c 2015-06-04 15:57:54.209359075 +0200 +@@ -66,6 +66,9 @@ + + extern int listen_to_virtual_ips; + ++/* set IP_TOS/IPV6_TCLASS to minimize packet delay */ ++int qos = IPTOS_PREC_INTERNETCONTROL; ++ + /* + * NIC rule entry + */ +@@ -161,15 +164,6 @@ static int pktinfo_status = 0; /* is IP + static struct refclockio *refio; + #endif /* REFCLOCK */ + +-#if defined(HAVE_IPTOS_SUPPORT) +-/* set IP_TOS to minimize packet delay */ +-# if defined(IPTOS_PREC_INTERNETCONTROL) +- unsigned int qos = IPTOS_PREC_INTERNETCONTROL; +-# else +- unsigned int qos = IPTOS_LOWDELAY; +-# endif +-#endif +- + /* + * File descriptor masks etc. for call to select + * Not needed for I/O Completion Ports +@@ -3034,6 +3028,13 @@ open_socket( + * IPv6 specific options go here + */ + if (IS_IPV6(addr)) { ++#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS) ++ if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, (char*)&qos, ++ sizeof(qos))) ++ msyslog(LOG_ERR, ++ "setsockopt IPV6_TCLASS (%02x) fails on address %s: %m", ++ qos, stoa(addr)); ++#endif /* IPPROTO_IPV6 && IPV6_TCLASS */ + #ifdef IPV6_V6ONLY + if (isc_net_probe_ipv6only() == ISC_R_SUCCESS + && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, +diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.dscp ntp-4.2.6p5/ntpd/ntp_parser.y +--- ntp-4.2.6p5/ntpd/ntp_parser.y.dscp 2015-06-04 15:50:44.728240351 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_parser.y 2015-06-04 15:50:44.736240374 +0200 +@@ -94,6 +94,7 @@ + %token T_Double + %token T_Driftfile + %token T_Drop ++%token T_Dscp + %token T_Ellipsis /* "..." not "ellipsis" */ + %token T_Enable + %token T_End +@@ -268,6 +269,7 @@ + %type log_config_command + %type log_config_list + %type misc_cmd_dbl_keyword ++%type misc_cmd_int_keyword + %type misc_cmd_str_keyword + %type misc_cmd_str_lcl_keyword + %type nic_rule_class +@@ -920,6 +922,13 @@ miscellaneous_command + av = create_attr_dval($1, $2); + enqueue(cfgt.vars, av); + } ++ | misc_cmd_int_keyword T_Integer ++ { ++ struct attr_val *av; ++ ++ av = create_attr_ival($1, $2); ++ enqueue(cfgt.vars, av); ++ } + | misc_cmd_str_keyword T_String + { + struct attr_val *av; +@@ -990,6 +999,10 @@ misc_cmd_dbl_keyword + | T_Tick + ; + ++misc_cmd_int_keyword ++ : T_Dscp ++ ; ++ + misc_cmd_str_keyword + : T_Leapfile + | T_Pidfile diff --git a/SOURCES/ntp-4.2.6p5-fipsmd5.patch b/SOURCES/ntp-4.2.6p5-fipsmd5.patch new file mode 100644 index 0000000..b6d8889 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-fipsmd5.patch @@ -0,0 +1,47 @@ +diff -up ntp-4.2.6p5/libntp/a_md5encrypt.c.fipsmd5 ntp-4.2.6p5/libntp/a_md5encrypt.c +--- ntp-4.2.6p5/libntp/a_md5encrypt.c.fipsmd5 2011-12-01 03:55:17.000000000 +0100 ++++ ntp-4.2.6p5/libntp/a_md5encrypt.c 2012-10-24 16:24:04.972358878 +0200 +@@ -38,7 +38,11 @@ MD5authencrypt( + * was creaded. + */ + INIT_SSL(); +- EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); ++ if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) { ++ msyslog(LOG_ERR, ++ "MAC encrypt: digest init failed"); ++ return (0); ++ } + EVP_DigestUpdate(&ctx, key, (u_int)cache_keylen); + EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length); + EVP_DigestFinal(&ctx, digest, &len); +@@ -71,7 +75,11 @@ MD5authdecrypt( + * was created. + */ + INIT_SSL(); +- EVP_DigestInit(&ctx, EVP_get_digestbynid(type)); ++ if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) { ++ msyslog(LOG_ERR, ++ "MAC decrypt: digest init failed"); ++ return (0); ++ } + EVP_DigestUpdate(&ctx, key, (u_int)cache_keylen); + EVP_DigestUpdate(&ctx, (u_char *)pkt, (u_int)length); + EVP_DigestFinal(&ctx, digest, &len); +@@ -101,7 +109,16 @@ addr2refid(sockaddr_u *addr) + return (NSRCADR(addr)); + + INIT_SSL(); +- EVP_DigestInit(&ctx, EVP_get_digestbynid(NID_md5)); ++ EVP_MD_CTX_init(&ctx); ++#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW ++ /* MD5 is not used as a crypto hash here. */ ++ EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); ++#endif ++ if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) { ++ msyslog(LOG_ERR, ++ "MD5 init failed"); ++ exit(1); ++ } + EVP_DigestUpdate(&ctx, (u_char *)PSOCK_ADDR6(addr), + sizeof(struct in6_addr)); + EVP_DigestFinal(&ctx, digest, &len); diff --git a/SOURCES/ntp-4.2.6p5-hexpw.patch b/SOURCES/ntp-4.2.6p5-hexpw.patch new file mode 100644 index 0000000..6e603c4 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-hexpw.patch @@ -0,0 +1,236 @@ +diff -up ntp-4.2.6p5/include/ntp_stdlib.h.hexpw ntp-4.2.6p5/include/ntp_stdlib.h +--- ntp-4.2.6p5/include/ntp_stdlib.h.hexpw 2012-11-20 14:43:14.001139737 +0100 ++++ ntp-4.2.6p5/include/ntp_stdlib.h 2012-11-20 14:43:14.047139771 +0100 +@@ -66,7 +66,8 @@ extern int authhavekey (keyid_t); + extern int authistrusted (keyid_t); + extern int authreadkeys (const char *); + extern void authtrust (keyid_t, u_long); +-extern int authusekey (keyid_t, int, const u_char *); ++extern int authusekey (keyid_t, int, const char *); ++extern int authdecodekey (const char *, u_char *, int); + + extern u_long calyearstart (u_long); + extern const char *clockname (int); +diff -up ntp-4.2.6p5/libntp/authreadkeys.c.hexpw ntp-4.2.6p5/libntp/authreadkeys.c +--- ntp-4.2.6p5/libntp/authreadkeys.c.hexpw 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/libntp/authreadkeys.c 2012-11-20 14:43:14.047139771 +0100 +@@ -3,7 +3,6 @@ + */ + #include + #include +-#include + + #include "ntp_fp.h" + #include "ntp.h" +@@ -77,7 +76,6 @@ authreadkeys( + char buf[512]; /* lots of room for line */ + u_char keystr[20]; + int len; +- int j; + + /* + * Open file. Complain and return if it can't be opened. +@@ -162,10 +160,7 @@ authreadkeys( + #endif /* OPENSSL */ + + /* +- * Finally, get key and insert it. If it is longer than 20 +- * characters, it is a binary string encoded in hex; +- * otherwise, it is a text string of printable ASCII +- * characters. ++ * Finally, get key and insert it. + */ + token = nexttok(&line); + if (token == NULL) { +@@ -173,31 +168,15 @@ authreadkeys( + "authreadkeys: no key for key %d", keyno); + continue; + } +- len = strlen(token); +- if (len <= 20) { +- MD5auth_setkey(keyno, keytype, (u_char *)token, len); +- } else { +- char hex[] = "0123456789abcdef"; +- u_char temp; +- char *ptr; +- int jlim; +- +- jlim = min(len, 2 * sizeof(keystr)); +- for (j = 0; j < jlim; j++) { +- ptr = strchr(hex, tolower(token[j])); +- if (ptr == NULL) { +- msyslog(LOG_ERR, +- "authreadkeys: invalid hex digit for key %d", keyno); +- continue; +- } +- temp = (u_char)(ptr - hex); +- if (j & 1) +- keystr[j / 2] |= temp; +- else +- keystr[j / 2] = temp << 4; +- } +- MD5auth_setkey(keyno, keytype, keystr, jlim / 2); ++ ++ len = authdecodekey(token, keystr, sizeof (keystr)); ++ if (!len) { ++ msyslog(LOG_ERR, ++ "authreadkeys: could not decode key %d", keyno); ++ continue; + } ++ ++ MD5auth_setkey(keyno, keytype, keystr, len); + } + fclose(fp); + return (1); +diff -up ntp-4.2.6p5/libntp/authusekey.c.hexpw ntp-4.2.6p5/libntp/authusekey.c +--- ntp-4.2.6p5/libntp/authusekey.c.hexpw 2009-12-09 08:36:37.000000000 +0100 ++++ ntp-4.2.6p5/libntp/authusekey.c 2012-11-20 14:43:14.048139771 +0100 +@@ -7,6 +7,7 @@ + #include "ntp_types.h" + #include "ntp_string.h" + #include "ntp_stdlib.h" ++#include "ntp.h" + + /* + * Types of ascii representations for keys. "Standard" means a 64 bit +@@ -19,17 +20,62 @@ int + authusekey( + keyid_t keyno, + int keytype, +- const u_char *str ++ const char *str + ) + { +- const u_char *cp; + int len; ++ u_char key[20]; + +- cp = str; +- len = strlen((const char *)cp); +- if (len == 0) ++ len = authdecodekey(str, key, sizeof(key)); ++ if (!len) + return 0; + +- MD5auth_setkey(keyno, keytype, str, (int)strlen((const char *)str)); ++ MD5auth_setkey(keyno, keytype, key, len); + return 1; + } ++ ++/* ++ * authdecodekey - decode binary or ASCII key from string ++ * ++ * Returns the length of the parsed key, zero if invalid. ++ */ ++int ++authdecodekey( ++ const char *str, ++ u_char *key, ++ int max_length ++ ) ++{ ++ int len; ++ ++ /* ++ * If the string is longer than 20 characters, it is ++ * a binary string encoded in hex; otherwise, it is ++ * a text string of printable ASCII characters. ++ */ ++ len = strlen(str); ++ ++ if (len <= 20) { ++ len = min(len, max_length); ++ memcpy(key, str, len); ++ } else { ++ char hex[] = "0123456789abcdef"; ++ u_char temp; ++ char *ptr; ++ int j; ++ ++ len = min(len / 2, max_length); ++ for (j = 0; j < len * 2; j++) { ++ ptr = strchr(hex, tolower(str[j])); ++ if (ptr == NULL) ++ return 0; ++ temp = (u_char)(ptr - hex); ++ if (j & 1) ++ key[j / 2] |= temp; ++ else ++ key[j / 2] = temp << 4; ++ } ++ } ++ ++ return len; ++} +diff -up ntp-4.2.6p5/ntpdc/ntpdc.c.hexpw ntp-4.2.6p5/ntpdc/ntpdc.c +--- ntp-4.2.6p5/ntpdc/ntpdc.c.hexpw 2011-12-25 00:27:15.000000000 +0100 ++++ ntp-4.2.6p5/ntpdc/ntpdc.c 2012-11-20 14:43:14.048139771 +0100 +@@ -942,12 +942,10 @@ sendrequest( + } + if (!authistrusted(info_auth_keyid)) { + pass = getpass_keytype(info_auth_keytype); +- if ('\0' == pass[0]) { ++ if (!authusekey(info_auth_keyid, info_auth_keytype, pass)) { + fprintf(stderr, "Invalid password\n"); + return 1; + } +- authusekey(info_auth_keyid, info_auth_keytype, +- (u_char *)pass); + authtrust(info_auth_keyid, 1); + } + qpkt.auth_seq = AUTH_SEQ(1, 0); +@@ -1825,16 +1823,21 @@ passwd( + } + } + if (!interactive) { +- authusekey(info_auth_keyid, info_auth_keytype, +- (u_char *)pcmd->argval[0].string); ++ if (!authusekey(info_auth_keyid, info_auth_keytype, ++ pcmd->argval[0].string)) { ++ fprintf(fp, "Invalid password\n"); ++ return; ++ } + authtrust(info_auth_keyid, 1); + } else { + pass = getpass_keytype(info_auth_keytype); + if (*pass == '\0') + (void) fprintf(fp, "Password unchanged\n"); + else { +- authusekey(info_auth_keyid, info_auth_keytype, +- (u_char *)pass); ++ if (!authusekey(info_auth_keyid, info_auth_keytype, pass)) { ++ fprintf(fp, "Invalid password\n"); ++ return; ++ } + authtrust(info_auth_keyid, 1); + } + } +diff -up ntp-4.2.6p5/ntpq/ntpq.c.hexpw ntp-4.2.6p5/ntpq/ntpq.c +--- ntp-4.2.6p5/ntpq/ntpq.c.hexpw 2011-12-25 00:27:15.000000000 +0100 ++++ ntp-4.2.6p5/ntpq/ntpq.c 2012-11-20 14:43:14.049139771 +0100 +@@ -1276,12 +1276,10 @@ sendrequest( + } + if (!authistrusted(info_auth_keyid)) { + pass = getpass_keytype(info_auth_keytype); +- if ('\0' == pass[0]) { ++ if (!authusekey(info_auth_keyid, info_auth_keytype, pass)) { + fprintf(stderr, "Invalid password\n"); + return 1; + } +- authusekey(info_auth_keyid, info_auth_keytype, +- (u_char *)pass); + authtrust(info_auth_keyid, 1); + } + +@@ -2498,7 +2496,10 @@ passwd( + return; + } + } +- authusekey(info_auth_keyid, info_auth_keytype, (u_char *)pass); ++ if (!authusekey(info_auth_keyid, info_auth_keytype, pass)) { ++ fprintf(fp, "Invalid password\n"); ++ return; ++ } + authtrust(info_auth_keyid, 1); + } + diff --git a/SOURCES/ntp-4.2.6p5-identlen.patch b/SOURCES/ntp-4.2.6p5-identlen.patch new file mode 100644 index 0000000..e9691aa --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-identlen.patch @@ -0,0 +1,58 @@ +diff -up ntp-4.2.6p5/html/keygen.html.identlen ntp-4.2.6p5/html/keygen.html +--- ntp-4.2.6p5/html/keygen.html.identlen 2012-12-05 11:43:46.666828864 +0100 ++++ ntp-4.2.6p5/html/keygen.html 2012-12-05 12:00:45.331085982 +0100 +@@ -43,7 +43,7 @@ + +

Synopsis

+ +-

ntp-keygen [ -deGHIMPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA ++

ntp-keygen [ -deGHIMPT ] [ -b modulus ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA + | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ + -i group ] + [ -m modulus ] [ -p passwd2 ] [ -q passwd1 ] [ -S +@@ -140,6 +140,8 @@ +

Command Line Options

+ +
++
-b modulus
++
Set the modulus for generating identity keys to modulus bits. The modulus defaults to 256, but can be set from 256 (32 octets) to 2048 (256 octets). Use the larger moduli with caution, as this can consume considerable computing resources and increases the size of authenticated packets.
+ +
-c [ RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ]
+
Select certificate and message digest/signature encryption scheme. Note that +diff -up ntp-4.2.6p5/util/ntp-keygen-opts.def.identlen ntp-4.2.6p5/util/ntp-keygen-opts.def +--- ntp-4.2.6p5/util/ntp-keygen-opts.def.identlen 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen-opts.def 2012-12-05 12:03:17.991124514 +0100 +@@ -16,6 +16,19 @@ include = '#include '; + #include version.def + + flag = { ++ value = b; ++ name = imbits; ++ arg-type = number; ++ arg-name = imbits; ++ arg-range = '256->2048'; ++ ifdef = OPENSSL; ++ descrip = "identity modulus bits"; ++ doc = <<- _EndOfDoc_ ++ The number of bits in the identity modulus. The default is 256. ++ _EndOfDoc_; ++}; ++ ++flag = { + value = c; + name = certificate; + arg-type = string; +diff -up ntp-4.2.6p5/util/ntp-keygen.c.identlen ntp-4.2.6p5/util/ntp-keygen.c +--- ntp-4.2.6p5/util/ntp-keygen.c.identlen 2011-12-25 00:27:16.000000000 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen.c 2012-12-05 12:03:43.318130907 +0100 +@@ -318,6 +318,10 @@ main( + mvpar++; + nkeys = OPT_VALUE_MV_KEYS; + } ++ ++ if (HAVE_OPT( IMBITS )) ++ modulus2 = OPT_VALUE_IMBITS; ++ + if (HAVE_OPT( MODULUS )) + modulus = OPT_VALUE_MODULUS; + diff --git a/SOURCES/ntp-4.2.6p5-keylen.patch b/SOURCES/ntp-4.2.6p5-keylen.patch new file mode 100644 index 0000000..5dc50b8 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-keylen.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/libntp/authreadkeys.c.keylen ntp-4.2.6p5/libntp/authreadkeys.c +--- ntp-4.2.6p5/libntp/authreadkeys.c.keylen 2015-02-09 12:33:15.549485698 +0100 ++++ ntp-4.2.6p5/libntp/authreadkeys.c 2015-02-09 13:03:44.938842731 +0100 +@@ -74,7 +74,7 @@ authreadkeys( + keyid_t keyno; + int keytype; + char buf[512]; /* lots of room for line */ +- u_char keystr[20]; ++ u_char keystr[32]; + int len; + + /* diff --git a/SOURCES/ntp-4.2.6p5-leapreset.patch b/SOURCES/ntp-4.2.6p5-leapreset.patch new file mode 100644 index 0000000..81722fb --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-leapreset.patch @@ -0,0 +1,18 @@ +commit 5f0420ad1ee3528bf83a28ea54c51af2b09ecfa5 +Author: +Date: Mon Nov 19 20:17:35 2012 -0800 + + [Bug 2246] Clear sys_leap when voting says to disarm the leap + +diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c +index 1259d52..397a80f 100644 +--- a/ntpd/ntp_proto.c ++++ b/ntpd/ntp_proto.c +@@ -1948,6 +1948,7 @@ clock_update( + } else if (leapsec > 0) { + report_event(EVNT_DISARMED, NULL, NULL); + leapsec = 0; ++ sys_leap = LEAP_NOWARNING; + } + break; + diff --git a/SOURCES/ntp-4.2.6p5-logdefault.patch b/SOURCES/ntp-4.2.6p5-logdefault.patch new file mode 100644 index 0000000..177a59b --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-logdefault.patch @@ -0,0 +1,30 @@ +diff -up ntp-4.2.6p5/html/miscopt.html.logdefault ntp-4.2.6p5/html/miscopt.html +--- ntp-4.2.6p5/html/miscopt.html.logdefault 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/html/miscopt.html 2014-01-03 15:08:11.947681966 +0100 +@@ -56,11 +56,11 @@ +
While not strictly a security function, the Autokey protocol provides means to securely retrieve the current or updated leapsecond values from a server.
+
logconfig configkeyword
+
This command controls the amount and type of output written to the system syslog facility or the alternate logfile log file. All configkeyword keywords can be prefixed with =, + and -, where = sets the syslogmask, + adds and - removes messages. syslog messages can be controlled in four classes (clock, peer, sys and sync). Within these classes four types of messages can be controlled: informational messages (info), event messages (events), statistics messages (statistics) and status messages (status).
+-
Configuration keywords are formed by concatenating the message class with the event class. The all prefix can be used instead of a message class. A message class may also be followed by the all keyword to enable/disable all messages of the respective message class. By default, logconfig output is set to allsync.
++
Configuration keywords are formed by concatenating the message class with the event class. The all prefix can be used instead of a message class. A message class may also be followed by the all keyword to enable/disable all messages of the respective message class. By default, logconfig output is set to =syncall +sysevents +sysstatus.
+
Thus, a minimal log configuration could look like this:
+-
logconfig=syncstatus +sysevents
++
logconfig =syncstatus +sysevents
+
This would just list the synchronizations state of ntpd and the major system events. For a simple reference server, the following minimum message configuration could be useful:
+-
logconfig allsync +allclock
++
logconfig =syncall +clockall
+
This configuration will list all clock information and synchronization information. All other events and messages about peers, system events and so on is suppressed.
+
logfile logfile
+
This command specifies the location of an alternate log file to be used instead of the default system syslog facility. This is the same operation as the -l command line option.
+diff -up ntp-4.2.6p5/ntpd/ntp_config.c.logdefault ntp-4.2.6p5/ntpd/ntp_config.c +--- ntp-4.2.6p5/ntpd/ntp_config.c.logdefault 2011-12-01 03:55:17.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_config.c 2014-01-03 15:05:44.293553494 +0100 +@@ -3835,7 +3835,7 @@ getconfig( + + #endif /* SYS_WINNT */ + res_fp = NULL; +- ntp_syslogmask = NLOG_SYNCMASK; /* set more via logconfig */ ++ ntp_syslogmask = NLOG_SYNCMASK | NLOG_SYSEVENT | NLOG_SYSSTATUS; /* set more via logconfig */ + + /* + * install a non default variable with this daemon version diff --git a/SOURCES/ntp-4.2.6p5-mcastjoin.patch b/SOURCES/ntp-4.2.6p5-mcastjoin.patch new file mode 100644 index 0000000..a86bc68 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-mcastjoin.patch @@ -0,0 +1,76 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_io.c.mcastjoin ntp-4.2.6p5/ntpd/ntp_io.c +--- ntp-4.2.6p5/ntpd/ntp_io.c.mcastjoin 2015-04-13 14:41:59.108323479 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_io.c 2015-04-13 14:43:46.468637433 +0200 +@@ -2038,6 +2038,32 @@ update_interfaces( + if (sys_bclient) + io_setbclient(); + ++ /* ++ * Check multicast interfaces and try to join multicast groups if ++ * not joined yet. ++ */ ++ for (ep = ep_list; ep != NULL; ep = ep->elink) { ++ remaddr_t *entry; ++ ++ if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags)) ++ continue; ++ ++ /* Find remote address that was linked to this interface */ ++ for (entry = remoteaddr_list; ++ entry != NULL; ++ entry = entry->link) { ++ if (entry->ep == ep) { ++ if (socket_multicast_enable(ep, &entry->addr)) { ++ msyslog(LOG_INFO, ++ "Joined %s socket to multicast group %s", ++ stoa(&ep->sin), ++ stoa(&entry->addr)); ++ } ++ break; ++ } ++ } ++ } ++ + return new_interface_found; + } + +@@ -2467,12 +2493,12 @@ socket_multicast_enable( + IP_ADD_MEMBERSHIP, + (char *)&mreq, + sizeof(mreq))) { +- msyslog(LOG_ERR, ++ DPRINTF(2, ( + "setsockopt IP_ADD_MEMBERSHIP failed: %m on socket %d, addr %s for %x / %x (%s)", + iface->fd, stoa(&iface->sin), + mreq.imr_multiaddr.s_addr, + mreq.imr_interface.s_addr, +- stoa(maddr)); ++ stoa(maddr))); + return ISC_FALSE; + } + DPRINTF(4, ("Added IPv4 multicast membership on socket %d, addr %s for %x / %x (%s)\n", +@@ -2497,10 +2523,10 @@ socket_multicast_enable( + if (setsockopt(iface->fd, IPPROTO_IPV6, + IPV6_JOIN_GROUP, (char *)&mreq6, + sizeof(mreq6))) { +- msyslog(LOG_ERR, ++ DPRINTF(2, ( + "setsockopt IPV6_JOIN_GROUP failed: %m on socket %d, addr %s for interface %u (%s)", + iface->fd, stoa(&iface->sin), +- mreq6.ipv6mr_interface, stoa(maddr)); ++ mreq6.ipv6mr_interface, stoa(maddr))); + return ISC_FALSE; + } + DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %u (%s)\n", +@@ -2793,11 +2819,6 @@ io_multicast_add( + "Joined %s socket to multicast group %s", + stoa(&ep->sin), + stoa(addr)); +- else +- msyslog(LOG_ERR, +- "Failed to join %s socket to multicast group %s", +- stoa(&ep->sin), +- stoa(addr)); + } + + add_addr_to_list(addr, one_ep); diff --git a/SOURCES/ntp-4.2.6p5-mlock.patch b/SOURCES/ntp-4.2.6p5-mlock.patch new file mode 100644 index 0000000..ba04c54 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-mlock.patch @@ -0,0 +1,69 @@ +diff -up ntp-4.2.6p5/html/ntpd.html.mlock ntp-4.2.6p5/html/ntpd.html +--- ntp-4.2.6p5/html/ntpd.html.mlock 2012-11-23 14:58:15.401693701 +0100 ++++ ntp-4.2.6p5/html/ntpd.html 2012-11-23 14:58:15.415693714 +0100 +@@ -32,7 +32,7 @@ + +
+

Synopsis

+- ntpd [ -46aAbdDgLnNqx ] [ -c conffile ] [ -f driftfile ] [ -i jaildir ] [ -I iface ] [ -k keyfile ] [ -l logfile ] [ -p pidfile ] [ -P priority ] [ -r broadcastdelay ] [ -s statsdir ] [ -t key ] [ -u user[:group] ] [ -U interface_update_interval ] [ -v variable ] [ -V variable ] ++ ntpd [ -46aAbdDgLmnNqx ] [ -c conffile ] [ -f driftfile ] [ -i jaildir ] [ -I iface ] [ -k keyfile ] [ -l logfile ] [ -p pidfile ] [ -P priority ] [ -r broadcastdelay ] [ -s statsdir ] [ -t key ] [ -u user[:group] ] [ -U interface_update_interval ] [ -v variable ] [ -V variable ] +

Description

+

The ntpd program is an operating system daemon that synchronises the system clock with remote NTP time servers or local reference clocks. It is a complete implementation of the Network Time Protocol (NTP) version 4, but also retains compatibility with version 3, as defined by RFC-1305, and version 1 and 2, as defined by RFC-1059 and RFC-1119, respectively. The program can operate in any of several modes, as described on the Association Management page, and with both symmetric key and public key cryptography, as described on the Authentication Options page.

+

The ntpd program ordinarily requires a configuration file as described on the Configuration Commands and Options collection above. However a client can discover remote servers and configure them automatically. This makes it possible to deploy a fleet of workstations without specifying configuration details specific to the local environment. Further details are on the Automatic Server Discovery page.

+@@ -123,6 +123,8 @@ +
Do not listen to virtual interfaces, defined as those with names containing a colon. This option is deprecated. Please consider using the configuration file interface command, which is more versatile.
+
-M
+
Raise scheduler precision to its maximum (1 msec) using timeBeginPeriod. (Windows only)
++
-m ++
Lock memory. +
-n
+
Don't fork.
+
-N
+diff -up ntp-4.2.6p5/ntpd/ntpd.c.mlock ntp-4.2.6p5/ntpd/ntpd.c +--- ntp-4.2.6p5/ntpd/ntpd.c.mlock 2012-11-23 14:58:15.369693666 +0100 ++++ ntp-4.2.6p5/ntpd/ntpd.c 2012-11-23 14:58:15.416693715 +0100 +@@ -723,7 +723,8 @@ ntpdmain( + } + #endif + +-#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE) ++#if defined(MCL_CURRENT) && defined(MCL_FUTURE) ++ if (HAVE_OPT( MLOCK )) { + # ifdef HAVE_SETRLIMIT + /* + * Set the stack limit to something smaller, so that we don't lock a lot +@@ -749,7 +750,7 @@ ntpdmain( + * fail if we drop root privlege. To be useful the value + * has to be larger than the largest ntpd resident set size. + */ +- rl.rlim_cur = rl.rlim_max = 32*1024*1024; ++ rl.rlim_cur = rl.rlim_max = 128*1024*1024; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) { + msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m"); + } +@@ -761,6 +762,7 @@ ntpdmain( + */ + if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0) + msyslog(LOG_ERR, "mlockall(): %m"); ++ } + #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */ + # ifdef HAVE_PLOCK + # ifdef PROCLOCK +diff -up ntp-4.2.6p5/ntpd/ntpdbase-opts.def.mlock ntp-4.2.6p5/ntpd/ntpdbase-opts.def +--- ntp-4.2.6p5/ntpd/ntpdbase-opts.def.mlock 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntpdbase-opts.def 2012-11-23 15:07:16.960261421 +0100 +@@ -226,6 +226,14 @@ flag = { + }; + + flag = { ++ name = mlock; ++ value = m; ++ descrip = "Lock memory"; ++ doc = <<- _EndOfDoc_ ++ _EndOfDoc_; ++}; ++ ++flag = { + ifdef = SYS_WINNT; + name = modifymmtimer; + value = M; diff --git a/SOURCES/ntp-4.2.6p5-monwarn.patch b/SOURCES/ntp-4.2.6p5-monwarn.patch new file mode 100644 index 0000000..a1aa2d4 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-monwarn.patch @@ -0,0 +1,17 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.monwarn ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.monwarn 2014-07-03 18:03:37.985020147 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2014-07-03 18:06:08.656380757 +0200 +@@ -3701,8 +3701,12 @@ proto_config( + case PROTO_MONITOR: /* monitoring (monitor) */ + if (value) + mon_start(MON_ON); +- else ++ else { + mon_stop(MON_ON); ++ if (mon_enabled) ++ msyslog(LOG_WARNING, ++ "monitor cannot be disabled with limited restrict"); ++ } + break; + + case PROTO_NTP: /* NTP discipline (ntp) */ diff --git a/SOURCES/ntp-4.2.6p5-mreadvar.patch b/SOURCES/ntp-4.2.6p5-mreadvar.patch new file mode 100644 index 0000000..ed9dffc --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-mreadvar.patch @@ -0,0 +1,13 @@ +diff -up ntp-4.2.6p5/ntpq/ntpq-subs.c.mreadvar ntp-4.2.6p5/ntpq/ntpq-subs.c +--- ntp-4.2.6p5/ntpq/ntpq-subs.c.mreadvar 2011-12-25 00:27:15.000000000 +0100 ++++ ntp-4.2.6p5/ntpq/ntpq-subs.c 2015-02-09 12:13:02.215449708 +0100 +@@ -857,8 +857,8 @@ mreadvar( + &from, &to)) + return; + ++ memset(tmplist, 0, sizeof(tmplist)); + if (pcmd->nargs >= 3) { +- memset(tmplist, 0, sizeof(tmplist)); + doaddvlist(tmplist, pcmd->argval[2].string); + pvars = tmplist; + } else { diff --git a/SOURCES/ntp-4.2.6p5-multiopts.patch b/SOURCES/ntp-4.2.6p5-multiopts.patch new file mode 100644 index 0000000..6311152 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-multiopts.patch @@ -0,0 +1,19 @@ +diff -up ntp-4.2.6p5/ntpd/ntpdbase-opts.def.multiopts ntp-4.2.6p5/ntpd/ntpdbase-opts.def +--- ntp-4.2.6p5/ntpd/ntpdbase-opts.def.multiopts 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/ntpdbase-opts.def 2012-11-23 14:54:49.132477448 +0100 +@@ -259,6 +259,7 @@ flag = { + flag = { + name = pidfile; + value = p; ++ max = 2; + arg-type = string; + descrip = "path to the PID file"; + doc = <<- _EndOfDoc_ +@@ -355,6 +356,7 @@ flag = { + ifdef = HAVE_DROPROOT; + name = user; + value = u; ++ max = 2; + arg-type = string; + descrip = "Run as userid (or userid:groupid)"; + omitted-usage = "built without --enable-clockctl or --enable-linuxcaps"; diff --git a/SOURCES/ntp-4.2.6p5-nanoshm.patch b/SOURCES/ntp-4.2.6p5-nanoshm.patch new file mode 100644 index 0000000..5327a53 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-nanoshm.patch @@ -0,0 +1,141 @@ +diff -up ntp-4.2.6p5/ntpd/refclock_shm.c.nanoshm ntp-4.2.6p5/ntpd/refclock_shm.c +--- ntp-4.2.6p5/ntpd/refclock_shm.c.nanoshm 2010-02-04 08:26:55.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/refclock_shm.c 2014-08-25 15:43:45.608698816 +0200 +@@ -83,16 +83,18 @@ struct shmTime { + * use values + * clear valid + */ +- int count; +- time_t clockTimeStampSec; +- int clockTimeStampUSec; +- time_t receiveTimeStampSec; +- int receiveTimeStampUSec; +- int leap; +- int precision; +- int nsamples; +- int valid; +- int dummy[10]; ++ volatile int count; ++ time_t clockTimeStampSec; ++ int clockTimeStampUSec; ++ time_t receiveTimeStampSec; ++ int receiveTimeStampUSec; ++ int leap; ++ int precision; ++ int nsamples; ++ volatile int valid; ++ unsigned clockTimeStampNSec; /* Unsigned ns timestamps */ ++ unsigned receiveTimeStampNSec; /* Unsigned ns timestamps */ ++ int dummy[8]; + }; + + struct shmunit { +@@ -320,31 +322,68 @@ int shm_peek( + return(0); + } + if (shm->valid) { +- struct timeval tvr; +- struct timeval tvt; ++ struct timespec tvr; ++ struct timespec tvt; + struct tm *t; + int ok=1; ++ unsigned cns_new, rns_new; ++ int cnt; + tvr.tv_sec = 0; +- tvr.tv_usec = 0; ++ tvr.tv_nsec = 0; + tvt.tv_sec = 0; +- tvt.tv_usec = 0; ++ tvt.tv_nsec = 0; + switch (shm->mode) { +- case 0: { +- tvr.tv_sec=shm->receiveTimeStampSec; +- tvr.tv_usec=shm->receiveTimeStampUSec; +- tvt.tv_sec=shm->clockTimeStampSec; +- tvt.tv_usec=shm->clockTimeStampUSec; +- } +- break; +- case 1: { +- int cnt=shm->count; +- tvr.tv_sec=shm->receiveTimeStampSec; +- tvr.tv_usec=shm->receiveTimeStampUSec; +- tvt.tv_sec=shm->clockTimeStampSec; +- tvt.tv_usec=shm->clockTimeStampUSec; +- ok=(cnt==shm->count); +- } +- break; ++ case 0: ++ tvr.tv_sec = shm->receiveTimeStampSec; ++ tvr.tv_nsec = shm->receiveTimeStampUSec * 1000; ++ rns_new = shm->receiveTimeStampNSec; ++ tvt.tv_sec = shm->clockTimeStampSec; ++ tvt.tv_nsec = shm->clockTimeStampUSec * 1000; ++ cns_new = shm->clockTimeStampNSec; ++ ++ /* Since these comparisons are between unsigned ++ ** variables they are always well defined, and any ++ ** (signed) underflow will turn into very large ++ ** unsigned values, well above the 1000 cutoff ++ */ ++ if ( ((cns_new - (unsigned)tvt.tv_nsec) < 1000) ++ && ((rns_new - (unsigned)tvr.tv_nsec) < 1000)) { ++ tvt.tv_nsec = cns_new; ++ tvr.tv_nsec = rns_new; ++ } ++ // At this point tvr and tvt contains valid ns-level ++ // timestamps, possibly generated by extending the ++ // old us-level timestamps ++ ++ break; ++ ++ case 1: ++ cnt = shm->count; ++ ++ tvr.tv_sec = shm->receiveTimeStampSec; ++ tvr.tv_nsec = shm->receiveTimeStampUSec * 1000; ++ rns_new = shm->receiveTimeStampNSec; ++ tvt.tv_sec = shm->clockTimeStampSec; ++ tvt.tv_nsec = shm->clockTimeStampUSec * 1000; ++ cns_new = shm->clockTimeStampNSec; ++ ok = (cnt == shm->count); ++ ++ /* Since these comparisons are between unsigned ++ ** variables they are always well defined, and any ++ ** (signed) underflow will turn into very large ++ ** unsigned values, well above the 1000 cutoff ++ */ ++ if ( ((cns_new - (unsigned)tvt.tv_nsec) < 1000) ++ && ((rns_new - (unsigned)tvr.tv_nsec) < 1000)) { ++ tvt.tv_nsec = cns_new; ++ tvr.tv_nsec = rns_new; ++ } ++ // At this point tvr and tvt contains valid ns-level ++ // timestamps, possibly generated by extending the ++ // old us-level timestamps ++ ++ break; ++ + default: + msyslog (LOG_ERR, "SHM: bad mode found in shared memory: %d",shm->mode); + } +@@ -352,8 +391,8 @@ int shm_peek( + if (ok) { + time_t help; /* XXX NetBSD has incompatible tv_sec */ + +- TVTOTS(&tvr,&pp->lastrec); +- pp->lastrec.l_ui += JAN_1970; ++ pp->lastrec.l_ui = (u_long)tvr.tv_sec + JAN_1970; ++ pp->lastrec.l_uf = tvr.tv_nsec * 4.294967296; + /* pp->lasttime = current_time; */ + pp->polls++; + help = tvt.tv_sec; +@@ -362,7 +401,7 @@ int shm_peek( + pp->hour=t->tm_hour; + pp->minute=t->tm_min; + pp->second=t->tm_sec; +- pp->nsec=tvt.tv_usec * 1000; ++ pp->nsec = tvt.tv_nsec; + peer->precision=shm->precision; + pp->leap=shm->leap; + } diff --git a/SOURCES/ntp-4.2.6p5-noservres.patch b/SOURCES/ntp-4.2.6p5-noservres.patch new file mode 100644 index 0000000..1f579ce --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-noservres.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/libntp/decodenetnum.c.noservres ntp-4.2.6p5/libntp/decodenetnum.c +--- ntp-4.2.6p5/libntp/decodenetnum.c.noservres 2011-08-04 06:13:43.000000000 +0200 ++++ ntp-4.2.6p5/libntp/decodenetnum.c 2013-03-28 18:38:49.239727130 +0100 +@@ -70,7 +70,7 @@ decodenetnum( + } + ZERO(hints); + hints.ai_flags = Z_AI_NUMERICHOST; +- err = getaddrinfo(cp, "ntp", &hints, &ai); ++ err = getaddrinfo(cp, NULL, &hints, &ai); + if (err != 0) + return 0; + NTP_INSIST(ai->ai_addrlen <= sizeof(*netnum)); diff --git a/SOURCES/ntp-4.2.6p5-pwcipher.patch b/SOURCES/ntp-4.2.6p5-pwcipher.patch new file mode 100644 index 0000000..683fbc2 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-pwcipher.patch @@ -0,0 +1,258 @@ +diff -up ntp-4.2.6p5/html/keygen.html.pwcipher ntp-4.2.6p5/html/keygen.html +--- ntp-4.2.6p5/html/keygen.html.pwcipher 2012-11-23 13:57:26.178868018 +0100 ++++ ntp-4.2.6p5/html/keygen.html 2012-11-23 14:44:50.952850361 +0100 +@@ -44,8 +44,8 @@ +

Synopsis

+ +

ntp-keygen [ -deGHIMPT ] [ -b modulus ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA +- | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ +- -i group ] ++ | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] ++ [ -C cipher ] [ -i group ] + [ -m modulus ] [ -p passwd2 ] [ -q passwd1 ] [ -S + [ RSA | DSA ] ] [ -s host ] [ -V nkeys ]

+ +@@ -148,6 +148,9 @@ + compatibility with FIPS 140-2 is required, either the DSA-SHA or DSA-SHA1 scheme + must be used. + ++
-C cipher ++
Select the cipher which is used to encrypt the files containing private keys. The default is three-key triple DES in CBC mode, equivalent to "-C des-ede3-cbc". The openssl tool lists ciphers available in "openssl -h" output.
++ +
-d
+
Enable debugging. This option displays the cryptographic data produced for eye-friendly billboards.
+ +@@ -215,7 +218,7 @@ + +

All files begin with two nonencrypted lines. The first line contains the file name in the format ntpkey_key_host.fstamp. The second line contains the datestamp in conventional Unix date format. Lines beginning with # are ignored.

+ +-

The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the DES-CBC algorithm and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.

++

The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the cipher selected with -C and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.

+ +

The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following the header the keys are entered one per line in the format

+ +@@ -237,4 +240,4 @@ + + + +- +\ No newline at end of file ++ +diff -up ntp-4.2.6p5/util/ntp-keygen-opts.def.pwcipher ntp-4.2.6p5/util/ntp-keygen-opts.def +--- ntp-4.2.6p5/util/ntp-keygen-opts.def.pwcipher 2009-12-09 08:36:35.000000000 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen-opts.def 2012-11-23 13:57:26.211868051 +0100 +@@ -34,6 +34,21 @@ flag = { + _EndOfDoc_; + }; + ++flag = { ++ value = C; ++ name = cipher; ++ arg-type = string; ++ arg-name = cipher; ++ ifdef = OPENSSL; ++ descrip = "privatekey cipher"; ++ doc = <<- _EndOfDoc_ ++ Select the cipher which is used to encrypt the files containing ++ private keys. The default is three-key triple DES in CBC mode, ++ equivalent to "-C des-ede3-cbc". The openssl tool lists ciphers ++ available in "openssl -h" output. ++ _EndOfDoc_; ++}; ++ + #include debug-opt.def + + flag = { +@@ -134,7 +149,7 @@ flag = { + descrip = "output private password"; + doc = <<- _EndOfDoc_ + Encrypt generated files containing private data with the specified +- password and the DES-CBC algorithm. ++ password and the cipher selected with -C/--cipher. + _EndOfDoc_; + }; + +diff -up ntp-4.2.6p5/util/ntp-keygen.c.pwcipher ntp-4.2.6p5/util/ntp-keygen.c +--- ntp-4.2.6p5/util/ntp-keygen.c.pwcipher 2012-11-23 13:57:26.202868041 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen.c 2012-11-23 13:57:26.212868052 +0100 +@@ -169,6 +169,7 @@ char *passwd1 = NULL; /* input private k + char *passwd2 = NULL; /* output private key password */ + #ifdef OPENSSL + long d0, d1, d2, d3; /* callback counters */ ++const EVP_CIPHER * cipher = NULL; + #endif /* OPENSSL */ + + #ifdef SYS_WINNT +@@ -236,6 +237,7 @@ main( + const EVP_MD *ectx; /* EVP digest */ + char pathbuf[MAXFILENAME + 1]; + const char *scheme = NULL; /* digest/signature scheme */ ++ const char *ciphername = NULL; /* to encrypt priv. key */ + char *exten = NULL; /* private extension */ + char *grpkey = NULL; /* identity extension */ + int nid; /* X509 digest/signature scheme */ +@@ -322,6 +324,9 @@ main( + if (HAVE_OPT( CERTIFICATE )) + scheme = OPT_ARG( CERTIFICATE ); + ++ if (HAVE_OPT( CIPHER )) ++ ciphername = OPT_ARG( CIPHER ); ++ + if (HAVE_OPT( SUBJECT_NAME )) + hostname = strdup(OPT_ARG( SUBJECT_NAME )); + +@@ -418,6 +423,13 @@ main( + } + if (scheme == NULL) + scheme = "RSA-MD5"; ++ if (ciphername == NULL) ++ ciphername = "des-ede3-cbc"; ++ cipher = EVP_get_cipherbyname(ciphername); ++ if (cipher == NULL) { ++ fprintf(stderr, "Unknown cipher %s\n", ciphername); ++ exit(-1); ++ } + if (groupname == NULL) + groupname = hostname; + fprintf(stderr, "Using host %s group %s\n", hostname, +@@ -520,9 +532,9 @@ main( + BN_copy(rsa->q, BN_value_one()); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_RSA(pkey, rsa); +- PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, +- NULL); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0, ++ NULL, NULL); ++ fflush(stdout); + if (debug) + RSA_print_fp(stderr, rsa, 0); + } +@@ -542,9 +554,9 @@ main( + rsa = pkey_gqkey->pkey.rsa; + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_RSA(pkey, rsa); +- PEM_write_PrivateKey(stdout, pkey, +- EVP_des_cbc(), NULL, 0, NULL, passwd2); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0, ++ NULL, passwd2); ++ fflush(stdout); + if (debug) + RSA_print_fp(stderr, rsa, 0); + } +@@ -584,9 +596,9 @@ main( + BN_copy(dsa->priv_key, BN_value_one()); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey, dsa); +- PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, +- NULL); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0, ++ NULL, NULL); ++ fflush(stdout); + if (debug) + DSA_print_fp(stderr, dsa, 0); + } +@@ -607,9 +619,9 @@ main( + dsa = pkey_iffkey->pkey.dsa; + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey, dsa); +- PEM_write_PrivateKey(stdout, pkey, EVP_des_cbc(), NULL, +- 0, NULL, passwd2); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0, ++ NULL, passwd2); ++ fflush(stdout); + if (debug) + DSA_print_fp(stderr, dsa, 0); + } +@@ -645,9 +657,9 @@ main( + fprintf(stdout, "# %s\n# %s\n", filename, + ctime(&epoch)); + pkey = pkey_mvpar[2]; +- PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, +- NULL); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0, ++ NULL, NULL); ++ fflush(stdout); + if (debug) + DSA_print_fp(stderr, pkey->pkey.dsa, 0); + } +@@ -664,9 +676,9 @@ main( + fprintf(stdout, "# %s\n# %s\n", filename, + ctime(&epoch)); + pkey = pkey_mvpar[1]; +- PEM_write_PrivateKey(stdout, pkey, EVP_des_cbc(), NULL, +- 0, NULL, passwd2); +- fclose(stdout); ++ PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0, ++ NULL, passwd2); ++ fflush(stdout); + if (debug) + DSA_print_fp(stderr, pkey->pkey.dsa, 0); + } +@@ -886,7 +898,7 @@ gen_rsa( + str = fheader("RSAhost", id, hostname); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_RSA(pkey, rsa); +- PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL, + passwd1); + fclose(str); + if (debug) +@@ -941,7 +953,7 @@ gen_dsa( + str = fheader("DSAsign", id, hostname); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey, dsa); +- PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL, + passwd1); + fclose(str); + if (debug) +@@ -1108,7 +1120,7 @@ gen_iffkey( + str = fheader("IFFkey", id, groupname); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey, dsa); +- PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL, + passwd1); + fclose(str); + if (debug) +@@ -1305,7 +1317,7 @@ gen_gqkey( + str = fheader("GQkey", id, groupname); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_RSA(pkey, rsa); +- PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL, + passwd1); + fclose(str); + if (debug) +@@ -1710,7 +1722,7 @@ gen_mvkey( + BN_copy(dsa->pub_key, b); + pkey = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey, dsa); +- PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL, + passwd1); + evpars[i++] = pkey; + if (debug) +@@ -1736,7 +1748,7 @@ gen_mvkey( + dsa2->pub_key = BN_dup(ghat); + pkey1 = EVP_PKEY_new(); + EVP_PKEY_assign_DSA(pkey1, dsa2); +- PEM_write_PrivateKey(str, pkey1, EVP_des_cbc(), NULL, 0, NULL, ++ PEM_write_PKCS8PrivateKey(str, pkey1, cipher, NULL, 0, NULL, + passwd1); + evpars[i++] = pkey1; + if (debug) +@@ -1762,7 +1774,7 @@ gen_mvkey( + sdsa->pub_key = BN_dup(xhat[j]); + pkey1 = EVP_PKEY_new(); + EVP_PKEY_set1_DSA(pkey1, sdsa); +- PEM_write_PrivateKey(str, pkey1, EVP_des_cbc(), NULL, 0, ++ PEM_write_PKCS8PrivateKey(str, pkey1, cipher, NULL, 0, + NULL, passwd1); + evpars[i++] = pkey1; + if (debug) diff --git a/SOURCES/ntp-4.2.6p5-rawstats.patch b/SOURCES/ntp-4.2.6p5-rawstats.patch new file mode 100644 index 0000000..3e6fe67 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-rawstats.patch @@ -0,0 +1,142 @@ +commit 63b405a67040ad6545abb102bf0714ccb5a50558 +Author: +Date: Thu Dec 27 20:09:00 2012 -0500 + + ntp_util.c, ntpd.h, ChangeLog, ntp_proto.c: + Fix for bug 2081 + +diff -up ntp-4.2.6p5/include/ntpd.h.rawstats ntp-4.2.6p5/include/ntpd.h +--- ntp-4.2.6p5/include/ntpd.h.rawstats 2015-07-22 14:19:37.220167860 +0200 ++++ ntp-4.2.6p5/include/ntpd.h 2015-07-22 14:20:52.819392212 +0200 +@@ -244,7 +244,7 @@ extern void record_peer_stats (sockaddr_ + extern void record_proto_stats (char *); + extern void record_loop_stats (double, double, double, double, int); + extern void record_clock_stats (sockaddr_u *, const char *); +-extern void record_raw_stats (sockaddr_u *, sockaddr_u *, l_fp *, l_fp *, l_fp *, l_fp *); ++extern void record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int poll, int precision, double root_delay, double root_dispersion, u_int32 refid); + extern u_long leap_month(u_long); + extern void record_crypto_stats (sockaddr_u *, const char *); + #ifdef DEBUG +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rawstats ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.rawstats 2015-07-22 14:19:37.218167854 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-07-22 14:19:37.221167862 +0200 +@@ -1341,7 +1341,7 @@ process_packet( + double t34, t21; + double p_offset, p_del, p_disp; + l_fp p_rec, p_xmt, p_org, p_reftime, ci; +- u_char pmode, pleap, pstratum; ++ u_char pmode, pleap, pversion, pstratum; + char statstr[NTP_MAXSTRLEN]; + #ifdef ASSYM + int itemp; +@@ -1359,14 +1359,17 @@ process_packet( + NTOHL_FP(&pkt->xmt, &p_xmt); + pmode = PKT_MODE(pkt->li_vn_mode); + pleap = PKT_LEAP(pkt->li_vn_mode); ++ pversion = PKT_VERSION(pkt->li_vn_mode); + pstratum = PKT_TO_STRATUM(pkt->stratum); + + /* + * Capture the header values in the client/peer association.. + */ + record_raw_stats(&peer->srcadr, peer->dstadr ? +- &peer->dstadr->sin : NULL, &p_org, &p_rec, &p_xmt, +- &peer->dst); ++ &peer->dstadr->sin : NULL, ++ &p_org, &p_rec, &p_xmt, &peer->dst, ++ pleap, pversion, pmode, pstratum, pkt->ppoll, pkt->precision, ++ p_del, p_disp, pkt->refid); + peer->leap = pleap; + peer->stratum = min(pstratum, STRATUM_UNSPEC); + peer->pmode = pmode; +diff -up ntp-4.2.6p5/ntpd/ntp_util.c.rawstats ntp-4.2.6p5/ntpd/ntp_util.c +--- ntp-4.2.6p5/ntpd/ntp_util.c.rawstats 2010-10-22 09:37:31.000000000 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_util.c 2015-07-22 14:19:37.221167862 +0200 +@@ -707,7 +707,16 @@ record_raw_stats( + l_fp *t1, /* originate timestamp */ + l_fp *t2, /* receive timestamp */ + l_fp *t3, /* transmit timestamp */ +- l_fp *t4 /* destination timestamp */ ++ l_fp *t4, /* destination timestamp */ ++ int leap, ++ int version, ++ int mode, ++ int stratum, ++ int poll, ++ int precision, ++ double root_delay, /* seconds */ ++ double root_dispersion,/* seconds */ ++ u_int32 refid + ) + { + l_fp now; +@@ -721,10 +730,13 @@ record_raw_stats( + day = now.l_ui / 86400 + MJD_1900; + now.l_ui %= 86400; + if (rawstats.fp != NULL) { +- fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s\n", day, +- ulfptoa(&now, 3), stoa(srcadr), dstadr ? +- stoa(dstadr) : "-", ulfptoa(t1, 9), ulfptoa(t2, 9), +- ulfptoa(t3, 9), ulfptoa(t4, 9)); ++ fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s\n", ++ day, ulfptoa(&now, 3), ++ stoa(srcadr), dstadr ? stoa(dstadr) : "-", ++ ulfptoa(t1, 9), ulfptoa(t2, 9), ++ ulfptoa(t3, 9), ulfptoa(t4, 9), ++ leap, version, mode, stratum, poll, precision, ++ root_delay, root_dispersion, refid_str(refid, stratum)); + fflush(rawstats.fp); + } + } + +commit f626c563dbf6c00c40f9d12e8200b427759ed0bf +Author: +Date: Sat Dec 25 06:12:51 2010 +0000 + + Add ntpq sysinfo command, similar to ntpdc's sysinfo. + +diff --git a/libntp/numtoa.c b/libntp/numtoa.c +index 36a7c58..0fbbab7 100644 +--- a/libntp/numtoa.c ++++ b/libntp/numtoa.c +@@ -31,3 +31,29 @@ numtoa( + (u_long)netnum & 0xff); + return buf; + } ++ ++ ++/* Convert a refid & stratum to a string */ ++const char * ++refid_str( ++ u_int32 refid, ++ int stratum ++ ) ++{ ++ char * text; ++ size_t tlen; ++ ++ if (stratum > 1) ++ return numtoa(refid); ++ ++ LIB_GETBUF(text); ++ text[0] = '.'; ++ strncpy(&text[1], (void *)&refid, sizeof(refid)); ++ text[1 + sizeof(refid)] = '\0'; ++ tlen = strlen(text); ++ text[tlen] = '.'; ++ text[tlen + 1] = '\0'; ++ ++ return text; ++} ++ +diff -up ntp-4.2.6p5/include/ntp_stdlib.h.rawstats ntp-4.2.6p5/include/ntp_stdlib.h +--- ntp-4.2.6p5/include/ntp_stdlib.h.rawstats 2015-07-22 15:13:16.870503486 +0200 ++++ ntp-4.2.6p5/include/ntp_stdlib.h 2015-07-22 15:14:21.893714802 +0200 +@@ -134,6 +134,7 @@ extern char * socktohost (const sockaddr + extern int octtoint (const char *, u_long *); + extern u_long ranp2 (int); + extern char * refnumtoa (sockaddr_u *); ++extern const char *refid_str (u_int32, int); + extern int tsftomsu (u_long, int); + extern char * uinttoa (u_long); + diff --git a/SOURCES/ntp-4.2.6p5-refreshroute.patch b/SOURCES/ntp-4.2.6p5-refreshroute.patch new file mode 100644 index 0000000..d8737e2 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-refreshroute.patch @@ -0,0 +1,111 @@ +Backported from ntp-dev-4.2.7p399 + +diff -up ntp-4.2.6p5/ntpd/ntp_io.c.refreshroute ntp-4.2.6p5/ntpd/ntp_io.c +--- ntp-4.2.6p5/ntpd/ntp_io.c.refreshroute 2013-10-17 13:48:34.808727175 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_io.c 2013-12-09 14:02:28.076249785 +0100 +@@ -1785,7 +1785,6 @@ update_interfaces( + isc_result_t result; + isc_interface_t isc_if; + int new_interface_found; +- int refresh_peers; + unsigned int family; + endpt enumep; + endpt * ep; +@@ -1800,7 +1799,6 @@ update_interfaces( + */ + + new_interface_found = FALSE; +- refresh_peers = FALSE; + iter = NULL; + result = isc_interfaceiter_create(mctx, &iter); + +@@ -1836,6 +1834,8 @@ update_interfaces( + + convert_isc_if(&isc_if, &enumep, port); + ++ DPRINT_INTERFACE(4, (&enumep, "examining ", "\n")); ++ + /* + * Check if and how we are going to use the interface. + */ +@@ -1843,19 +1843,23 @@ update_interfaces( + enumep.flags)) { + + case ACTION_IGNORE: ++ DPRINTF(4, ("ignoring interface %s (%s) - by nic rules\n", ++ enumep.name, stoa(&enumep.sin))); + continue; + + case ACTION_LISTEN: ++ DPRINTF(4, ("listen interface %s (%s) - by nic rules\n", ++ enumep.name, stoa(&enumep.sin))); + enumep.ignore_packets = ISC_FALSE; + break; + + case ACTION_DROP: ++ DPRINTF(4, ("drop on interface %s (%s) - by nic rules\n", ++ enumep.name, stoa(&enumep.sin))); + enumep.ignore_packets = ISC_TRUE; + break; + } + +- DPRINT_INTERFACE(4, (&enumep, "examining ", "\n")); +- + /* interfaces must be UP to be usable */ + if (!(enumep.flags & INT_UP)) { + DPRINTF(4, ("skipping interface %s (%s) - DOWN\n", +@@ -1898,15 +1902,8 @@ update_interfaces( + */ + strncpy(ep->name, enumep.name, + sizeof(ep->name)); +- if (ep->ignore_packets != +- enumep.ignore_packets) { +- ep->ignore_packets = ++ ep->ignore_packets = + enumep.ignore_packets; +- refresh_peers = TRUE; +- DPRINTF(4, ("refreshing peers due to %s ignore_packets change to %d\n", +- stoa(&ep->sin), +- ep->ignore_packets)); +- } + } else { + /* name collision - rename interface */ + strncpy(ep->name, "*multiple*", +@@ -1971,9 +1968,6 @@ update_interfaces( + (*receiver)(data, &ifi); + + new_interface_found = TRUE; +- refresh_peers = TRUE; +- DPRINTF(4, ("refreshing peers due to new addr %s\n", +- stoa(&ep->sin))); + DPRINT_INTERFACE(3, + (ep, "updating ", + " new - created\n")); +@@ -2013,9 +2007,6 @@ update_interfaces( + DPRINT_INTERFACE(3, (ep, "updating ", + "GONE - deleting\n")); + remove_interface(ep); +- refresh_peers = TRUE; +- DPRINTF(4, ("refreshing peers due to deleted addr %s", +- stoa(&ep->sin))); + + ifi.action = IFS_DELETED; + ifi.ep = ep; +@@ -2037,12 +2028,12 @@ update_interfaces( + } + + /* +- * phase 3 - re-configure as the world has changed if necessary ++ * phase 3 - re-configure as the world has possibly changed ++ * ++ * never ever make this conditional again - it is needed to track ++ * routing updates. see bug #2506 + */ +- if (refresh_peers) { +- refresh_all_peerinterfaces(); +- msyslog(LOG_INFO, "peers refreshed"); +- } ++ refresh_all_peerinterfaces(); + + if (sys_bclient) + io_setbclient(); diff --git a/SOURCES/ntp-4.2.6p5-restrict46.patch b/SOURCES/ntp-4.2.6p5-restrict46.patch new file mode 100644 index 0000000..7add549 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-restrict46.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.restrict46 ntp-4.2.6p5/ntpd/ntp_parser.y +--- ntp-4.2.6p5/ntpd/ntp_parser.y.restrict46 2015-12-03 18:14:32.378326330 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_parser.y 2015-12-03 18:21:08.369300132 +0100 +@@ -734,7 +734,7 @@ access_control_command + $4, + ip_file->line_no)); + } +- | T_Restrict ip_address T_Mask ip_address ac_flag_list ++ | T_Restrict address T_Mask ip_address ac_flag_list + { + enqueue(cfgt.restrict_opts, + create_restrict_node($2, $4, $5, ip_file->line_no)); diff --git a/SOURCES/ntp-4.2.6p5-rootdisp.patch b/SOURCES/ntp-4.2.6p5-rootdisp.patch new file mode 100644 index 0000000..9d90359 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-rootdisp.patch @@ -0,0 +1,84 @@ +Backported from ntp-dev-4.2.7p385 + +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp 2013-12-09 15:02:58.394459288 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2013-12-09 15:10:05.770954848 +0100 +@@ -1667,10 +1667,34 @@ clock_update( + sys_refid = peer->refid; + else + sys_refid = addr2refid(&peer->srcadr); +- dtemp = sys_jitter + fabs(sys_offset) + peer->disp + +- (peer->delay + peer->rootdelay) / 2 + clock_phi * +- (current_time - peer->update); +- sys_rootdisp = dtemp + peer->rootdisp; ++ /* ++ * Root Dispersion (E) is defined (in RFC 5905) as: ++ * ++ * E = p.epsilon_r + p.epsilon + p.psi + PHI*(s.t - p.t) + |THETA| ++ * ++ * where: ++ * p.epsilon_r is the PollProc's root dispersion ++ * p.epsilon is the PollProc's dispersion ++ * p.psi is the PollProc's jitter ++ * THETA is the combined offset ++ * ++ * NB: Think Hard about where these numbers come from and ++ * what they mean. When did peer->update happen? Has anything ++ * interesting happened since then? What values are the most ++ * defensible? Why? ++ * ++ * DLM thinks this equation is probably the best of all worse choices. ++ */ ++ dtemp = peer->rootdisp ++ + peer->disp ++ + sys_jitter ++ + clock_phi * (current_time - peer->update) ++ + fabs(sys_offset); ++ ++ if (dtemp > sys_mindisp) ++ sys_rootdisp = dtemp; ++ else ++ sys_rootdisp = sys_mindisp; + sys_rootdelay = peer->delay + peer->rootdelay; + sys_reftime = peer->dst; + +@@ -2810,15 +2834,36 @@ root_distance( + double dtemp; + + /* ++ * Root Distance (LAMBDA) is defined as: ++ * (delta + DELTA)/2 + epsilon + EPSILON + phi ++ * ++ * where: ++ * delta is the round-trip delay ++ * DELTA is the root delay ++ * epsilon is the remote server precision + local precision ++ * + (15 usec each second) ++ * EPSILON is the root dispersion ++ * phi is the peer jitter statistic ++ * ++ * NB: Think hard about why we are using these values, and what ++ * the alternatives are, and the various pros/cons. ++ * ++ * DLM thinks these are probably the best choices from any of the ++ * other worse choices. ++ */ ++ dtemp = (peer->delay + peer->rootdelay) / 2 ++ + LOGTOD(peer->precision) ++ + LOGTOD(sys_precision) ++ + clock_phi * (current_time - peer->update) ++ + peer->rootdisp ++ + peer->jitter; ++ /* + * Careful squeak here. The value returned must be greater than + * the minimum root dispersion in order to avoid clockhop with + * highly precise reference clocks. Note that the root distance + * cannot exceed the sys_maxdist, as this is the cutoff by the + * selection algorithm. + */ +- dtemp = (peer->delay + peer->rootdelay) / 2 + peer->disp + +- peer->rootdisp + clock_phi * (current_time - peer->update) + +- peer->jitter; + if (dtemp < sys_mindisp) + dtemp = sys_mindisp; + return (dtemp); diff --git a/SOURCES/ntp-4.2.6p5-rsaexp.patch b/SOURCES/ntp-4.2.6p5-rsaexp.patch new file mode 100644 index 0000000..4930ded --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-rsaexp.patch @@ -0,0 +1,21 @@ +diff -up ntp-4.2.6p5/util/ntp-keygen.c.rsaexp ntp-4.2.6p5/util/ntp-keygen.c +--- ntp-4.2.6p5/util/ntp-keygen.c.rsaexp 2015-02-09 12:18:06.627127473 +0100 ++++ ntp-4.2.6p5/util/ntp-keygen.c 2015-02-09 12:28:15.263780280 +0100 +@@ -882,7 +882,7 @@ gen_rsa( + FILE *str; + + fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus); +- rsa = RSA_generate_key(modulus, 3, cb, "RSA"); ++ rsa = RSA_generate_key(modulus, 65537, cb, "RSA"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", +@@ -1223,7 +1223,7 @@ gen_gqkey( + fprintf(stderr, + "Generating GQ parameters (%d bits)...\n", + modulus2); +- rsa = RSA_generate_key(modulus2, 3, cb, "GQ"); ++ rsa = RSA_generate_key(modulus2, 65537, cb, "GQ"); + fprintf(stderr, "\n"); + if (rsa == NULL) { + fprintf(stderr, "RSA generate keys fails\n%s\n", diff --git a/SOURCES/ntp-4.2.6p5-shmperm.patch b/SOURCES/ntp-4.2.6p5-shmperm.patch new file mode 100644 index 0000000..35638eb --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-shmperm.patch @@ -0,0 +1,191 @@ +diff -up ntp-4.2.6p5/html/drivers/driver28.html.shmperm ntp-4.2.6p5/html/drivers/driver28.html +--- ntp-4.2.6p5/html/drivers/driver28.html.shmperm 2009-12-09 08:36:37.000000000 +0100 ++++ ntp-4.2.6p5/html/drivers/driver28.html 2015-02-09 15:57:57.450877311 +0100 +@@ -18,7 +18,8 @@ + Driver ID: SHM

+ +

Description

+-

This driver receives its reference clock info from a shared memory-segment. The shared memory-segment is created with owner-only access for unit 0 and 1, and world access for unit 2 and 3

++

This driver receives its reference clock info from a shared memory-segment. The shared memory-segment is created with owner-only access for unit 0 and 1, and world access for other units unless the mode word is set for owner-only access.

++ + +

Structure of shared memory-segment

+
struct shmTime {
+@@ -94,6 +95,40 @@ Here is a sample showing the GPS recepti
+ 54364 85700.160 127.127.28.0  65   0  65   0   0
+ 
+ ++

The 'mode' word

++ ++

++ Some aspects of the driver behavior can be adjusted by setting bits of ++ the 'mode' word in the server configuration line:
++   server 127.127.28.x mode Y ++

++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
mode word bits and bit groups
BitDecHexMeaning
011The SHM segment is private (mode 0600). This is the fixed ++ default for clock units 0 and 1; clock units >1 are mode ++ 0666 unless this bit is set for the specific unit.
1-31--reserved -- do not use
++ +

Fudge Factors

+
+
time1 time +@@ -112,9 +147,64 @@ Here is a sample showing the GPS recepti +
Not used by this driver. +
flag4 0 | 1 +
If flag4 is set, clockstats records will be written when the driver is polled. +-

Additional Information

+-

Reference Clock Drivers

+
++ ++

Public vs. Private SHM segments

++ ++

The driver attempts to create a shared memory segment with an ++ identifier depending on the unit number. This identifier (which can be ++ a numeric value or a string) clearly depends on the method used, which ++ in turn depends on the host operating system:

++ ++
    ++
  • ++ Windows uses a file mapping to the page file with the ++ name 'Global\NTPu' for public accessible ++ mappings, where u is the clock unit. Private / ++ non-public mappings are created as ++ 'Local\NTPu'. ++

    ++ Public access assigns a NULL DACL to the memory mapping, while ++ private access just uses the default DACL of the process creating ++ the mapping. ++

    ++
  • ++
  • ++ SYSV IPC creates a shared memory segment with a key value ++ of 0x4E545030 + u, where u is again ++ the clock unit. (This value could be hex-decoded as 'NTP0', ++ 'NTP1',..., with funny characters for units > 9.) ++

    ++ Public access means a permission set of 0666, while private access ++ creates the mapping with a permission set of 0600. ++

    ++
  • ++
++ ++

There's no support for POSIX shared memory yet.

++ ++

NTPD is started as root on most POSIX-like operating systems ++ and uses the setuid/setgid system API to run under reduced rights once ++ the initial setup of the process is done. One consequence out of this ++ is that the allocation of SHM segments must be done early during the ++ clock setup. The actual polling of the clock is done as the run-time ++ user; deferring the creation of the SHM segment to this point will ++ create a SHM segment owned by the runtime-user account. The internal ++ structure of NTPD does not permit the use of a fudge flag if ++ this is to be avoided; this is the reason why a mode bit is used for ++ the configuration of a public segment. ++

++ ++

When running under Windows, the chosen user account must be able to ++ create a SHM segment in the global object name space for SHM clocks with ++ public access. Otherwise the session isolation used by Windows kernels ++ after WinXP will get into the way if the client program does not run in ++ the same session. ++

++ ++

Additional Information

++

Reference Clock Drivers

++ +
+ + +diff -up ntp-4.2.6p5/ntpd/refclock_shm.c.shmperm ntp-4.2.6p5/ntpd/refclock_shm.c +--- ntp-4.2.6p5/ntpd/refclock_shm.c.shmperm 2015-02-09 15:52:06.131877933 +0100 ++++ ntp-4.2.6p5/ntpd/refclock_shm.c 2015-02-09 15:52:06.137877933 +0100 +@@ -52,6 +52,11 @@ + #define NSAMPLES 3 /* stages of median filter */ + + /* ++ * Mode flags ++ */ ++#define SHM_MODE_PRIVATE 0x0001 ++ ++/* + * Function prototypes + */ + static int shm_start (int unit, struct peer *peer); +@@ -99,6 +104,7 @@ struct shmTime { + + struct shmunit { + struct shmTime *shm; /* pointer to shared memory segment */ ++ int forall; /* access for all UIDs? */ + + /* debugging/monitoring counters - reset when printed */ + int ticks; /* number of attempts to read data*/ +@@ -109,9 +115,12 @@ struct shmunit { + }; + + +-struct shmTime *getShmTime(int); +- +-struct shmTime *getShmTime (int unit) { ++static struct shmTime* ++getShmTime( ++ int unit, ++ int/*BOOL*/ forall ++ ) ++{ + #ifndef SYS_WINNT + int shmid=0; + +@@ -119,8 +128,8 @@ struct shmTime *getShmTime (int unit) { + * Big units will give non-ascii but that's OK + * as long as everybody does it the same way. + */ +- shmid=shmget (0x4e545030+unit, sizeof (struct shmTime), +- IPC_CREAT|(unit<2?0600:0666)); ++ shmid=shmget(0x4e545030 + unit, sizeof (struct shmTime), ++ IPC_CREAT | (forall ? 0666 : 0600)); + if (shmid==-1) { /*error */ + msyslog(LOG_ERR,"SHM shmget (unit %d): %s",unit,strerror(errno)); + return 0; +@@ -199,7 +208,9 @@ shm_start( + memset(up, 0, sizeof(*up)); + pp->unitptr = (caddr_t)up; + +- up->shm = getShmTime(unit); ++ up->forall = (unit >= 2) && !(peer->ttl & SHM_MODE_PRIVATE); ++ ++ up->shm = getShmTime(unit, up->forall); + + /* + * Initialize miscellaneous peer variables +@@ -314,7 +325,7 @@ int shm_peek( + if (up->shm == 0) { + /* try to map again - this may succeed if meanwhile some- + body has ipcrm'ed the old (unaccessible) shared mem segment */ +- up->shm = getShmTime(unit); ++ up->shm = getShmTime(unit, up->forall); + } + shm = up->shm; + if (shm == 0) { diff --git a/SOURCES/ntp-4.2.6p5-sourceport.patch b/SOURCES/ntp-4.2.6p5-sourceport.patch new file mode 100644 index 0000000..ef3fb10 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-sourceport.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.sourceport ntp-4.2.6p5/ntpd/ntp_proto.c +--- ntp-4.2.6p5/ntpd/ntp_proto.c.sourceport 2015-02-06 16:43:27.857879763 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_proto.c 2015-02-06 16:43:56.446879712 +0100 +@@ -334,7 +334,7 @@ receive( + * reveals a clogging attack. + */ + sys_received++; +- if (SRCPORT(&rbufp->recv_srcadr) < NTP_PORT) { ++ if (SRCPORT(&rbufp->recv_srcadr) == 0) { + sys_badlength++; + return; /* bogus port */ + } diff --git a/SOURCES/ntp-4.2.6p5-staunsync.patch b/SOURCES/ntp-4.2.6p5-staunsync.patch new file mode 100644 index 0000000..8a8e279 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-staunsync.patch @@ -0,0 +1,16 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.staunsync ntp-4.2.6p5/ntpd/ntp_loopfilter.c +--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.staunsync 2017-09-20 10:38:35.776437535 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c 2017-09-20 10:40:47.240562306 +0200 +@@ -935,9 +935,9 @@ loop_config( + pll_control = 1; + memset(&ntv, 0, sizeof(ntv)); + ntv.modes = MOD_BITS; +- ntv.status = STA_PLL; +- ntv.maxerror = MAXDISPERSE; +- ntv.esterror = MAXDISPERSE; ++ ntv.status = STA_PLL | STA_UNSYNC; ++ ntv.maxerror = MAXDISPERSE * 1e6; ++ ntv.esterror = MAXDISPERSE * 1e6; + ntv.constant = sys_poll; + #ifdef SIGSYS + /* diff --git a/SOURCES/ntp-4.2.6p5-tsyncdriver.patch b/SOURCES/ntp-4.2.6p5-tsyncdriver.patch new file mode 100644 index 0000000..0a225cc --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-tsyncdriver.patch @@ -0,0 +1,1091 @@ +diff -up ntp-4.2.6p5/config.h.in.tsyncdriver ntp-4.2.6p5/config.h.in +--- ntp-4.2.6p5/config.h.in.tsyncdriver 2011-12-25 00:32:51.000000000 +0100 ++++ ntp-4.2.6p5/config.h.in 2017-09-19 11:01:08.267218957 +0200 +@@ -159,6 +159,9 @@ + /* Zyfer GPStarplus */ + #undef CLOCK_ZYFER + ++/* Spectracom TSYNC PCI */ ++#undef CLOCK_TSYNCPCI ++ + /* Enable ntpd debugging code? */ + #undef DEBUG + +diff -up ntp-4.2.6p5/configure.tsyncdriver ntp-4.2.6p5/configure +--- ntp-4.2.6p5/configure.tsyncdriver 2011-12-25 00:31:17.000000000 +0100 ++++ ntp-4.2.6p5/configure 2017-09-19 11:01:08.334221167 +0200 +@@ -22827,6 +22827,7 @@ esac + $as_echo "$ans" >&6; } + + ++$as_echo "#define CLOCK_TSYNCPCI 1" >>confdefs.h + + + +diff -up ntp-4.2.6p5/html/drivers/driver45.html.tsyncdriver ntp-4.2.6p5/html/drivers/driver45.html +--- ntp-4.2.6p5/html/drivers/driver45.html.tsyncdriver 2017-09-19 11:01:08.269219023 +0200 ++++ ntp-4.2.6p5/html/drivers/driver45.html 2017-09-19 11:01:08.269219023 +0200 +@@ -0,0 +1,32 @@ ++ ++ ++ ++ ++ ++ ++ Spectracom TSYNC PCI ++ ++ ++ ++ ++

Spectracom TSYNC PCI

++

Last update: ++ 26-Mar-2012 05:10 ++ UTC

++
++

Synopsis

++ Address: 127.127.45.u
++ Reference ID: one of GPS, IRIG, HVQ, FREQ, ACTS, PPS, PTP, ACT, USR, LOCL
++ Driver ID: Spectracom TSYNC PCI
++ Driver Port: /dev/tsyncpciu ++ Features: (none) ++

Description

++

This driver supports the Spectracom TSYNC PCI receiver.

++

Additional Information

++

Reference Clock Drivers

++
++ ++ ++ ++ +diff -up ntp-4.2.6p5/html/refclock.html.tsyncdriver ntp-4.2.6p5/html/refclock.html +--- ntp-4.2.6p5/html/refclock.html.tsyncdriver 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/html/refclock.html 2017-09-19 11:01:08.269219023 +0200 +@@ -82,9 +82,10 @@ +
  • Type 42 Zyfer GPStarplus Receiver
  • +
  • Type 43 RIPE NCC interface for Trimble Palisade
  • +
  • Type 44 NeoClock4X - DCF77 / TDF serial line
  • ++
  • Type 45 Spectracom TSYNC PCI
  • + +
    + + + +- +\ No newline at end of file ++ +diff -up ntp-4.2.6p5/include/ntp.h.tsyncdriver ntp-4.2.6p5/include/ntp.h +--- ntp-4.2.6p5/include/ntp.h.tsyncdriver 2017-09-19 11:01:08.246218264 +0200 ++++ ntp-4.2.6p5/include/ntp.h 2017-09-19 11:01:08.269219023 +0200 +@@ -525,7 +525,8 @@ struct peer { + #define REFCLK_ZYFER 42 /* Zyfer GPStarplus receiver */ + #define REFCLK_RIPENCC 43 /* RIPE NCC Trimble driver */ + #define REFCLK_NEOCLOCK4X 44 /* NeoClock4X DCF77 or TDF receiver */ +-#define REFCLK_MAX 44 /* NeoClock4X DCF77 or TDF receiver */ ++#define REFCLK_TSYNCPCI 45 /* Spectracom TSYNC PCI timing board */ ++#define REFCLK_MAX 45 /* Spectracom TSYNC PCI timing board */ + + + /* +diff -up ntp-4.2.6p5/libntp/clocktypes.c.tsyncdriver ntp-4.2.6p5/libntp/clocktypes.c +--- ntp-4.2.6p5/libntp/clocktypes.c.tsyncdriver 2009-12-09 08:36:37.000000000 +0100 ++++ ntp-4.2.6p5/libntp/clocktypes.c 2017-09-19 11:01:08.270219055 +0200 +@@ -100,6 +100,8 @@ struct clktype clktypes[] = { + "GPS_RIPENCC" }, + { REFCLK_NEOCLOCK4X, "NeoClock4X DCF77 / TDF receiver (44)", + "NEOCLK4X"}, ++ { REFCLK_TSYNCPCI, "Spectracom TSYNC PCI timing board (45)", ++ "PCI_TSYNC"}, + { -1, "", "" } + }; + +diff -up ntp-4.2.6p5/ntpd/Makefile.in.tsyncdriver ntp-4.2.6p5/ntpd/Makefile.in +--- ntp-4.2.6p5/ntpd/Makefile.in.tsyncdriver 2011-12-25 00:31:11.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/Makefile.in 2017-09-19 11:01:08.270219055 +0200 +@@ -97,6 +97,7 @@ am_libntpd_a_OBJECTS = ntp_control.$(OBJ + refclock_tpro.$(OBJEXT) refclock_true.$(OBJEXT) \ + refclock_tt560.$(OBJEXT) refclock_ulink.$(OBJEXT) \ + refclock_wwv.$(OBJEXT) refclock_wwvb.$(OBJEXT) \ ++ refclock_tsyncpci.$(OBJEXT) \ + refclock_zyfer.$(OBJEXT) $(am__objects_1) + libntpd_a_OBJECTS = $(am_libntpd_a_OBJECTS) + am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" \ +@@ -499,6 +500,7 @@ libntpd_a_SOURCES = \ + refclock_wwv.c \ + refclock_wwvb.c \ + refclock_zyfer.c \ ++ refclock_tsyncpci.c \ + $(NULL) + + all: $(BUILT_SOURCES) +@@ -734,6 +736,7 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_wwv.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_wwvb.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_zyfer.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_tsyncpci.Po@am__quote@ + + .c.o: + @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +diff -up ntp-4.2.6p5/ntpd/ntp_control.c.tsyncdriver ntp-4.2.6p5/ntpd/ntp_control.c +--- ntp-4.2.6p5/ntpd/ntp_control.c.tsyncdriver 2017-09-19 11:01:08.266218923 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_control.c 2017-09-19 11:01:08.270219055 +0200 +@@ -419,6 +419,7 @@ static u_char clocktypes[] = { + CTL_SST_TS_UHF, /* REFCLK_ZYFER (42) */ + CTL_SST_TS_UHF, /* REFCLK_RIPENCC (43) */ + CTL_SST_TS_UHF, /* REFCLK_NEOCLOCK4X (44) */ ++ CTL_SST_TS_UHF, /* REFCLK_TSYNCPCI (45) */ + }; + + +diff -up ntp-4.2.6p5/ntpd/refclock_conf.c.tsyncdriver ntp-4.2.6p5/ntpd/refclock_conf.c +--- ntp-4.2.6p5/ntpd/refclock_conf.c.tsyncdriver 2011-01-04 02:57:27.000000000 +0100 ++++ ntp-4.2.6p5/ntpd/refclock_conf.c 2017-09-19 11:01:08.270219055 +0200 +@@ -258,6 +258,12 @@ extern struct refclock refclock_neoclock + #define refclock_neoclock4x refclock_none + #endif + ++#ifdef CLOCK_TSYNCPCI ++extern struct refclock refclock_tsyncpci; ++#else ++#define refclock_tsyncpci refclock_none ++#endif ++ + /* + * Order is clock_start(), clock_shutdown(), clock_poll(), + * clock_control(), clock_init(), clock_buginfo, clock_flags; +@@ -309,7 +315,8 @@ struct refclock * const refclock_conf[] + &refclock_tt560, /* 41 REFCLK_TT560 */ + &refclock_zyfer, /* 42 REFCLK_ZYFER */ + &refclock_ripencc, /* 43 REFCLK_RIPENCC */ +- &refclock_neoclock4x /* 44 REFCLK_NEOCLOCK4X */ ++ &refclock_neoclock4x, /* 44 REFCLK_NEOCLOCK4X */ ++ &refclock_tsyncpci /* 45 REFCLK_TSYNCPCI */ + }; + + u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *); +diff -up ntp-4.2.6p5/ntpd/refclock_tsyncpci.c.tsyncdriver ntp-4.2.6p5/ntpd/refclock_tsyncpci.c +--- ntp-4.2.6p5/ntpd/refclock_tsyncpci.c.tsyncdriver 2017-09-19 11:01:08.271219088 +0200 ++++ ntp-4.2.6p5/ntpd/refclock_tsyncpci.c 2017-09-19 11:04:55.261709585 +0200 +@@ -0,0 +1,922 @@ ++/******************************************************************************* ++* ++* Module : refclock_tsyncpci.c ++* Date : 09/08/08 ++* Purpose : Implements a reference clock driver for the NTP daemon. This ++* reference clock driver provides a means to communicate with ++* the Spectracom TSYNC PCI timing devices and use them as a time ++* source. ++* ++* (C) Copyright 2008 Spectracom Corporation ++* ++* This software is provided by Spectracom Corporation 'as is' and ++* any express or implied warranties, including, but not limited to, the ++* implied warranties of merchantability and fitness for a particular purpose ++* are disclaimed. In no event shall Spectracom Corporation be liable ++* for any direct, indirect, incidental, special, exemplary, or consequential ++* damages (including, but not limited to, procurement of substitute goods ++* or services; loss of use, data, or profits; or business interruption) ++* however caused and on any theory of liability, whether in contract, strict ++* liability, or tort (including negligence or otherwise) arising in any way ++* out of the use of this software, even if advised of the possibility of ++* such damage. ++* ++* This software is released for distribution according to the NTP copyright ++* and license contained in html/copyright.html of NTP source. ++* ++*******************************************************************************/ ++#ifdef HAVE_CONFIG_H ++#include ++#endif ++ ++#if defined(REFCLOCK) && defined(CLOCK_TSYNCPCI) ++ ++#include ++#ifdef HAVE_SYS_IOCTL_H ++# include ++#endif ++ ++#include ++#include ++#include ++ ++ ++#include "ntpd.h" ++#include "ntp_io.h" ++#include "ntp_refclock.h" ++#include "ntp_unixtime.h" ++#include "ntp_stdlib.h" ++#include "ntp_calendar.h" ++ ++ ++/******************************************************************************* ++** ++** This driver supports the Spectracom TSYNC PCI GPS receiver. It requires ++** that the tsyncpci.o device driver be installed and loaded. ++** ++*******************************************************************************/ ++ ++#define TSYNC_PCI_REVISION "1.11" ++ ++/* ++** TPRO interface definitions ++*/ ++#define DEVICE "/dev/tsyncpci" /* device name */ ++#define PRECISION (-20) /* precision assumed (1 us) */ ++#define DESCRIPTION "Spectracom TSYNC-PCI" /* WRU */ ++ ++#define SECONDS_1900_TO_1970 (2208988800U) ++ ++#define TSYNC_REF_IID (0x2500) // SS CAI, REF IID ++#define TSYNC_REF_DEST_ID (0x0001) // KTS Firmware ++#define TSYNC_REF_IN_PYLD_OFF (0) ++#define TSYNC_REF_IN_LEN (0) ++#define TSYNC_REF_OUT_PYLD_OFF (0) ++#define TSYNC_REF_OUT_LEN (8) ++#define TSYNC_REF_MAX_OUT_LEN (16) ++#define TSYNC_REF_PYLD_LEN (TSYNC_REF_IN_LEN + \ ++ TSYNC_REF_MAX_OUT_LEN) ++#define TSYNC_REF_LEN (4) ++#define TSYNC_REF_LOCAL ("LOCL") ++ ++#define TSYNC_TMSCL_IID (0x2301) // CS CAI, TIMESCALE IID ++#define TSYNC_TMSCL_DEST_ID (0x0001) // KTS Firmware ++#define TSYNC_TMSCL_IN_PYLD_OFF (0) ++#define TSYNC_TMSCL_IN_LEN (0) ++#define TSYNC_TMSCL_OUT_PYLD_OFF (0) ++#define TSYNC_TMSCL_OUT_LEN (4) ++#define TSYNC_TMSCL_MAX_OUT_LEN (12) ++#define TSYNC_TMSCL_PYLD_LEN (TSYNC_TMSCL_IN_LEN + \ ++ TSYNC_TMSCL_MAX_OUT_LEN) ++ ++#define TSYNC_LEAP_IID (0x2307) // CS CAI, LEAP SEC IID ++#define TSYNC_LEAP_DEST_ID (0x0001) // KTS Firmware ++#define TSYNC_LEAP_IN_PYLD_OFF (0) ++#define TSYNC_LEAP_IN_LEN (0) ++#define TSYNC_LEAP_OUT_PYLD_OFF (0) ++#define TSYNC_LEAP_OUT_LEN (28) ++#define TSYNC_LEAP_MAX_OUT_LEN (36) ++#define TSYNC_LEAP_PYLD_LEN (TSYNC_LEAP_IN_LEN + \ ++ TSYNC_LEAP_MAX_OUT_LEN) ++ ++// These define the base date/time of the system clock. The system time will ++// be tracked as the number of seconds from this date/time. ++#define TSYNC_TIME_BASE_YEAR (1970) // earliest acceptable year ++#define TSYNC_SECS_PER_MIN (60) ++#define TSYNC_MINS_PER_HR (60) ++#define TSYNC_HRS_PER_DAY (24) ++#define TSYNC_DAYS_PER_YR (365) ++#define TSYNC_DAYS_PER_LYR (366) ++#define TSYNC_SECS_PER_HR (TSYNC_MINS_PER_HR * TSYNC_SECS_PER_MIN) ++#define TSYNC_SECS_PER_DAY (TSYNC_HRS_PER_DAY * TSYNC_SECS_PER_HR) ++#define TSYNC_SECS_PER_YR (TSYNC_DAYS_PER_YR * TSYNC_SECS_PER_DAY) ++#define TSYNC_SECS_PER_LYR (TSYNC_DAYS_PER_LYR * TSYNC_SECS_PER_DAY) ++ ++ ++#define TSYNC_LCL_STRATUM (0) ++ ++/* ++** TSYNC Time Scales type ++*/ ++typedef enum ++{ ++ TIME_SCALE_UTC = 0, // Universal Coordinated Time ++ TIME_SCALE_TAI = 1, // International Atomic Time ++ TIME_SCALE_GPS = 2, // Global Positioning System ++ TIME_SCALE_LOCAL = 3, // UTC w/local rules for time zone and DST ++ NUM_TIME_SCALES = 4, // Number of time scales ++ ++ TIME_SCALE_MAX = 15 // Maximum number of timescales ++ ++} TIME_SCALE; ++ ++/* ++** TSYNC Board Object ++*/ ++typedef struct BoardObj { ++ ++ int file_descriptor; ++ unsigned short devid; ++ unsigned short options; ++ unsigned char firmware[5]; ++ unsigned char FPGA[5]; ++ unsigned char driver[7]; ++ ++} BoardObj; ++ ++/* ++** TSYNC Time Object ++*/ ++typedef struct TimeObj { ++ ++ unsigned char syncOption; /* -M option */ ++ unsigned int secsDouble; /* seconds floating pt */ ++ unsigned char seconds; /* seconds whole num */ ++ unsigned char minutes; ++ unsigned char hours; ++ unsigned short days; ++ unsigned short year; ++ unsigned short flags; /* bit 2 SYNC, bit 1 TCODE; all others 0 */ ++ ++} TimeObj; ++ ++/* ++** NTP Time Object ++*/ ++typedef struct NtpTimeObj { ++ ++ TimeObj timeObj; ++ struct timeval tv; ++ unsigned int refId; ++ ++} NtpTimeObj; ++/* ++** TSYNC Supervisor Reference Object ++*/ ++typedef struct ReferenceObj { ++ ++ char time[TSYNC_REF_LEN]; ++ char pps[TSYNC_REF_LEN]; ++ ++} ReferenceObj; ++ ++/* ++** TSYNC Seconds Time Object ++*/ ++typedef struct SecTimeObj ++{ ++ unsigned int seconds; ++ unsigned int ns; ++} ++SecTimeObj; ++ ++/* ++** TSYNC DOY Time Object ++*/ ++typedef struct DoyTimeObj ++{ ++ unsigned int year; ++ unsigned int doy; ++ unsigned int hour; ++ unsigned int minute; ++ unsigned int second; ++ unsigned int ns; ++} ++DoyTimeObj; ++ ++/* ++** TSYNC Leap Second Object ++*/ ++typedef struct LeapSecondObj ++{ ++ int offset; ++ DoyTimeObj utcDate; ++} ++LeapSecondObj; ++ ++/* ++ * structures for ioctl interactions with driver ++ */ ++#define DI_PAYLOADS_STARTER_LENGTH 4 ++typedef struct ioctl_trans_di { ++ ++ // input parameters ++ uint16_t dest; ++ uint16_t iid; ++ ++ uint32_t inPayloadOffset; ++ uint32_t inLength; ++ uint32_t outPayloadOffset; ++ uint32_t maxOutLength; ++ ++ // output parameters ++ uint32_t actualOutLength; ++ int32_t status; ++ ++ // Input and output ++ ++ // The payloads field MUST be last in ioctl_trans_di. ++ uint8_t payloads[DI_PAYLOADS_STARTER_LENGTH]; ++ ++}ioctl_trans_di; ++ ++/* ++ * structure for looking up a reference ID from a reference name ++ */ ++typedef struct ++{ ++ const char* pRef; // KTS Reference Name ++ const char* pRefId; // NTP Reference ID ++ ++} RefIdLookup; ++ ++/* ++ * unit control structure ++ */ ++typedef struct { ++ uint32_t refPrefer; // Reference prefer flag ++ uint32_t refId; // Host peer reference ID ++ uint8_t refStratum; // Host peer reference stratum ++ ++} TsyncUnit; ++ ++/* ++** Function prototypes ++*/ ++static void tsync_poll (int unit, struct peer *); ++static void tsync_shutdown (int, struct peer *); ++static int tsync_start (int, struct peer *); ++ ++/* ++** Helper functions ++*/ ++static void ApplyTimeOffset (DoyTimeObj* pDt, int off); ++static void SecTimeFromDoyTime (SecTimeObj* pSt, DoyTimeObj* pDt); ++static void DoyTimeFromSecTime (DoyTimeObj* pDt, SecTimeObj* pSt); ++ ++/* ++** Transfer vector ++*/ ++struct refclock refclock_tsyncpci = { ++ tsync_start, /* start up driver */ ++ tsync_shutdown, /* shut down driver */ ++ tsync_poll, /* transmit poll message */ ++ noentry, /* not used (old tsync_control) */ ++ noentry, /* initialize driver (not used) */ ++ noentry, /* not used (old tsync_buginfo) */ ++ NOFLAGS /* not used */ ++}; ++ ++/* ++ * Reference ID lookup table ++ */ ++static RefIdLookup RefIdLookupTbl[] = ++{ ++ {"gps", "GPS"}, ++ {"ir", "IRIG"}, ++ {"hvq", "HVQ"}, ++ {"frq", "FREQ"}, ++ {"mdm", "ACTS"}, ++ {"epp", "PPS"}, ++ {"ptp", "PTP"}, ++ {"asc", "ATC"}, ++ {"hst0", "USER"}, ++ {"hst", TSYNC_REF_LOCAL}, ++ {"self", TSYNC_REF_LOCAL}, ++ {NULL, NULL} ++}; ++ ++/******************************************************************************* ++** IOCTL DEFINITIONS ++*******************************************************************************/ ++#define IOCTL_TPRO_ID 't' ++#define IOCTL_TPRO_OPEN _IOWR(IOCTL_TPRO_ID, 0, BoardObj) ++#define IOCTL_TPRO_GET_NTP_TIME _IOWR(IOCTL_TPRO_ID, 25, NtpTimeObj) ++#define IOCTL_TSYNC_GET _IOWR(IOCTL_TPRO_ID, 26, ioctl_trans_di) ++ ++/****************************************************************************** ++ * ++ * Function: tsync_start() ++ * Description: Used to intialize the Spectracom TSYNC reference driver. ++ * ++ * Parameters: ++ * IN: unit - not used. ++ * *peer - pointer to this reference clock's peer structure ++ * Returns: 0 - unsuccessful ++ * 1 - successful ++ * ++*******************************************************************************/ ++static int tsync_start(int unit, struct peer *peer) ++{ ++ struct refclockproc *pp; ++ TsyncUnit *up; ++ ++ ++ /* ++ ** initialize reference clock and peer parameters ++ */ ++ pp = peer->procptr; ++ pp->clockdesc = DESCRIPTION; ++ pp->io.clock_recv = noentry; ++ pp->io.srcclock = (caddr_t)peer; ++ pp->io.datalen = 0; ++ peer->precision = PRECISION; ++ ++ // Allocate and initialize unit structure ++ if (!(up = (TsyncUnit*)emalloc(sizeof(TsyncUnit)))) ++ { ++ return (0); ++ } ++ ++ // Store reference preference ++ up->refPrefer = peer->flags & FLAG_PREFER; ++ ++ // Initialize reference stratum level and ID ++ up->refStratum = STRATUM_UNSPEC; ++ strncpy((char *)&up->refId, TSYNC_REF_LOCAL, TSYNC_REF_LEN); ++ ++ // Attach unit structure ++ pp->unitptr = (caddr_t)up; ++ ++ /* Declare our refId as local in the beginning because we do not know ++ * what our actual refid is yet. ++ */ ++ strncpy((char *)&pp->refid, TSYNC_REF_LOCAL, TSYNC_REF_LEN); ++ ++ return (1); ++ ++} /* End - tsync_start() */ ++ ++/******************************************************************************* ++** ++** Function: tsync_shutdown() ++** Description: Handles anything related to shutting down the reference clock ++** driver. Nothing at this point in time. ++** ++** Parameters: ++** IN: unit - not used. ++** *peer - pointer to this reference clock's peer structure ++** Returns: none. ++** ++*******************************************************************************/ ++static void tsync_shutdown(int unit, struct peer *peer) ++{ ++ ++} /* End - tsync_shutdown() */ ++ ++/****************************************************************************** ++ * ++ * Function: tsync_poll() ++ * Description: Retrieve time from the TSYNC device. ++ * ++ * Parameters: ++ * IN: unit - not used. ++ * *peer - pointer to this reference clock's peer structure ++ * Returns: none. ++ * ++*******************************************************************************/ ++static void tsync_poll(int unit, struct peer *peer) ++{ ++ char device[32]; ++ struct refclockproc *pp; ++ struct calendar jt; ++ TsyncUnit *up; ++ unsigned char synch; ++ double seconds; ++ int err; ++ int err1; ++ int err2; ++ int err3; ++ int i; ++ int j; ++ unsigned int itAllocationLength; ++ unsigned int itAllocationLength1; ++ unsigned int itAllocationLength2; ++ NtpTimeObj TimeContext; ++ BoardObj hBoard; ++ char timeRef[TSYNC_REF_LEN + 1]; ++ char ppsRef [TSYNC_REF_LEN + 1]; ++ TIME_SCALE tmscl = TIME_SCALE_UTC; ++ LeapSecondObj leapSec; ++ ioctl_trans_di *it; ++ ioctl_trans_di *it1; ++ ioctl_trans_di *it2; ++ l_fp offset; ++ l_fp ltemp; ++ ReferenceObj * pRefObj; ++ ++ ++ /* Construct the device name */ ++ sprintf(device, "%s%d", DEVICE, (int)peer->refclkunit); ++ ++ printf("Polling device number %d...\n", (int)peer->refclkunit); ++ ++ /* Open the TSYNC device */ ++ hBoard.file_descriptor = open(device, O_RDONLY | O_NDELAY, 0777); ++ ++ /* If error opening TSYNC device... */ ++ if (hBoard.file_descriptor < 0) ++ { ++ msyslog(LOG_ERR, "Couldn't open device"); ++ return; ++ } ++ ++ /* If error while initializing the board... */ ++ if (ioctl(hBoard.file_descriptor, IOCTL_TPRO_OPEN, &hBoard) < 0) ++ { ++ msyslog(LOG_ERR, "Couldn't initialize device"); ++ close(hBoard.file_descriptor); ++ return; ++ } ++ ++ /* Allocate memory for ioctl message */ ++ itAllocationLength = ++ (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) + ++ TSYNC_REF_IN_LEN + TSYNC_REF_MAX_OUT_LEN; ++ ++ it = (ioctl_trans_di*)alloca(itAllocationLength); ++ if (it == NULL) { ++ msyslog(LOG_ERR, "Couldn't allocate transaction memory - Reference"); ++ return; ++ } ++ ++ /* Build SS_GetRef ioctl message */ ++ it->dest = TSYNC_REF_DEST_ID; ++ it->iid = TSYNC_REF_IID; ++ it->inPayloadOffset = TSYNC_REF_IN_PYLD_OFF; ++ it->inLength = TSYNC_REF_IN_LEN; ++ it->outPayloadOffset = TSYNC_REF_OUT_PYLD_OFF; ++ it->maxOutLength = TSYNC_REF_MAX_OUT_LEN; ++ it->actualOutLength = 0; ++ it->status = 0; ++ memset(it->payloads, 0, TSYNC_REF_MAX_OUT_LEN); ++ ++ /* Read the reference from the TSYNC-PCI device */ ++ err = ioctl(hBoard.file_descriptor, ++ IOCTL_TSYNC_GET, ++ (char *)it); ++ ++ /* Allocate memory for ioctl message */ ++ itAllocationLength1 = ++ (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) + ++ TSYNC_TMSCL_IN_LEN + TSYNC_TMSCL_MAX_OUT_LEN; ++ ++ it1 = (ioctl_trans_di*)alloca(itAllocationLength1); ++ if (it1 == NULL) { ++ msyslog(LOG_ERR, "Couldn't allocate transaction memory - Time Scale"); ++ return; ++ } ++ ++ /* Build CS_GetTimeScale ioctl message */ ++ it1->dest = TSYNC_TMSCL_DEST_ID; ++ it1->iid = TSYNC_TMSCL_IID; ++ it1->inPayloadOffset = TSYNC_TMSCL_IN_PYLD_OFF; ++ it1->inLength = TSYNC_TMSCL_IN_LEN; ++ it1->outPayloadOffset = TSYNC_TMSCL_OUT_PYLD_OFF; ++ it1->maxOutLength = TSYNC_TMSCL_MAX_OUT_LEN; ++ it1->actualOutLength = 0; ++ it1->status = 0; ++ memset(it1->payloads, 0, TSYNC_TMSCL_MAX_OUT_LEN); ++ ++ /* Read the Time Scale info from the TSYNC-PCI device */ ++ err1 = ioctl(hBoard.file_descriptor, ++ IOCTL_TSYNC_GET, ++ (char *)it1); ++ ++ /* Allocate memory for ioctl message */ ++ itAllocationLength2 = ++ (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) + ++ TSYNC_LEAP_IN_LEN + TSYNC_LEAP_MAX_OUT_LEN; ++ ++ it2 = (ioctl_trans_di*)alloca(itAllocationLength2); ++ if (it2 == NULL) { ++ msyslog(LOG_ERR, "Couldn't allocate transaction memory - Leap Second"); ++ return; ++ } ++ ++ /* Build CS_GetLeapSec ioctl message */ ++ it2->dest = TSYNC_LEAP_DEST_ID; ++ it2->iid = TSYNC_LEAP_IID; ++ it2->inPayloadOffset = TSYNC_LEAP_IN_PYLD_OFF; ++ it2->inLength = TSYNC_LEAP_IN_LEN; ++ it2->outPayloadOffset = TSYNC_LEAP_OUT_PYLD_OFF; ++ it2->maxOutLength = TSYNC_LEAP_MAX_OUT_LEN; ++ it2->actualOutLength = 0; ++ it2->status = 0; ++ memset(it2->payloads, 0, TSYNC_LEAP_MAX_OUT_LEN); ++ ++ /* Read the leap seconds info from the TSYNC-PCI device */ ++ err2 = ioctl(hBoard.file_descriptor, ++ IOCTL_TSYNC_GET, ++ (char *)it2); ++ ++ pp = peer->procptr; ++ up = (TsyncUnit*)pp->unitptr; ++ ++ /* Read the time from the TSYNC-PCI device */ ++ err3 = ioctl(hBoard.file_descriptor, ++ IOCTL_TPRO_GET_NTP_TIME, ++ (char *)&TimeContext); ++ ++ /* Close the TSYNC device */ ++ close(hBoard.file_descriptor); ++ ++ // Check for errors ++ if ((err < 0) ||(err1 < 0) || (err2 < 0) || (err3 < 0) || ++ (it->status != 0) || (it1->status != 0) || (it2->status != 0) || ++ (it->actualOutLength != TSYNC_REF_OUT_LEN) || ++ (it1->actualOutLength != TSYNC_TMSCL_OUT_LEN) || ++ (it2->actualOutLength != TSYNC_LEAP_OUT_LEN)) { ++ refclock_report(peer, CEVNT_FAULT); ++ return; ++ } ++ ++ // Extract reference identifiers from ioctl payload ++ memset(timeRef, '\0', sizeof(timeRef)); ++ memset(ppsRef, '\0', sizeof(ppsRef)); ++ pRefObj = (void *)it->payloads; ++ memcpy(timeRef, pRefObj->time, TSYNC_REF_LEN); ++ memcpy(ppsRef, pRefObj->pps, TSYNC_REF_LEN); ++ ++ // Extract the Clock Service Time Scale and convert to correct byte order ++ memcpy(&tmscl, it1->payloads, sizeof(tmscl)); ++ tmscl = ntohl(tmscl); ++ ++ // Extract leap second info from ioctl payload and perform byte swapping ++ for (i = 0; i < (sizeof(leapSec) / 4); i++) ++ { ++ for (j = 0; j < 4; j++) ++ { ++ ((unsigned char*)&leapSec)[(i * 4) + j] = ++ ((unsigned char*)(it2->payloads))[(i * 4) + (3 - j)]; ++ } ++ } ++ ++ // Determine time reference ID from reference name ++ for (i = 0; RefIdLookupTbl[i].pRef != NULL; i++) ++ { ++ // Search RefID table ++ if (strstr(timeRef, RefIdLookupTbl[i].pRef) != NULL) ++ { ++ // Found the matching string ++ break; ++ } ++ } ++ ++ // Determine pps reference ID from reference name ++ for (j = 0; RefIdLookupTbl[j].pRef != NULL; j++) ++ { ++ // Search RefID table ++ if (strstr(ppsRef, RefIdLookupTbl[j].pRef) != NULL) ++ { ++ // Found the matching string ++ break; ++ } ++ } ++ ++ // Determine synchronization state from flags ++ synch = (TimeContext.timeObj.flags == 0x4) ? 1 : 0; ++ ++ // Pull seconds information from time object ++ seconds = (double) (TimeContext.timeObj.secsDouble); ++ seconds /= (double) 1000000.0; ++ ++ /* ++ ** Convert the number of microseconds to double and then place in the ++ ** peer's last received long floating point format. ++ */ ++ DTOLFP(((double)TimeContext.tv.tv_usec / 1000000.0), &pp->lastrec); ++ ++ /* ++ ** The specTimeStamp is the number of seconds since 1/1/1970, while the ++ ** peer's lastrec time should be compatible with NTP which is seconds since ++ ** 1/1/1900. So Add the number of seconds between 1900 and 1970 to the ++ ** specTimeStamp and place in the peer's lastrec long floating point struct. ++ */ ++ pp->lastrec.Ul_i.Xl_ui += (unsigned int)TimeContext.tv.tv_sec + ++ SECONDS_1900_TO_1970; ++ ++ pp->polls++; ++ ++ /* ++ ** set the reference clock object ++ */ ++ sprintf(pp->a_lastcode, "%03d %02d:%02d:%02.6f", ++ TimeContext.timeObj.days, TimeContext.timeObj.hours, ++ TimeContext.timeObj.minutes, seconds); ++ ++ pp->lencode = strlen (pp->a_lastcode); ++ pp->day = TimeContext.timeObj.days; ++ pp->hour = TimeContext.timeObj.hours; ++ pp->minute = TimeContext.timeObj.minutes; ++ pp->second = (int) seconds; ++ seconds = (seconds - (double) (pp->second / 1.0)) * 1000000000; ++ pp->nsec = (long) seconds; ++ ++ /* ++ ** calculate year start ++ */ ++ jt.year = TimeContext.timeObj.year; ++ jt.yearday = 1; ++ jt.monthday = 1; ++ jt.month = 1; ++ jt.hour = 0; ++ jt.minute = 0; ++ jt.second = 0; ++ pp->yearstart = caltontp(&jt); ++ ++ // Calculate and report reference clock offset ++ offset.l_ui = (long)(((pp->day - 1) * 24) + pp->hour + GMT); ++ offset.l_ui = (offset.l_ui * 60) + (long)pp->minute; ++ offset.l_ui = (offset.l_ui * 60) + (long)pp->second; ++ offset.l_ui = offset.l_ui + (long)pp->yearstart; ++ offset.l_uf = 0; ++ DTOLFP(pp->nsec / 1e9, <emp); ++ L_ADD(&offset, <emp); ++ refclock_process_offset(pp, offset, pp->lastrec, ++ pp->fudgetime1); ++ ++ // KTS in sync ++ if (synch) { ++ // Subtract leap second info by one second to determine effective day ++ ApplyTimeOffset(&(leapSec.utcDate), -1); ++ ++ // If there is a leap second today and the KTS is using a time scale ++ // which handles leap seconds then ++ if ((tmscl != TIME_SCALE_GPS) && (tmscl != TIME_SCALE_TAI) && ++ (leapSec.utcDate.year == (unsigned int)TimeContext.timeObj.year) && ++ (leapSec.utcDate.doy == (unsigned int)TimeContext.timeObj.days)) ++ { ++ // If adding a second ++ if (leapSec.offset == 1) ++ { ++ pp->leap = LEAP_ADDSECOND; ++ } ++ // Else if removing a second ++ else if (leapSec.offset == -1) ++ { ++ pp->leap = LEAP_DELSECOND; ++ } ++ // Else report no leap second pending (no handling of offsets ++ // other than +1 or -1) ++ else ++ { ++ pp->leap = LEAP_NOWARNING; ++ } ++ } ++ // Else report no leap second pending ++ else ++ { ++ pp->leap = LEAP_NOWARNING; ++ } ++ ++ peer->leap = pp->leap; ++ refclock_report(peer, CEVNT_NOMINAL); ++ ++ // If reference name reported, then not in holdover ++ if ((RefIdLookupTbl[i].pRef != NULL) && ++ (RefIdLookupTbl[j].pRef != NULL)) ++ { ++ // Determine if KTS being synchronized by host (identified as ++ // "LOCL") ++ if ((strcmp(RefIdLookupTbl[i].pRefId, TSYNC_REF_LOCAL) == 0) || ++ (strcmp(RefIdLookupTbl[j].pRefId, TSYNC_REF_LOCAL) == 0)) ++ { ++ // Clear prefer flag ++ peer->flags &= ~FLAG_PREFER; ++ ++ // Set reference clock stratum level as unusable ++ pp->stratum = STRATUM_UNSPEC; ++ peer->stratum = pp->stratum; ++ ++ // If a valid peer is available ++ if ((sys_peer != NULL) && (sys_peer != peer)) ++ { ++ // Store reference peer stratum level and ID ++ up->refStratum = sys_peer->stratum; ++ up->refId = addr2refid(&sys_peer->srcadr); ++ } ++ } ++ else ++ { ++ // Restore prefer flag ++ peer->flags |= up->refPrefer; ++ ++ // Store reference stratum as local clock ++ up->refStratum = TSYNC_LCL_STRATUM; ++ strncpy((char *)&up->refId, RefIdLookupTbl[j].pRefId, ++ TSYNC_REF_LEN); ++ ++ // Set reference clock stratum level as local clock ++ pp->stratum = TSYNC_LCL_STRATUM; ++ peer->stratum = pp->stratum; ++ } ++ ++ // Update reference name ++ strncpy((char *)&pp->refid, RefIdLookupTbl[j].pRefId, ++ TSYNC_REF_LEN); ++ peer->refid = pp->refid; ++ } ++ // Else in holdover ++ else ++ { ++ // Restore prefer flag ++ peer->flags |= up->refPrefer; ++ ++ // Update reference ID to saved ID ++ pp->refid = up->refId; ++ peer->refid = pp->refid; ++ ++ // Update stratum level to saved stratum level ++ pp->stratum = up->refStratum; ++ peer->stratum = pp->stratum; ++ } ++ } ++ // Else KTS not in sync ++ else { ++ // Place local identifier in peer RefID ++ strncpy((char *)&pp->refid, TSYNC_REF_LOCAL, TSYNC_REF_LEN); ++ peer->refid = pp->refid; ++ ++ // Report not in sync ++ pp->leap = LEAP_NOTINSYNC; ++ peer->leap = pp->leap; ++ } ++ ++ if (pp->coderecv == pp->codeproc) { ++ refclock_report(peer, CEVNT_TIMEOUT); ++ return; ++ } ++ ++ record_clock_stats(&peer->srcadr, pp->a_lastcode); ++ refclock_receive(peer); ++ ++ /* Increment the number of times the reference has been polled */ ++ pp->polls++; ++ ++} /* End - tsync_poll() */ ++ ++ ++//////////////////////////////////////////////////////////////////////////////// ++// Function: ApplyTimeOffset ++// Description: The ApplyTimeOffset function adds an offset (in seconds) to a ++// specified date and time. The specified date and time is passed ++// back after being modified. ++// ++// Assumptions: 1. Every fourth year is a leap year. Therefore, this function ++// is only accurate through Feb 28, 2100. ++//////////////////////////////////////////////////////////////////////////////// ++void ApplyTimeOffset(DoyTimeObj* pDt, int off) ++{ ++ SecTimeObj st; // Time, in seconds ++ ++ ++ // Convert date and time to seconds ++ SecTimeFromDoyTime(&st, pDt); ++ ++ // Apply offset ++ st.seconds = (int)((signed long long)st.seconds + (signed long long)off); ++ ++ // Convert seconds to date and time ++ DoyTimeFromSecTime(pDt, &st); ++ ++} // End ApplyTimeOffset ++ ++ ++//////////////////////////////////////////////////////////////////////////////// ++// Function: SecTimeFromDoyTime ++// Description: The SecTimeFromDoyTime function converts a specified date ++// and time into a count of seconds since the base time. This ++// function operates across the range Base Time to Max Time for ++// the system. ++// ++// Assumptions: 1. A leap year is any year evenly divisible by 4. Therefore, ++// this function is only accurate through Feb 28, 2100. ++// 2. Conversion does not account for leap seconds. ++//////////////////////////////////////////////////////////////////////////////// ++void SecTimeFromDoyTime(SecTimeObj* pSt, DoyTimeObj* pDt) ++{ ++ unsigned int yrs; // Years ++ unsigned int lyrs; // Leap years ++ ++ ++ // Start with accumulated time of 0 ++ pSt->seconds = 0; ++ ++ // Calculate the number of years and leap years ++ yrs = pDt->year - TSYNC_TIME_BASE_YEAR; ++ lyrs = (yrs + 1) / 4; ++ ++ // Convert leap years and years ++ pSt->seconds += lyrs * TSYNC_SECS_PER_LYR; ++ pSt->seconds += (yrs - lyrs) * TSYNC_SECS_PER_YR; ++ ++ // Convert days, hours, minutes and seconds ++ pSt->seconds += (pDt->doy - 1) * TSYNC_SECS_PER_DAY; ++ pSt->seconds += pDt->hour * TSYNC_SECS_PER_HR; ++ pSt->seconds += pDt->minute * TSYNC_SECS_PER_MIN; ++ pSt->seconds += pDt->second; ++ ++ // Copy the subseconds count ++ pSt->ns = pDt->ns; ++ ++} // End SecTimeFromDoyTime ++ ++ ++//////////////////////////////////////////////////////////////////////////////// ++// Function: DoyTimeFromSecTime ++// Description: The DoyTimeFromSecTime function converts a specified count ++// of seconds since the start of our base time into a SecTimeObj ++// structure. ++// ++// Assumptions: 1. A leap year is any year evenly divisible by 4. Therefore, ++// this function is only accurate through Feb 28, 2100. ++// 2. Conversion does not account for leap seconds. ++//////////////////////////////////////////////////////////////////////////////// ++void DoyTimeFromSecTime(DoyTimeObj* pDt, SecTimeObj* pSt) ++{ ++ signed long long secs; // Seconds accumulator variable ++ unsigned int yrs; // Years accumulator variable ++ unsigned int doys; // Days accumulator variable ++ unsigned int hrs; // Hours accumulator variable ++ unsigned int mins; // Minutes accumulator variable ++ ++ ++ // Convert the seconds count into a signed 64-bit number for calculations ++ secs = (signed long long)(pSt->seconds); ++ ++ // Calculate the number of 4 year chunks ++ yrs = (unsigned int)((secs / ++ ((TSYNC_SECS_PER_YR * 3) + TSYNC_SECS_PER_LYR)) * 4); ++ secs %= ((TSYNC_SECS_PER_YR * 3) + TSYNC_SECS_PER_LYR); ++ ++ // If there is at least a normal year worth of time left ++ if (secs >= TSYNC_SECS_PER_YR) ++ { ++ // Increment the number of years and subtract a normal year of time ++ yrs++; ++ secs -= TSYNC_SECS_PER_YR; ++ } ++ ++ // If there is still at least a normal year worth of time left ++ if (secs >= TSYNC_SECS_PER_YR) ++ { ++ // Increment the number of years and subtract a normal year of time ++ yrs++; ++ secs -= TSYNC_SECS_PER_YR; ++ } ++ ++ // If there is still at least a leap year worth of time left ++ if (secs >= TSYNC_SECS_PER_LYR) ++ { ++ // Increment the number of years and subtract a leap year of time ++ yrs++; ++ secs -= TSYNC_SECS_PER_LYR; ++ } ++ ++ // Calculate the day of year as the number of days left, then add 1 ++ // because months start on the 1st. ++ doys = (unsigned int)((secs / TSYNC_SECS_PER_DAY) + 1); ++ secs %= TSYNC_SECS_PER_DAY; ++ ++ // Calculate the hour ++ hrs = (unsigned int)(secs / TSYNC_SECS_PER_HR); ++ secs %= TSYNC_SECS_PER_HR; ++ ++ // Calculate the minute ++ mins = (unsigned int)(secs / TSYNC_SECS_PER_MIN); ++ secs %= TSYNC_SECS_PER_MIN; ++ ++ // Fill in the doytime structure ++ pDt->year = yrs + TSYNC_TIME_BASE_YEAR; ++ pDt->doy = doys; ++ pDt->hour = hrs; ++ pDt->minute = mins; ++ pDt->second = (unsigned int)secs; ++ pDt->ns = pSt->ns; ++ ++} // End DoyTimeFromSecTime ++ ++#else ++int refclock_tsyncpci_bs; ++#endif /* REFCLOCK */ diff --git a/SOURCES/ntp-4.2.6p5-updatebclient.patch b/SOURCES/ntp-4.2.6p5-updatebclient.patch new file mode 100644 index 0000000..bc740e9 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-updatebclient.patch @@ -0,0 +1,23 @@ +diff -up ntp-4.2.6p5/ntpd/ntp_io.c.updatebclient ntp-4.2.6p5/ntpd/ntp_io.c +--- ntp-4.2.6p5/ntpd/ntp_io.c.updatebclient 2012-11-20 15:54:23.516362641 +0100 ++++ ntp-4.2.6p5/ntpd/ntp_io.c 2012-11-20 15:55:05.464364038 +0100 +@@ -2044,6 +2044,9 @@ update_interfaces( + msyslog(LOG_INFO, "peers refreshed"); + } + ++ if (sys_bclient) ++ io_setbclient(); ++ + return new_interface_found; + } + +@@ -2678,9 +2681,6 @@ io_setbclient(void) + set_pktinfo(1); + if (nif > 0) + DPRINTF(1, ("io_setbclient: Opened broadcast clients\n")); +- else if (!nif) +- msyslog(LOG_ERR, +- "Unable to listen for broadcasts, no broadcast interfaces available"); + #else + msyslog(LOG_ERR, + "io_setbclient: Broadcast Client disabled by build"); diff --git a/SOURCES/ntp-4.2.6p5-xleap.patch b/SOURCES/ntp-4.2.6p5-xleap.patch new file mode 100644 index 0000000..2937f97 --- /dev/null +++ b/SOURCES/ntp-4.2.6p5-xleap.patch @@ -0,0 +1,44 @@ +diff -up ntp-4.2.6p5/html/miscopt.html.xleap ntp-4.2.6p5/html/miscopt.html +--- ntp-4.2.6p5/html/miscopt.html.xleap 2009-12-09 08:36:36.000000000 +0100 ++++ ntp-4.2.6p5/html/miscopt.html 2015-02-18 13:36:42.245273922 +0100 +@@ -88,7 +88,7 @@ + is 0.128 s. If set to zero, step adjustments will never + occur. Note: The kernel time discipline is disabled if + the step threshold is set to zero or greater than 0.5 +- s. ++ s and the threshold is applied also to leap second corrections. +
    stepout stepout
    +
    Specifies the stepout threshold in seconds. The default without this + command is 900 s. If set to zero, popcorn spikes will +diff -up ntp-4.2.6p5/html/ntpd.html.xleap ntp-4.2.6p5/html/ntpd.html +--- ntp-4.2.6p5/html/ntpd.html.xleap 2015-02-18 13:24:29.489697158 +0100 ++++ ntp-4.2.6p5/html/ntpd.html 2015-02-18 13:34:46.296031098 +0100 +@@ -146,7 +146,7 @@ +
    -U interface update interval
    +
    Number of seconds to wait between interface list scans to pick up new and delete network interface. Set to 0 to disable dynamic interface list updating. The default is to scan every 5 minutes.
    +
    -x
    +-
    Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the -g and -q options. See the tinker command for other options. Note: The kernel time discipline is disabled with this option.
    ++
    Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the -g and -q options. See the tinker command for other options. Note: The kernel time discipline is disabled with this option and the step threshold is applied also to leap second corrections.
    +
    +

    The Configuration File

    +

    Ordinarily, ntpd reads the ntp.conf configuration file at startup in order to determine the synchronization sources and operating modes. It is also possible to specify a working, although limited, configuration entirely on the command line, obviating the need for a configuration file. This may be particularly useful when the local host is to be configured as a broadcast client, with servers determined by listening to broadcasts at run time.

    +diff -up ntp-4.2.6p5/ntpd/ntp_timer.c.xleap ntp-4.2.6p5/ntpd/ntp_timer.c +--- ntp-4.2.6p5/ntpd/ntp_timer.c.xleap 2015-04-21 18:16:08.255535621 +0200 ++++ ntp-4.2.6p5/ntpd/ntp_timer.c 2015-04-21 18:16:30.463601752 +0200 +@@ -449,8 +449,14 @@ timer(void) + sys_leap = LEAP_NOWARNING; + sys_tai = leap_tai; + #ifdef KERNEL_PLL +- if (!(pll_control && kern_enable)) +- step_systime(-1.0); ++ if (!pll_control || !kern_enable) { ++ if (clock_max < 1.0 && clock_max > 0.0) { ++ step_systime(-1.0); ++ msyslog(LOG_NOTICE, "Inserting positive leap second"); ++ } else { ++ msyslog(LOG_NOTICE, "Ignoring leap second"); ++ } ++ } + #else /* KERNEL_PLL */ + #ifndef SYS_WINNT /* WinNT port has its own leap second handling */ + step_systime(-1.0); diff --git a/SOURCES/ntp-wait.service b/SOURCES/ntp-wait.service new file mode 100644 index 0000000..8d67e13 --- /dev/null +++ b/SOURCES/ntp-wait.service @@ -0,0 +1,14 @@ +[Unit] +Description=Wait for ntpd to synchronize system clock +After=ntpd.service +Requires=ntpd.service +Before=time-sync.target +Wants=time-sync.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/ntp-wait +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/SOURCES/ntp.conf b/SOURCES/ntp.conf new file mode 100644 index 0000000..5ce2137 --- /dev/null +++ b/SOURCES/ntp.conf @@ -0,0 +1,58 @@ +# For more information about this file, see the man pages +# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5). + +driftfile VARNTP/drift + +# Permit time synchronization with our time source, but do not +# permit the source to query or modify the service on this system. +restrict default nomodify notrap nopeer noquery + +# Permit all access over the loopback interface. This could +# be tightened as well, but to do so would effect some of +# the administrative functions. +restrict 127.0.0.1 +restrict ::1 + +# Hosts on local network are less restricted. +#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap + +# Use public servers from the pool.ntp.org project. +# Please consider joining the pool (http://www.pool.ntp.org/join.html). +server 0.VENDORZONE.pool.ntp.org iburst +server 1.VENDORZONE.pool.ntp.org iburst +server 2.VENDORZONE.pool.ntp.org iburst +server 3.VENDORZONE.pool.ntp.org iburst + +#broadcast 192.168.1.255 autokey # broadcast server +#broadcastclient # broadcast client +#broadcast 224.0.1.1 autokey # multicast server +#multicastclient 224.0.1.1 # multicast client +#manycastserver 239.255.254.254 # manycast server +#manycastclient 239.255.254.254 autokey # manycast client + +# Enable public key cryptography. +#crypto + +includefile ETCNTP/crypto/pw + +# Key file containing the keys and key identifiers used when operating +# with symmetric key cryptography. +keys ETCNTP/keys + +# Specify the key identifiers which are trusted. +#trustedkey 4 8 42 + +# Specify the key identifier to use with the ntpdc utility. +#requestkey 8 + +# Specify the key identifier to use with the ntpq utility. +#controlkey 8 + +# Enable writing of statistics records. +#statistics clockstats cryptostats loopstats peerstats + +# Disable the monitoring facility to prevent amplification attacks using ntpdc +# monlist command when default restrict does not include the noquery flag. See +# CVE-2013-5211 for more details. +# Note: Monitoring will not be disabled with the limited restriction flag. +disable monitor diff --git a/SOURCES/ntp.cryptopw b/SOURCES/ntp.cryptopw new file mode 100644 index 0000000..7e96fc2 --- /dev/null +++ b/SOURCES/ntp.cryptopw @@ -0,0 +1,5 @@ +# This file is included from /etc/ntp.conf. It specifies the password used to +# decrypt files containing private keys and identity parameters. The password +# is required only if the files have been encrypted. +# +#crypto pw apassword diff --git a/SOURCES/ntp.dhclient b/SOURCES/ntp.dhclient new file mode 100755 index 0000000..1cc9f43 --- /dev/null +++ b/SOURCES/ntp.dhclient @@ -0,0 +1,63 @@ +#!/bin/bash +# +# ntp.sh: dhclient-script plugin for NTP settings, +# place in /etc/dhcp/dhclient.d and 'chmod +x ntp.sh' to enable +# +# Copyright (C) 2008 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author(s): David Cantrell +# Miroslav Lichvar +# + +CONF=/etc/ntp.conf +SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface} + +ntp_replace_conf() { + echo "$1" | diff -q ${CONF} - > /dev/null 2>&1 + if [ $? -eq 1 ]; then + echo "$1" > ${CONF} + restorecon ${CONF} >/dev/null 2>&1 + systemctl try-restart ntpd.service > /dev/null 2>&1 || + service ntpd condrestart > /dev/null 2>&1 + fi +} + +ntp_config() { + if [ ! "${PEERNTP}" = "no" ] && [ -n "${new_ntp_servers}" ] && + [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then + local conf=$(grep -v '^server .* # added by /sbin/dhclient-script$' < ${CONF}) + local unique_servers=$(comm -23 \ + <(for s in ${new_ntp_servers}; do echo $s; done | sort -u) \ + <(echo "$conf" | awk '$1=="peer"||$1=="server"{print $2}' | sort -u)) + + conf=$(echo "$conf" + for s in ${unique_servers}; do + echo "server ${s} ${NTPSERVERARGS} # added by /sbin/dhclient-script" + done) + + [ -f ${SAVECONF} ] || touch ${SAVECONF} + ntp_replace_conf "$conf" + fi +} + +ntp_restore() { + if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then + local conf=$(grep -v '^server .* # added by /sbin/dhclient-script$' < ${CONF}) + + ntp_replace_conf "$conf" + rm -f ${SAVECONF} + fi +} diff --git a/SOURCES/ntp.keys b/SOURCES/ntp.keys new file mode 100644 index 0000000..80ab8c4 --- /dev/null +++ b/SOURCES/ntp.keys @@ -0,0 +1,3 @@ +# For more information about this file, see the man page ntp_auth(5). +# +# id type key diff --git a/SOURCES/ntp.step-tickers b/SOURCES/ntp.step-tickers new file mode 100644 index 0000000..8b4b1fd --- /dev/null +++ b/SOURCES/ntp.step-tickers @@ -0,0 +1,3 @@ +# List of NTP servers used by the ntpdate service. + +0.VENDORZONE.pool.ntp.org diff --git a/SOURCES/ntpd.service b/SOURCES/ntpd.service new file mode 100644 index 0000000..1084545 --- /dev/null +++ b/SOURCES/ntpd.service @@ -0,0 +1,12 @@ +[Unit] +Description=Network Time Service +After=syslog.target ntpdate.service sntp.service + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/ntpd +ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/SOURCES/ntpd.sysconfig b/SOURCES/ntpd.sysconfig new file mode 100644 index 0000000..49394c7 --- /dev/null +++ b/SOURCES/ntpd.sysconfig @@ -0,0 +1,2 @@ +# Command line options for ntpd +OPTIONS="-g" diff --git a/SOURCES/ntpdate.service b/SOURCES/ntpdate.service new file mode 100644 index 0000000..8e6e616 --- /dev/null +++ b/SOURCES/ntpdate.service @@ -0,0 +1,13 @@ +[Unit] +Description=Set time via NTP +After=network-online.target nss-lookup.target +Before=time-sync.target +Wants=time-sync.target network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/ntpdate-wrapper +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/SOURCES/ntpdate.sysconfig b/SOURCES/ntpdate.sysconfig new file mode 100644 index 0000000..54676b4 --- /dev/null +++ b/SOURCES/ntpdate.sysconfig @@ -0,0 +1,5 @@ +# Options for ntpdate +OPTIONS="-p 2" + +# Set to 'yes' to sync hw clock after successful ntpdate +SYNC_HWCLOCK=no diff --git a/SOURCES/ntpdate.wrapper b/SOURCES/ntpdate.wrapper new file mode 100755 index 0000000..ed91bec --- /dev/null +++ b/SOURCES/ntpdate.wrapper @@ -0,0 +1,29 @@ +#!/bin/bash + +ntpconf=/etc/ntp.conf +ntpstep=/etc/ntp/step-tickers + +[ "$EUID" != "0" ] && exit 4 +[ -x /usr/sbin/ntpdate ] || exit 5 +[ -f /etc/sysconfig/ntpdate ] || exit 6 +. /etc/sysconfig/ntpdate + +[ -f $ntpstep ] && tickers=$(sed 's/#.*//' $ntpstep) || tickers= + +if ! echo "$tickers" | grep -qi '[a-z0-9]' && [ -f $ntpconf ]; then + # the step-tickers file doesn't specify a server, + # use servers from ntp.conf instead + tickers=$(awk '$1=="peer"||$1=="server"{print $2}' $ntpconf | \ + grep -Ev '127\.127\.[0-9]+\.[0-9]+') +fi + +if ! echo "$tickers" | grep -qi '[a-z0-9]'; then + echo "NTP server not specified in $ntpstep or $ntpconf" + exit 6 +fi + +/usr/sbin/ntpdate -U ntp -s -b $OPTIONS $tickers &> /dev/null +RETVAL=$? + +[ $RETVAL -eq 0 ] && [ "$SYNC_HWCLOCK" = "yes" ] && /sbin/hwclock --systohc +exit $RETVAL diff --git a/SOURCES/ntpstat-0.2-clksrc.patch b/SOURCES/ntpstat-0.2-clksrc.patch new file mode 100644 index 0000000..c427f1f --- /dev/null +++ b/SOURCES/ntpstat-0.2-clksrc.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat ntp-4.2.4p7/ntpstat-0.2/ntpstat.c +--- ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat 2002-06-10 08:02:12.000000000 +0200 ++++ ntp-4.2.4p7/ntpstat-0.2/ntpstat.c 2009-07-20 12:22:35.000000000 +0200 +@@ -187,7 +187,7 @@ int main (void) { + else + printf("unknown source"); + +- if (!strncmp(clksrcname[clksrc],clksrcname[6],sizeof(clksrcname[6]))) { ++ if (clksrc == 6) { + // source of sync is another NTP server so check the IP address + strncpy(buff, ntpmsg.payload, sizeof(buff)); + if ((newstr = strstr (buff, REFID))) { diff --git a/SOURCES/ntpstat-0.2-errorbit.patch b/SOURCES/ntpstat-0.2-errorbit.patch new file mode 100644 index 0000000..06e9342 --- /dev/null +++ b/SOURCES/ntpstat-0.2-errorbit.patch @@ -0,0 +1,32 @@ +diff -up ntp-4.2.6p4/ntpstat-0.2/ntpstat.c.errorbit ntp-4.2.6p4/ntpstat-0.2/ntpstat.c +--- ntp-4.2.6p4/ntpstat-0.2/ntpstat.c.errorbit 2011-10-06 13:41:38.591669772 +0200 ++++ ntp-4.2.6p4/ntpstat-0.2/ntpstat.c 2011-10-06 16:50:01.708315811 +0200 +@@ -104,6 +104,7 @@ int main (void) { + FD_ZERO(&fds); + + inet_aton("127.0.0.1", &address); ++ memset(&sock, 0, sizeof (sock));; + sock.sin_family = AF_INET; + sock.sin_addr = address; + sock.sin_port = htons(NTP_PORT); +@@ -159,15 +160,18 @@ int main (void) { + die ("return data appears to be invalid based on status word"); + } + +- if (!(ntpmsg.byte2 | EMASK)) { ++ if (ntpmsg.byte2 & EMASK) { + fprintf (stderr,"status byte2 is %02x\n", ntpmsg.byte2 ); + die ("error bit is set in reply"); + } + +- if (!(ntpmsg.byte2 | MMASK)) { ++ /* ignore the more bit */ ++#if 0 ++ if (ntpmsg.byte2 & MMASK) { + fprintf (stderr,"status byte2 is %02x\n", ntpmsg.byte2 ); + fprintf (stderr,"More bit unexpected in reply"); + } ++#endif + + /* if the leap indicator (LI), which is the two most significant bits + in status byte1, are both one, then the clock is not synchronised. */ diff --git a/SOURCES/ntpstat-0.2-manual.patch b/SOURCES/ntpstat-0.2-manual.patch new file mode 100644 index 0000000..99dbb6a --- /dev/null +++ b/SOURCES/ntpstat-0.2-manual.patch @@ -0,0 +1,41 @@ +diff -up ntp-4.2.6p5/ntpstat-0.2/ntpstat.1.manual ntp-4.2.6p5/ntpstat-0.2/ntpstat.1 +--- ntp-4.2.6p5/ntpstat-0.2/ntpstat.1.manual 2002-06-10 08:02:12.000000000 +0200 ++++ ntp-4.2.6p5/ntpstat-0.2/ntpstat.1 2015-12-04 17:28:23.379793604 +0100 +@@ -1,4 +1,4 @@ +-.TH ntpstat 1 "$Date: 2001/06/22 03:27:10 $" ++.TH ntpstat 1 + .UC 4 + .SH NAME + ntpstat \- show network time synchronisation status +@@ -6,12 +6,18 @@ ntpstat \- show network time synchronisa + .B ntpstat + .SH DESCRIPTION + .I ntpstat +-will report the synchronisation state of the NTP daemon ++will report the synchronisation state of the NTP daemon (ntpd) + running on the local machine. If the local system is found to be + synchronised to a reference time source, + .I ntpstat + will report the approximate time accuracy. + ++When the synchronised state is reported, it means the system clock was updated ++at some point. There is no timeout for this state. It will stay there even ++when the source becomes unreachable and there are no other sources available. ++However, the reported accuracy will be slowly increasing, in the default ntpd ++configuration by 15 microseconds per second. ++ + .SH RETURNS + .I ntpstat + returns 0 if clock is synchronised. +@@ -22,7 +28,10 @@ returns 2 if clock state is indeterminan + if ntpd is not contactable. + + .SH SEE ALSO +-ntpdc, ntpdq ++.BR ntp_misc (5), ++.BR ntpd (8), ++.BR ntpq (8), ++.BR ntpdc (8) + + .SH AUTHOR + G. Richard Keech (rkeech@redhat.com) diff --git a/SOURCES/ntpstat-0.2-maxerror.patch b/SOURCES/ntpstat-0.2-maxerror.patch new file mode 100644 index 0000000..f8ab750 --- /dev/null +++ b/SOURCES/ntpstat-0.2-maxerror.patch @@ -0,0 +1,38 @@ +diff -up ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.maxerror ntp-4.2.6p1/ntpstat-0.2/ntpstat.c +--- ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.maxerror 2010-05-03 11:37:49.000000000 +0200 ++++ ntp-4.2.6p1/ntpstat-0.2/ntpstat.c 2010-05-03 12:20:08.000000000 +0200 +@@ -89,7 +89,9 @@ int main (void) { + "modem"}; /* 9 */ + char *newstr; + char *dispstr; ++ char *delaystr; + const char DISP[] = "rootdisp="; ++ const char DELAY[] = "rootdelay="; + const char STRATUM[] = "stratum="; + const char POLL[] = "tc="; + const char REFID[] = "refid="; +@@ -235,16 +237,19 @@ int main (void) { + /* Set the position of the start of the string to + "rootdispersion=" part of the string. */ + strncpy(buff, ntpmsg.payload, sizeof(buff)); +- if ((newstr = strstr (buff, DISP))) { +- newstr += sizeof(DISP) - 1; +- dispstr = strtok(newstr,"."); ++ if ((dispstr = strstr (buff, DISP)) && (delaystr = strstr (buff, DELAY))) { ++ dispstr += sizeof(DISP) - 1; ++ dispstr = strtok(dispstr,","); ++ delaystr += sizeof(DELAY) - 1; ++ delaystr = strtok(delaystr,","); + + /* Check the resultant string is of a reasonable length */ +- if ((strlen (dispstr) == 0) || (strlen (dispstr) > 4)) { ++ if ((strlen (dispstr) == 0) || (strlen (dispstr) > 10) || ++ (strlen (delaystr) == 0) || (strlen (delaystr) > 10)) { + printf ("accuracy unreadable\n"); + } + else { +- printf(" time correct to within %s ms\n",dispstr); ++ printf(" time correct to within %.0f ms\n", atof(dispstr) + atof(delaystr) / 2.0); + } + } else { + rc=1; diff --git a/SOURCES/ntpstat-0.2-multipacket.patch b/SOURCES/ntpstat-0.2-multipacket.patch new file mode 100644 index 0000000..ca21257 --- /dev/null +++ b/SOURCES/ntpstat-0.2-multipacket.patch @@ -0,0 +1,12 @@ +diff -up ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat ntp-4.2.4p7/ntpstat-0.2/ntpstat.c +--- ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat 2002-06-10 08:02:12.000000000 +0200 ++++ ntp-4.2.4p7/ntpstat-0.2/ntpstat.c 2009-07-20 12:22:35.000000000 +0200 +@@ -151,7 +151,7 @@ int main (void) { + /* For the reply message to be valid, the first byte should be as sent, + and the second byte should be the same, with the response bit set */ + byte1ok = ((ntpmsg.byte1&0x3F) == B1VAL); +- byte2ok = (ntpmsg.byte2 == (B2VAL|RMASK)); ++ byte2ok = ((ntpmsg.byte2 & ~MMASK) == (B2VAL|RMASK)); + if (!(byte1ok && byte2ok)) { + fprintf (stderr,"status word is 0x%02x%02x\n", ntpmsg.byte1,ntpmsg.byte2 ); + die ("return data appears to be invalid based on status word"); diff --git a/SOURCES/ntpstat-0.2-sysvars.patch b/SOURCES/ntpstat-0.2-sysvars.patch new file mode 100644 index 0000000..3f641a9 --- /dev/null +++ b/SOURCES/ntpstat-0.2-sysvars.patch @@ -0,0 +1,15 @@ +diff -up ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.sysvars ntp-4.2.6p1/ntpstat-0.2/ntpstat.c +--- ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.sysvars 2010-05-03 11:27:47.000000000 +0200 ++++ ntp-4.2.6p1/ntpstat-0.2/ntpstat.c 2010-05-03 11:32:56.000000000 +0200 +@@ -89,9 +89,9 @@ int main (void) { + "modem"}; /* 9 */ + char *newstr; + char *dispstr; +- const char DISP[] = "rootdispersion="; ++ const char DISP[] = "rootdisp="; + const char STRATUM[] = "stratum="; +- const char POLL[] = "poll="; ++ const char POLL[] = "tc="; + const char REFID[] = "refid="; + + /* initialise timeout value */ diff --git a/SOURCES/sntp.service b/SOURCES/sntp.service new file mode 100644 index 0000000..1722767 --- /dev/null +++ b/SOURCES/sntp.service @@ -0,0 +1,14 @@ +[Unit] +Description=Set time via SNTP +After=network-online.target nss-lookup.target +Before=time-sync.target +Wants=time-sync.target network-online.target + +[Service] +Type=oneshot +EnvironmentFile=/etc/sysconfig/sntp +ExecStart=/usr/sbin/sntp $OPTIONS +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/SOURCES/sntp.sysconfig b/SOURCES/sntp.sysconfig new file mode 100644 index 0000000..1bf1c01 --- /dev/null +++ b/SOURCES/sntp.sysconfig @@ -0,0 +1,2 @@ +# Options for sntp +OPTIONS="-s 0.VENDORZONE.pool.ntp.org" diff --git a/SPECS/ntp.spec b/SPECS/ntp.spec new file mode 100644 index 0000000..c706e7c --- /dev/null +++ b/SPECS/ntp.spec @@ -0,0 +1,1414 @@ +Summary: The NTP daemon and utilities +Name: ntp +Version: 4.2.6p5 +Release: 28%{?dist} +# primary license (COPYRIGHT) : MIT +# ElectricFence/ (not used) : GPLv2 +# kernel/sys/ppsclock.h (not used) : BSD with advertising +# include/ntif.h (not used) : BSD +# include/rsa_md5.h : BSD with advertising +# include/ntp_rfc2553.h : BSD with advertising +# lib/isc/commandline.c (not used) : BSD with advertising +# lib/isc/inet_aton.c (not used) : BSD with advertising +# lib/isc/strtoul.c (not used) : BSD with advertising +# lib/isc/unix/file.c : BSD with advertising +# lib/isc/inet_aton.c (not used) : BSD with advertising +# libntp/mktime.c : BSD with advertising +# libntp/ntp_random.c : BSD with advertising +# libntp/memmove.c : BSD with advertising +# libntp/ntp_rfc2553.c : BSD with advertising +# libntp/adjtimex.c (not used) : BSD +# libparse/ : BSD +# ntpd/refclock_jjy.c: MIT +# ntpd/refclock_oncore.c : BEERWARE License (aka, Public Domain) +# ntpd/refclock_palisade.c : BSD with advertising +# ntpd/refclock_jupiter.c : BSD with advertising +# ntpd/refclock_mx4200.c : BSD with advertising +# ntpd/refclock_palisade.h : BSD with advertising +# ntpstat-0.2/ : GPLv2 +# sntp/libopts/ (not used) : BSD or GPLv3+ +# util/ansi2knr.c (not used) : GPL+ +License: (MIT and BSD and BSD with advertising) and GPLv2 +Group: System Environment/Daemons +Source0: http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-%{version}.tar.gz +Source1: ntp.conf +Source2: ntp.keys +Source4: ntpd.sysconfig +# http://people.redhat.com/rkeech/#ntpstat +Source5: ntpstat-0.2.tgz +Source6: ntp.step-tickers +Source7: ntpdate.wrapper +Source8: ntp.cryptopw +Source9: ntpdate.sysconfig +Source10: ntp.dhclient +Source12: ntpd.service +Source13: ntpdate.service +Source14: ntp-wait.service +Source15: sntp.service +Source16: sntp.sysconfig + +# ntpbz #802 +Patch1: ntp-4.2.6p1-sleep.patch +# add support for dropping root to ntpdate +Patch2: ntp-4.2.6p4-droproot.patch +# ntpbz #779 +Patch3: ntp-4.2.6p3-bcast.patch +# align buffer for control messages +Patch4: ntp-4.2.6p1-cmsgalign.patch +# link ntpd with -ffast-math on ia64 +Patch5: ntp-4.2.6p1-linkfastmath.patch +# ntpbz #2294 +Patch6: ntp-4.2.6p5-fipsmd5.patch +# ntpbz #759 +Patch7: ntp-4.2.6p1-retcode.patch +# ntpbz #2085 +Patch8: ntp-4.2.6p5-rootdisp.patch +# ntpbz #2309 +Patch9: ntp-4.2.6p5-hexpw.patch +# ntpbz #898 +Patch10: ntp-4.2.6p4-htmldoc.patch +# ntpbz #1402 +Patch11: ntp-4.2.6p5-updatebclient.patch +# fix precision calculation on fast CPUs +Patch12: ntp-4.2.4p7-getprecision.patch +# ntpbz #1408 +Patch13: ntp-4.2.6p5-logdefault.patch +# add option -m to lock memory +Patch14: ntp-4.2.6p5-mlock.patch +# allow -u and -p options to be used twice (#639101) +Patch15: ntp-4.2.6p5-multiopts.patch +# ntpbz #2040 +Patch16: ntp-4.2.6p5-identlen.patch +# ntpbz #1670 +Patch17: ntp-4.2.6p3-broadcastdelay.patch +# ntpbz #1671 +Patch18: ntp-4.2.6p5-delaycalib.patch +# ntpbz #2019 +Patch19: ntp-4.2.6p5-pwcipher.patch +# ntpbz #2320 +Patch20: ntp-4.2.6p5-noservres.patch +# ntpbz #2506 +Patch21: ntp-4.2.6p5-refreshroute.patch +# ntpbz #2666 +Patch22: ntp-4.2.6p5-cve-2014-9294.patch +# ntpbz #2665 +Patch23: ntp-4.2.6p5-cve-2014-9293.patch +# ntpbz #2667 +Patch24: ntp-4.2.6p5-cve-2014-9295.patch +# ntpbz #2670 +Patch25: ntp-4.2.6p5-cve-2014-9296.patch +# ntpbz #2671 +Patch26: ntp-4.2.6p5-cve-2014-9297.patch +# ntpbz #2672 +Patch27: ntp-4.2.6p5-cve-2014-9298.patch +# ntpbz #2174 +Patch28: ntp-4.2.6p5-sourceport.patch +# ntpbz #2612 +Patch29: ntp-4.2.6p5-monwarn.patch +# ntpbz #1232 +Patch30: ntp-4.2.6p5-nanoshm.patch +# ntpbz #2661 +Patch32: ntp-4.2.6p5-mreadvar.patch +# ntpbz #730 +Patch33: ntp-4.2.6p5-rsaexp.patch +# ntpbz #2537 +Patch34: ntp-4.2.6p5-keylen.patch +# ntpbz #2627 +Patch35: ntp-4.2.6p5-shmperm.patch +# ntpbz #2745 +Patch36: ntp-4.2.6p5-xleap.patch +# ntpbz #2805 +Patch37: ntp-4.2.6p5-mcastjoin.patch +# ntpbz #2763, ntpbz #2811 +Patch38: ntp-4.2.6p5-backfwdstep.patch +# ntpbz #2779 +Patch39: ntp-4.2.6p5-cve-2015-1798.patch +# ntpbz #2781 +Patch40: ntp-4.2.6p5-cve-2015-1799.patch +# ntpbz #2797 +Patch41: ntp-4.2.6p5-cve-2015-3405.patch +# ntpbz #2837 +Patch42: ntp-4.2.6p5-dscp.patch +# ntpbz #2901 +Patch43: ntp-4.2.6p5-cve-2015-7704.patch +# allow only one step larger than panic threshold with -g +Patch44: ntp-4.2.6p5-cve-2015-5300.patch +# ntpbz #2246 +Patch45: ntp-4.2.6p5-leapreset.patch +# ntpbz #2081 +Patch46: ntp-4.2.6p5-rawstats.patch +# ntpbz #2639, #2880 +Patch47: ntp-4.2.6p5-clockstate.patch +# ntpbz #2851 +Patch48: ntp-4.2.6p5-restrict46.patch +# ntpbz #1593 +Patch49: ntp-4.2.6p5-cve-2015-5194.patch +# fix crash when referencing disabled statistic type +Patch50: ntp-4.2.6p5-cve-2015-5195.patch +# don't hang in sntp with crafted reply +Patch51: ntp-4.2.6p5-cve-2015-5219.patch +# ntpbz #2909 +Patch52: ntp-4.2.6p5-cve-2015-7701.patch +# ntpbz #2899 +Patch53: ntp-4.2.6p5-cve-2015-7691_7692_7702.patch +# ntpbz #2919 +Patch54: ntp-4.2.6p5-cve-2015-7852.patch +# ntpbz #2902 +Patch55: ntp-4.2.6p5-cve-2015-7703.patch +# ntpbz #2945 +Patch56: ntp-4.2.6p5-cve-2015-8138.patch +# ntpbz #2939, #2940 +Patch57: ntp-4.2.6p5-cve-2015-7977_7978.patch +# ntpbz #2948 +Patch58: ntp-4.2.6p5-cve-2015-8158.patch +# ntpbz #2936 +Patch59: ntp-4.2.6p5-cve-2015-7974.patch +# ntpbz #2942, ntpbz #3007 +Patch60: ntp-4.2.6p5-cve-2015-7979.patch +# ntpbz #2978 +Patch61: ntp-4.2.6p5-cve-2016-1548.patch +# ntpbz #3009 +Patch62: ntp-4.2.6p5-cve-2016-2518.patch +# ntpbz #2879 +Patch63: ntp-4.2.6p5-cve-2016-1550.patch +# ntpbz #3071 +Patch64: ntp-4.2.6p5-cve-2016-7426.patch +# ntpbz #3072 +Patch65: ntp-4.2.6p5-cve-2016-7429.patch +# ntpbz #3067 +Patch66: ntp-4.2.6p5-cve-2016-7433.patch +# ntpbz #3118 +Patch67: ntp-4.2.6p5-cve-2016-9310.patch +# ntpbz #3119 +Patch68: ntp-4.2.6p5-cve-2016-9311.patch +# ntpbz #3388 +Patch69: ntp-4.2.6p5-cve-2017-6462.patch +# ntpbz #3387 +Patch70: ntp-4.2.6p5-cve-2017-6463.patch +# ntpbz #3389 +Patch71: ntp-4.2.6p5-cve-2017-6464.patch +# add Spectracom TSYNC driver +Patch72: ntp-4.2.6p5-tsyncdriver.patch +# ntpbz #3434 +Patch73: ntp-4.2.6p5-staunsync.patch +# use SHA1 request key by default (#1442083) +Patch74: ntp-4.2.6p5-defreqkey.patch + +# handle unknown clock types +Patch100: ntpstat-0.2-clksrc.patch +# process first packet in multipacket response +Patch101: ntpstat-0.2-multipacket.patch +# use current system variable names +Patch102: ntpstat-0.2-sysvars.patch +# print synchronization distance instead of dispersion +Patch103: ntpstat-0.2-maxerror.patch +# fix error bit checking +Patch104: ntpstat-0.2-errorbit.patch +# improve man page +Patch105: ntpstat-0.2-manual.patch + +URL: http://www.ntp.org +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units +Requires: ntpdate = %{version}-%{release} +BuildRequires: libcap-devel openssl-devel libedit-devel perl-HTML-Parser +BuildRequires: pps-tools-devel autogen autogen-libopts-devel systemd-units +BuildRequires: bison + +%description +The Network Time Protocol (NTP) is used to synchronize a computer's +time with another reference time source. This package includes ntpd +(a daemon which continuously adjusts system time) and utilities used +to query and configure the ntpd daemon. + +Perl scripts ntp-wait and ntptrace are in the ntp-perl package, +ntpdate is in the ntpdate package and sntp is in the sntp package. +The documentation is in the ntp-doc package. + +%package perl +Summary: NTP utilities written in Perl +Group: Applications/System +Requires: %{name} = %{version}-%{release} +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units +# perl introduced in 4.2.4p4-7 +Obsoletes: %{name} < 4.2.4p4-7 +BuildArch: noarch +%description perl +This package contains Perl scripts ntp-wait and ntptrace. + +%package -n ntpdate +Summary: Utility to set the date and time via NTP +Group: Applications/System +Requires(pre): shadow-utils +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units + +%description -n ntpdate +ntpdate is a program for retrieving the date and time from +NTP servers. + +%package -n sntp +Summary: Standard Simple Network Time Protocol program +Group: Applications/System +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units + +%description -n sntp +sntp can be used as a SNTP client to query a NTP or SNTP server and either +display the time or set the local system's time (given suitable privilege). +It can be run as an interactive command or in a cron job. + +%package doc +Summary: NTP documentation +Group: Documentation +Requires: %{name} = %{version}-%{release} +BuildArch: noarch +%description doc +This package contains NTP documentation in HTML format. + +%global ntpdocdir %{_datadir}/doc/%{name}-%{version} + +# pool.ntp.org vendor zone which will be used in ntp.conf +%if 0%{!?vendorzone:1} +%{?fedora: %global vendorzone fedora.} +%{?rhel: %global vendorzone rhel.} +%endif + +%prep +%setup -q -a 5 + +%patch1 -p1 -b .sleep +%patch2 -p1 -b .droproot +%patch3 -p1 -b .bcast +%patch4 -p1 -b .cmsgalign +%ifarch ia64 +%patch5 -p1 -b .linkfastmath +%endif +%patch6 -p1 -b .fipsmd5 +%patch7 -p1 -b .retcode +%patch8 -p1 -b .rootdisp +%patch9 -p1 -b .hexpw +%patch10 -p1 -b .htmldoc +%patch11 -p1 -b .updatebclient +%patch12 -p1 -b .getprecision +%patch13 -p1 -b .logdefault +%patch14 -p1 -b .mlock +%patch15 -p1 -b .multiopts +%patch16 -p1 -b .identlen +%patch17 -p1 -b .broadcastdelay +%patch18 -p1 -b .delaycalib +%patch19 -p1 -b .pwcipher +%patch20 -p1 -b .noservres +%patch21 -p1 -b .refreshroute +%patch22 -p1 -b .cve-2014-9294 +%patch23 -p1 -b .cve-2014-9293 +%patch24 -p1 -b .cve-2014-9295 +%patch25 -p1 -b .cve-2014-9296 +%patch26 -p1 -b .cve-2014-9297 +%patch27 -p1 -b .cve-2014-9298 +%patch28 -p1 -b .sourceport +%patch29 -p1 -b .monwarn +%patch30 -p1 -b .nanoshm +%patch32 -p1 -b .mreadvar +%patch33 -p1 -b .rsaexp +%patch34 -p1 -b .keylen +%patch35 -p1 -b .shmperm +%patch36 -p1 -b .xleap +%patch37 -p1 -b .mcastjoin +%patch38 -p1 -b .backfwdstep +%patch39 -p1 -b .cve-2015-1798 +%patch40 -p1 -b .cve-2015-1799 +%patch41 -p1 -b .cve-2015-3405 +%patch42 -p1 -b .dscp +%patch43 -p1 -b .cve-2015-7704 +%patch44 -p1 -b .cve-2015-5300 +%patch45 -p1 -b .leapreset +%patch46 -p1 -b .rawstats +%patch47 -p1 -b .clockstate +%patch48 -p1 -b .restrict46 +%patch49 -p1 -b .cve-2015-5194 +%patch50 -p1 -b .cve-2015-5195 +%patch51 -p1 -b .cve-2015-5219 +%patch52 -p1 -b .cve-2015-7701 +%patch53 -p1 -b .cve-2015-7691_7692_7702 +%patch54 -p1 -b .cve-2015-7852 +%patch55 -p1 -b .cve-2015-7703 +%patch56 -p1 -b .cve-2015-8138 +%patch57 -p1 -b .cve-2015-7977_7978 +%patch58 -p1 -b .cve-2015-8158 +%patch59 -p1 -b .cve-2015-7974 +%patch60 -p1 -b .cve-2015-7979 +%patch61 -p1 -b .cve-2016-1548 +%patch62 -p1 -b .cve-2016-2518 +%patch63 -p1 -b .cve-2016-1550 +%patch64 -p1 -b .cve-2016-7426 +%patch65 -p1 -b .cve-2016-7429 +%patch66 -p1 -b .cve-2016-7433 +%patch67 -p1 -b .cve-2016-9310 +%patch68 -p1 -b .cve-2016-9311 +%patch69 -p1 -b .cve-2017-6462 +%patch70 -p1 -b .cve-2017-6463 +%patch71 -p1 -b .cve-2017-6464 +%patch72 -p1 -b .tsyncdriver +%patch73 -p1 -b .staunsync +%patch74 -p1 -b .defreqkey + +# ntpstat patches +%patch100 -p1 -b .clksrc +%patch101 -p1 -b .multipacket +%patch102 -p1 -b .sysvars +%patch103 -p1 -b .maxerror +%patch104 -p1 -b .errorbit +%patch105 -p1 -b .manual + +# set default path to sntp KoD database +sed -i 's|/var/db/ntp-kod|%{_localstatedir}/lib/sntp/kod|' sntp/{sntp.1,main.c} + +# fix line terminators +sed -i 's|\r||g' html/scripts/{footer.txt,style.css} + +for f in COPYRIGHT ChangeLog; do + iconv -f iso8859-1 -t utf8 -o ${f}{_,} && touch -r ${f}{,_} && mv -f ${f}{_,} +done + +# don't regenerate texinfo files as it breaks build with _smp_mflags +touch ntpd/ntpd-opts.texi util/ntp-keygen-opts.texi + +# autogen fails to regenerate man pages (#958908), but they won't be used anyway +touch ntpd/ntpd.1 util/ntp-keygen.1 + +# make the build fail if the parsers are not regenerated +rm ntpd/ntp_parser.{c,h} +echo > ntpd/ntp_keyword.h + +%build +sed -i 's|$CFLAGS -Wstrict-overflow|$CFLAGS|' configure sntp/configure +export CFLAGS="$RPM_OPT_FLAGS -fPIE -fno-strict-aliasing -fno-strict-overflow" +export LDFLAGS="-pie -Wl,-z,relro,-z,now" +%configure \ + --sysconfdir=%{_sysconfdir}/ntp/crypto \ + --with-openssl-libdir=%{_libdir} \ + --without-ntpsnmpd \ + --enable-all-clocks --enable-parse-clocks \ + --enable-ntp-signd=%{_localstatedir}/run/ntp_signd \ + --disable-local-libopts +echo '#define KEYFILE "%{_sysconfdir}/ntp/keys"' >> ntpdate/ntpdate.h +echo '#define NTP_VAR "%{_localstatedir}/log/ntpstats/"' >> config.h + +make -C ntpd ntp_keyword.h +make %{?_smp_mflags} + +sed -i 's|$ntpq = "ntpq"|$ntpq = "%{_sbindir}/ntpq"|' scripts/ntptrace +sed -i 's|ntpq -c |%{_sbindir}/ntpq -c |' scripts/ntp-wait + +pushd html +../scripts/html2man +# remove adjacent blank lines +sed -i 's/^[\t\ ]*$//;/./,/^$/!d' man/man*/*.[58] +popd + +make -C ntpstat-0.2 CFLAGS="$CFLAGS" + +%install +make DESTDIR=$RPM_BUILD_ROOT bindir=%{_sbindir} install + +mkdir -p $RPM_BUILD_ROOT%{_mandir}/man{5,8} +sed -i 's/sntp\.1/sntp\.8/' $RPM_BUILD_ROOT%{_mandir}/man1/sntp.1 +mv $RPM_BUILD_ROOT%{_mandir}/man{1/sntp.1,8/sntp.8} +rm -rf $RPM_BUILD_ROOT%{_mandir}/man1 + +pushd ntpstat-0.2 +mkdir -p $RPM_BUILD_ROOT%{_bindir} +install -m 755 ntpstat $RPM_BUILD_ROOT%{_bindir} +install -m 644 ntpstat.1 $RPM_BUILD_ROOT%{_mandir}/man8/ntpstat.8 +popd + +# fix section numbers +sed -i 's/\(\.TH[a-zA-Z ]*\)[1-9]\(.*\)/\18\2/' $RPM_BUILD_ROOT%{_mandir}/man8/*.8 +cp -r html/man/man[58] $RPM_BUILD_ROOT%{_mandir} + +mkdir -p $RPM_BUILD_ROOT%{ntpdocdir} +cp -p COPYRIGHT ChangeLog NEWS $RPM_BUILD_ROOT%{ntpdocdir} + +# prepare html documentation +find html | grep -E '\.(html|css|txt|jpg|gif)$' | grep -v '/build/\|sntp' | \ + cpio -pmd $RPM_BUILD_ROOT%{ntpdocdir} +find $RPM_BUILD_ROOT%{ntpdocdir} -type f | xargs chmod 644 +find $RPM_BUILD_ROOT%{ntpdocdir} -type d | xargs chmod 755 + +pushd $RPM_BUILD_ROOT +mkdir -p .%{_sysconfdir}/{ntp/crypto,sysconfig,dhcp/dhclient.d} .%{_libexecdir} +mkdir -p .%{_localstatedir}/{lib/{s,}ntp,log/ntpstats} .%{_unitdir} +touch .%{_localstatedir}/lib/{ntp/drift,sntp/kod} +sed -e 's|VENDORZONE\.|%{vendorzone}|' \ + -e 's|ETCNTP|%{_sysconfdir}/ntp|' \ + -e 's|VARNTP|%{_localstatedir}/lib/ntp|' \ + < %{SOURCE1} > .%{_sysconfdir}/ntp.conf +touch -r %{SOURCE1} .%{_sysconfdir}/ntp.conf +install -p -m600 %{SOURCE2} .%{_sysconfdir}/ntp/keys +install -p -m755 %{SOURCE7} .%{_libexecdir}/ntpdate-wrapper +install -p -m644 %{SOURCE4} .%{_sysconfdir}/sysconfig/ntpd +install -p -m644 %{SOURCE9} .%{_sysconfdir}/sysconfig/ntpdate +sed -e 's|VENDORZONE\.|%{vendorzone}|' \ + < %{SOURCE6} > .%{_sysconfdir}/ntp/step-tickers +touch -r %{SOURCE6} .%{_sysconfdir}/ntp/step-tickers +sed -e 's|VENDORZONE\.|%{vendorzone}|' \ + < %{SOURCE16} > .%{_sysconfdir}/sysconfig/sntp +touch -r %{SOURCE16} .%{_sysconfdir}/sysconfig/sntp +install -p -m600 %{SOURCE8} .%{_sysconfdir}/ntp/crypto/pw +install -p -m755 %{SOURCE10} .%{_sysconfdir}/dhcp/dhclient.d/ntp.sh +install -p -m644 %{SOURCE12} .%{_unitdir}/ntpd.service +install -p -m644 %{SOURCE13} .%{_unitdir}/ntpdate.service +install -p -m644 %{SOURCE14} .%{_unitdir}/ntp-wait.service +install -p -m644 %{SOURCE15} .%{_unitdir}/sntp.service + +mkdir .%{_prefix}/lib/systemd/ntp-units.d +echo 'ntpd.service' > .%{_prefix}/lib/systemd/ntp-units.d/60-ntpd.list + +popd + +%pre -n ntpdate +/usr/sbin/groupadd -g 38 ntp 2> /dev/null || : +/usr/sbin/useradd -u 38 -g 38 -s /sbin/nologin -M -r -d %{_sysconfdir}/ntp ntp 2>/dev/null || : + +%post +%systemd_post ntpd.service + +%post -n ntpdate +%systemd_post ntpdate.service + +%post -n sntp +%systemd_post sntp.service + +%post perl +%systemd_post ntp-wait.service + +%preun +%systemd_preun ntpd.service + +%preun -n ntpdate +%systemd_preun ntpdate.service + +%preun -n sntp +%systemd_preun sntp.service + +%preun perl +%systemd_preun ntp-wait.service + +%postun +%systemd_postun_with_restart ntpd.service + +%postun -n ntpdate +%systemd_postun + +%postun -n sntp +%systemd_postun + +%postun perl +%systemd_postun + +%files +%dir %{ntpdocdir} +%{ntpdocdir}/COPYRIGHT +%{ntpdocdir}/ChangeLog +%{ntpdocdir}/NEWS +%{_sbindir}/ntp-keygen +%{_sbindir}/ntpd +%{_sbindir}/ntpdc +%{_sbindir}/ntpq +%{_sbindir}/ntptime +%{_sbindir}/tickadj +%config(noreplace) %{_sysconfdir}/sysconfig/ntpd +%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/ntp.conf +%dir %attr(750,root,ntp) %{_sysconfdir}/ntp/crypto +%config(noreplace) %{_sysconfdir}/ntp/crypto/pw +%dir %{_sysconfdir}/dhcp/dhclient.d +%{_sysconfdir}/dhcp/dhclient.d/ntp.sh +%dir %attr(-,ntp,ntp) %{_localstatedir}/lib/ntp +%ghost %attr(644,ntp,ntp) %{_localstatedir}/lib/ntp/drift +%dir %attr(-,ntp,ntp) %{_localstatedir}/log/ntpstats +%{_bindir}/ntpstat +%{_mandir}/man5/*.5* +%{_mandir}/man8/ntp-keygen.8* +%{_mandir}/man8/ntpd.8* +%{_mandir}/man8/ntpdc.8* +%{_mandir}/man8/ntpq.8* +%{_mandir}/man8/ntpstat.8* +%{_mandir}/man8/ntptime.8* +%{_mandir}/man8/tickadj.8* +%{_prefix}/lib/systemd/ntp-units.d/*.list +%{_unitdir}/ntpd.service + +%files perl +%{_sbindir}/ntp-wait +%{_sbindir}/ntptrace +%{_mandir}/man8/ntp-wait.8* +%{_mandir}/man8/ntptrace.8* +%{_unitdir}/ntp-wait.service + +%files -n ntpdate +%doc COPYRIGHT +%config(noreplace) %{_sysconfdir}/sysconfig/ntpdate +%dir %{_sysconfdir}/ntp +%config(noreplace) %{_sysconfdir}/ntp/keys +%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/ntp/step-tickers +%{_libexecdir}/ntpdate-wrapper +%{_sbindir}/ntpdate +%{_mandir}/man8/ntpdate.8* +%{_unitdir}/ntpdate.service + +%files -n sntp +%doc sntp/COPYRIGHT +%config(noreplace) %{_sysconfdir}/sysconfig/sntp +%{_sbindir}/sntp +%{_mandir}/man8/sntp.8* +%dir %{_localstatedir}/lib/sntp +%ghost %{_localstatedir}/lib/sntp/kod +%{_unitdir}/sntp.service + +%files doc +%{ntpdocdir}/html + +%changelog +* Mon Oct 09 2017 Miroslav Lichvar 4.2.6p5-28 +- fix buffer overflow in datum refclock driver (CVE-2017-6462) +- fix crash with invalid unpeer command (CVE-2017-6463) +- fix potential crash with invalid server command (CVE-2017-6464) +- add Spectracom TSYNC driver (#1491797) +- fix initialization of system clock status (#1493452) +- fix typos in ntpd man page (#1420453) +- use SHA1 request key by default (#1442083) +- use network-online target in ntpdate and sntp services (#1466947) + +* Tue Feb 28 2017 Miroslav Lichvar 4.2.6p5-27 +- fix CVE-2016-7429 patch to work correctly on multicast client (#1422944) + +* Wed Jan 11 2017 Miroslav Lichvar 4.2.6p5-26 +- don't limit rate of packets from sources (CVE-2016-7426) +- don't change interface from received packets (CVE-2016-7429) +- fix calculation of root distance again (CVE-2016-7433) +- require authentication for trap commands (CVE-2016-9310) +- fix crash when reporting peer event to trappers (CVE-2016-9311) + +* Tue May 03 2016 Miroslav Lichvar 4.2.6p5-25 +- don't allow spoofed packet to enable symmetric interleaved mode + (CVE-2016-1548) +- check mode of new source in config command (CVE-2016-2518) +- make MAC check resilient against timing attack (CVE-2016-1550) + +* Tue Mar 15 2016 Miroslav Lichvar 4.2.6p5-24 +- fix crash with invalid logconfig command (CVE-2015-5194) +- fix crash when referencing disabled statistic type (CVE-2015-5195) +- don't hang in sntp with crafted reply (CVE-2015-5219) +- don't crash with crafted autokey packet (CVE-2015-7691, CVE-2015-7692, + CVE-2015-7702) +- fix memory leak with autokey (CVE-2015-7701) +- don't allow setting driftfile and pidfile remotely (CVE-2015-7703) +- don't crash in ntpq with crafted packet (CVE-2015-7852) +- check key ID in packets authenticated with symmetric key (CVE-2015-7974) +- fix crash with reslist command (CVE-2015-7977, CVE-2015-7978) +- don't allow spoofed packets to demobilize associations (CVE-2015-7979, + CVE-2016-1547) +- don't accept server/peer packets with zero origin timestamp (CVE-2015-8138) +- fix infinite loop in ntpq/ntpdc (CVE-2015-8158) +- fix resetting of leap status (#1242553) +- extend rawstats log (#1242877) +- report clock state changes related to leap seconds (#1242935) +- allow -4/-6 on restrict lines with mask (#1304492) +- explain synchronised state in ntpstat man page (#1309594) + +* Fri Oct 16 2015 Miroslav Lichvar 4.2.6p5-22 +- check origin timestamp before accepting KoD RATE packet (CVE-2015-7704) +- allow only one step larger than panic threshold with -g (CVE-2015-5300) + +* Thu Jun 04 2015 Miroslav Lichvar 4.2.6p5-20 +- validate lengths of values in extension fields (CVE-2014-9297) +- drop packets with spoofed source address ::1 (CVE-2014-9298) +- reject packets without MAC when authentication is enabled (CVE-2015-1798) +- protect symmetric associations with symmetric key against DoS attack (CVE-2015-1799) +- fix generation of MD5 keys with ntp-keygen on big-endian systems (CVE-2015-3405) +- add option to set Differentiated Services Code Point (DSCP) (#1202828) +- add nanosecond support to SHM refclock (#1117702) +- allow creating all SHM segments with owner-only access (#1122012) +- allow different thresholds for forward and backward step (#1193154) +- allow symmetric keys up to 32 bytes again (#1191111) +- don't step clock for leap second with -x option (#1191122) +- don't drop packets with source port below 123 (#1171640) +- retry joining multicast groups (#1207014) +- increase memlock limit again (#1053569) +- warn when monitor can't be disabled due to limited restrict (#1191108) +- use larger RSA exponent in ntp-keygen (#1191116) +- fix crash in ntpq mreadvar command (#1180721) +- move sntp kod database to allow SELinux labeling (#1082934) +- fix typos in ntpd man page (#1195211) +- improve documentation of restrict command (#1213953) + +* Fri Dec 19 2014 Miroslav Lichvar 4.2.6p5-19 +- don't generate weak control key for resolver (CVE-2014-9293) +- don't generate weak MD5 keys in ntp-keygen (CVE-2014-9294) +- fix buffer overflows via specially-crafted packets (CVE-2014-9295) +- don't mobilize passive association when authentication fails (CVE-2014-9296) + +* Tue Feb 11 2014 Miroslav Lichvar 4.2.6p5-18 +- disable monitor in default ntp.conf (#1047856) + +* Fri Jan 24 2014 Daniel Mach - 4.2.6p5-17 +- Mass rebuild 2014-01-24 + +* Fri Jan 03 2014 Miroslav Lichvar 4.2.6p5-16 +- refresh peers on routing updates (#1048132) +- fix calculation of root dispersion (#1045377) +- remove unnecessary IPv6 restrict line from default ntp.conf (#1048255) +- remove kod from default restrict in ntp.conf (#1048255) +- update logconfig documentation for patched default (#1048252) + +* Fri Dec 27 2013 Daniel Mach - 4.2.6p5-15 +- Mass rebuild 2013-12-27 + +* Fri Oct 04 2013 Miroslav Lichvar 4.2.6p5-14 +- remove ControlGroup in ntpd service (#999980) +- don't build ntpsnmpd (#1015435) + +* Mon Jul 15 2013 Miroslav Lichvar 4.2.6p5-13 +- ignore duplicate servers from dhclient +- don't use -Wstrict-overflow with -fno-strict-overflow +- buildrequire systemd-units +- remove pie test + +* Thu May 02 2013 Miroslav Lichvar 4.2.6p5-12 +- workaround failing autogen +- move files from /lib +- don't own ntp-units.d directory +- drop old systemd scriptlets +- fix dates in changelog + +* Tue Apr 02 2013 Miroslav Lichvar 4.2.6p5-11 +- avoid rereading /etc/services (#768804) +- remove ntp-wait dependency from ntpd service (#906753) +- add missing and remove unrecognized options in documentation +- update comments in some config files + +* Thu Feb 14 2013 Fedora Release Engineering - 4.2.6p5-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Fri Jan 04 2013 Miroslav Lichvar 4.2.6p5-9 +- compile with -fno-strict-overflow + +* Wed Dec 05 2012 Miroslav Lichvar 4.2.6p5-8 +- add option to set identity modulus size in ntp-keygen + +* Fri Nov 23 2012 Miroslav Lichvar 4.2.6p5-7 +- allow selection of cipher for private key files +- set identity modulus size in ntp-keygen +- create sntp subpackage +- add sntp service +- use system libopts +- add Wants=ntp-wait.service to ntpd service +- don't fail when /etc/sysconfig/ntpd is missing +- modify mlock and multiopts patches to use autogen +- make perl subpackage noarch + +* Tue Nov 20 2012 Miroslav Lichvar 4.2.6p5-6 +- bind broadcast client to new interfaces (#722690) +- decode hex encoded passwords in ntpq/ntpdc +- remove sample MD5 keys from default keys config + +* Wed Oct 24 2012 Miroslav Lichvar 4.2.6p5-5 +- fix crash in FIPS mode (#839280) +- use systemd macros if available (#850235) +- remove obsolete macros + +* Tue Aug 07 2012 Miroslav Lichvar 4.2.6p5-4 +- start ntpdate service after nss-lookup.target (#837486) +- update systemd-timedated integration (#846077) + +* Fri Jul 20 2012 Fedora Release Engineering - 4.2.6p5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Apr 27 2012 Miroslav Lichvar 4.2.6p5-2 +- update service file for systemd-timedated-ntp target (#816495) +- allow service to set realtime scheduler (#810801) +- drop comment enabling local driver in default config + +* Tue Feb 28 2012 Miroslav Lichvar 4.2.6p5-1 +- update to 4.2.6p5 +- switch service type to forking + +* Tue Feb 07 2012 Miroslav Lichvar 4.2.6p4-3 +- add default servers to step-tickers (#772389) +- enable PrivateTmp in ntpd service (#782520) + +* Fri Jan 13 2012 Fedora Release Engineering - 4.2.6p4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Thu Oct 06 2011 Miroslav Lichvar 4.2.6p4-1 +- update to 4.2.6p4 +- buildrequire pps-tools-devel +- fix errors in ntpstat found by coverity + +* Sun Aug 14 2011 Rex Dieter - 4.2.6p3-5.1 +- Rebuilt for rpm (#728707) + +* Wed Jul 20 2011 Miroslav Lichvar 4.2.6p3-5 +- drop SysV init scripts (#697526, #714705) +- add ntp-wait service + +* Fri May 06 2011 Bill Nottingham 4.2.6p3-4 +- fix systemd scriplets to properly handle upgrades + +* Wed Apr 06 2011 Miroslav Lichvar 4.2.6p3-3 +- pull in time-sync.target from ntpdate.service (Lennart Poettering) +- link with -Wl,-z,relro,-z,now options +- fix typo in ntpq man page (#664525) + +* Tue Feb 08 2011 Fedora Release Engineering - 4.2.6p3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Fri Jan 07 2011 Miroslav Lichvar 4.2.6p3-1 +- update to 4.2.6p3 + +* Thu Nov 25 2010 Miroslav Lichvar 4.2.6p3-0.1.rc10 +- update to 4.2.6p3-RC10 +- fix system peer unmarking when unreachable +- fix broadcastdelay option +- fix automatic broadcast delay calibration +- fix ntp-keygen -V crash +- avoid unnecessary timeout in ntpdate +- drop nano patch +- convert ChangeLog to UTF-8 + +* Fri Oct 01 2010 Miroslav Lichvar 4.2.6p2-7 +- allow -u and -p options to be used twice (#639101) + +* Wed Sep 29 2010 jkeating - 4.2.6p2-6 +- Rebuilt for gcc bug 634757 + +* Wed Sep 15 2010 Miroslav Lichvar 4.2.6p2-5 +- remove systemctl dependency for now +- suppress chkconfig output in %%post (#629285) +- generate ntp_decode(5) man page (#632300) + +* Fri Aug 27 2010 Miroslav Lichvar 4.2.6p2-4 +- fix default ntpdate sysconfig options (#445229) + +* Thu Aug 26 2010 Miroslav Lichvar 4.2.6p2-3 +- update ntpdate service (#627395) + +* Mon Aug 23 2010 Miroslav Lichvar 4.2.6p2-2 +- add support for systemd (#617328) +- retry few times in ntpdate init script before giving up (#445229) +- add fourth pool server to default ntp.conf and use iburst + +* Tue Jul 13 2010 Miroslav Lichvar 4.2.6p2-1 +- update to 4.2.6p2 +- add COPYRIGHT to ntpdate subpackage + +* Thu May 13 2010 Miroslav Lichvar 4.2.6p1-2 +- update ntpstat to use current system variable names (#588067) +- print synchronization distance instead of dispersion in ntpstat +- clarify ntpd -q description + +* Mon Apr 12 2010 Miroslav Lichvar 4.2.6p1-1 +- update to 4.2.6p1 + +* Fri Mar 19 2010 Miroslav Lichvar 4.2.6p1-0.1.rc5 +- update to 4.2.6p1-RC5 +- support NTPSERVERARGS variable in dhclient script (#558110) +- don't use deprecated egrep (#548182) +- don't verify ntp.conf (#481151) +- compile with PPS API support +- include new sntp + +* Wed Dec 09 2009 Miroslav Lichvar 4.2.4p8-1 +- update to 4.2.4p8 (#545557, CVE-2009-3563) + +* Wed Oct 21 2009 Miroslav Lichvar 4.2.4p7-7 +- add ntp-wait man page (#526161) +- fix init scripts (#527987) + +* Tue Sep 29 2009 Miroslav Lichvar 4.2.4p7-6 +- generate tickadj man page (#526161) +- fix precision calculation on fast CPUs + +* Fri Aug 21 2009 Tomas Mraz - 4.2.4p7-5 +- rebuilt with new openssl + +* Sat Jul 25 2009 Fedora Release Engineering - 4.2.4p7-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Tue Jul 21 2009 Miroslav Lichvar 4.2.4p7-3 +- handle system time jumps better +- don't wake up every second for refclocks without timer +- don't crash in ntpstat when unknown clock type is received (#505564) +- make ntpstat process first packet in multipacket response +- switch to editline +- set pool.ntp.org vendor zone in spec (#512711) +- compile with -fno-strict-aliasing + +* Thu May 28 2009 Miroslav Lichvar 4.2.4p7-2 +- fix frequency calculation when starting with no drift file +- reduce phase adjustments beyond Allan intercept in daemon PLL + +* Tue May 19 2009 Miroslav Lichvar 4.2.4p7-1 +- update to 4.2.4p7 (CVE-2009-1252) +- improve PLL response when kernel discipline is disabled +- don't log STA_MODE changes +- enable nanokernel support +- allow minpoll 3 +- increase memlock limit +- move html documentation to -doc subpackage (#492444) + +* Mon Apr 20 2009 Miroslav Lichvar 4.2.4p6-4 +- don't restart ntpd in dhclient script with every renewal +- fix buffer overflow in ntpq (#490617) +- check status in condrestart (#481261) +- don't crash when compiled with HAVE_TIMER_CREATE (#486217) + +* Wed Feb 25 2009 Fedora Release Engineering - 4.2.4p6-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Fri Jan 16 2009 Miroslav Lichvar 4.2.4p6-2 +- rebuild for new openssl + +* Wed Jan 14 2009 Miroslav Lichvar 4.2.4p6-1 +- update to 4.2.4p6 (CVE-2009-0021) +- include dhclient script (David Cantrell) +- convert COPYRIGHT to UTF-8 + +* Wed Oct 08 2008 Miroslav Lichvar 4.2.4p5-2 +- retry failed name resolution few times before giving up (#460561) +- don't write drift file upon exit +- run ntpq with full path in ntp-wait script + +* Fri Aug 29 2008 Miroslav Lichvar 4.2.4p5-1 +- update to 4.2.4p5 +- add support for fast interface updates + +* Mon Jul 28 2008 Miroslav Lichvar 4.2.4p4-7 +- reload resolv.conf after temporary failure in name resolution (#456743) +- use clock_gettime +- make subpackages for perl scripts and ntpdate (#452097, #456116) + +* Mon Apr 07 2008 Miroslav Lichvar 4.2.4p4-6 +- don't use /etc/sysconfig/clock in ntpdate init script + +* Mon Mar 10 2008 Miroslav Lichvar 4.2.4p4-5 +- fix building IPv6 support with new glibc-headers (#436713) +- avoid unaligned memory access (#435301) +- fix receiving broadcasts on 255.255.255.255 + +* Fri Feb 29 2008 Miroslav Lichvar 4.2.4p4-4 +- reset kernel frequency when -x option is used +- create separate init script for ntpdate +- add note about paths and exit codes to ntpd man page + +* Tue Feb 19 2008 Fedora Release Engineering - 4.2.4p4-3 +- Autorebuild for GCC 4.3 + +* Wed Dec 05 2007 Miroslav Lichvar 4.2.4p4-2 +- rebuild for openssl bump + +* Fri Oct 26 2007 Miroslav Lichvar 4.2.4p4-1 +- update to 4.2.4p4 +- fix default NTP version for outgoing packets in ntpdate man page + (#245408) +- replace BSD with advertising code in ntpdc and ntpq + +* Mon Sep 24 2007 Miroslav Lichvar 4.2.4p2-6 +- require perl (#274771) +- don't fail when starting with no interfaces (#300371) + +* Tue Aug 21 2007 Miroslav Lichvar 4.2.4p2-5 +- avoid use of uninitialized floating-point values in clock_select +- update license tag (Tom "spot" Callaway) +- drop sntp, MSNTP license is non-free + +* Mon Aug 13 2007 Miroslav Lichvar 4.2.4p2-4 +- allow loopback to share non-loopback address (#249226) +- require readline >= 5.2-3 (#250917) + +* Wed Jul 25 2007 Jesse Keating - 4.2.4p2-3 +- Rebuild for RH #249435 + +* Tue Jul 24 2007 Miroslav Lichvar 4.2.4p2-2 +- ignore tentative addresses (#246297) +- improve init script (#247003) +- fix sleep patch +- ease Autokey setup (#139673) + - change default keysdir to /etc/ntp/crypto + - set crypto password in /etc/ntp/crypto/pw + - don't use randfile if /dev/urandom is used by OpenSSL +- change default statsdir to /var/log/ntpstats/, use statistics type + as default filename +- package more doc files + +* Thu Jun 21 2007 Miroslav Lichvar 4.2.4p2-1 +- update to 4.2.4p2 + +* Tue May 22 2007 Miroslav Lichvar 4.2.4p0-3 +- fix interface updates with -I or -L option (#240254) +- accept multiple -I options +- fix broadcast client/server to accept/allow sending + broadcasts on 255.255.255.255 (#226958) +- fix return codes in init script (#240120) +- exit with nonzero code if ntpd -q did not set clock (#240134) +- drop revert452 patch, fixed in kernel 2.6.19 +- make with _smp_mflags + +* Wed May 09 2007 Miroslav Lichvar 4.2.4p0-2 +- compile with crypto support on 64bit architectures (#239576) +- update sleep patch + +* Wed Mar 07 2007 Miroslav Lichvar 4.2.4p0-1 +- update to 4.2.4p0 +- fix init script + - don't add second -g to ntpd options (#228424) + - update getopts + - skip all refclocks when parsing ntp.conf +- spec cleanup + +* Mon Jan 29 2007 Miroslav Lichvar 4.2.4-4 +- don't wake up every second (#204748) +- add option to enable memory locking (#195617) +- fix broadcast client +- use option values in ntp-keygen +- improve man pages + +* Tue Jan 23 2007 Miroslav Lichvar 4.2.4-3 +- disable autoopts option preset mechanisms for ntpd +- document -I option of ntpd +- generate makewhatis friendly man pages + +* Mon Jan 08 2007 Miroslav Lichvar 4.2.4-1 +- update to 4.2.4 (#146884) +- don't use local clock in default config +- autogenerate man pages from HTML +- clean up spec a bit + +* Wed Nov 22 2006 Miroslav Lichvar 4.2.2p4-2 +- pass additional options to ntpdate (#202204) + +* Tue Nov 21 2006 Miroslav Lichvar 4.2.2p4-1 +- update to 4.2.2p4 +- fix buffer overflow in WWV Audio driver (#216309) +- don't mark init script as config + +* Fri Aug 18 2006 Miroslav Lichvar 4.2.2p1-3 +- use adjtime when offset is more than 0.5s (#154625) + +* Mon Jul 24 2006 Miroslav Lichvar 4.2.2p1-2 +- link ntpd with -ffast-math on ia64 (#147980) + +* Tue Jul 18 2006 Miroslav Lichvar 4.2.2p1-1 +- update to 4.2.2p1 +- add more examples to ntp.conf + +* Thu Jul 06 2006 Miroslav Lichvar 4.2.2-3 +- fix manycast support in ntpdate (#194329) +- reply to manycast requests with null refid +- enable mlockall (#195617) +- correct threshold value in ntpdate manpage + +* Wed Jun 14 2006 Miroslav Lichvar 4.2.2-2 +- update initscript, ntp.conf, man pages +- package sntp + +* Mon Jun 12 2006 Miroslav Lichvar 4.2.2-1 +- update to ntp-4.2.2 +- drop drift file upgrade script +- use proper CFLAGS for ntpstat + +* Thu May 11 2006 Miroslav Lichvar - 4.2.0.a.20050816-14 +- modify ntp.conf, change default restrict, remove broadcastdelay, + use fedora.pool.ntp.org (#189667) +- don't install drift file +- remove unsupported options from ntptrace manpage (#137717) +- fix default paths in manpages for ntp-keygen and ntpdate + +* Fri Apr 07 2006 Miroslav Lichvar - 4.2.0.a.20050816-13 +- add option to sync hwclock after ntpdate (#179571) + +* Fri Mar 31 2006 Miroslav Lichvar - 4.2.0.a.20050816-12 +- fix initscript: + - replace -U with -u in getopts (#187003) + - don't pass group to ntpdate -U argument and ignore -i in options (#142926) + - set ntpconf for -c + - remove -p 8 from ntpdate arguments + - don't call ntpdate when step-tickers doesn't contain anything useful + and -x isn't in options +- fix default keyfile for ntpdate (#183196) + +* Thu Feb 23 2006 Miroslav Lichvar - 4.2.0.a.20050816-11 +- update man pages (#153195, #162856) +- drop C-Frame-121, vsnprintf, minusTi and loconly patch +- prevent segfault when loopback interface is not configured (#159056) +- spec cleanup + +* Fri Feb 10 2006 Jesse Keating - 4.2.0.a.20050816-10.2.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 4.2.0.a.20050816-10.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Wed Nov 9 2005 Petr Raszyk 4.2.0.a.20050816-10 +- ntpd does not submit his local clock (if there is no peer). + ntpdate->ntpd #163862 , Patch13: ntp-stable-4.2.0a-20050816-loconly.patch + +* Wed Nov 2 2005 Petr Raszyk 4.2.0.a.20050816-9 +- Wrong parameter -T -i +- Patch ntp-stable-4.2.0a-20050816-minusTi.patch + +* Mon Oct 31 2005 Petr Raszyk 4.2.0.a.20050816-3 +- A similar patch as ntp-4.0.99j-vsnprintf.patch in FEDORA CORE 4 +- (current patch is ntp-stable-4.2.0a-20050816-vsnprintf.patch) + +* Tue Sep 27 2005 Petr Raszyk 4.2.0.a.20050816-2 +- Fix fails on upgrade, if ntpd is disabled (#166773) +- A cosmetic patch. There are some comments and braces '{' '}' added. +- One unprintable character was converted to octal-form . +- It can be removed anytime (conversion of the cvs-projets for C-Frame 121, +- (auto-debug, auto-trace for cfr-printnet server). + +* Thu Aug 25 2005 Jindrich Novy 4.2.0.a.20050816-1 +- update to the latest stable 4.2.0.a.20050816 +- drop upstreamed .gcc4, .vsnprintf patches +- remove obsolete .autofoo patch +- make patch numbering less chaotic +- don't package backup for .droproot patch + +* Thu Apr 14 2005 Jiri Ryska 4.2.0.a.20040617-8 +- fixed gid setting when ntpd started with -u flag (#147743) + +* Tue Mar 08 2005 Jiri Ryska 4.2.0.a.20040617-7 +- removed -Werror +- patched for gcc4 and rebuilt + +* Wed Jan 12 2005 Tim Waugh - 4.2.0.a.20040617-6 +- Rebuilt for new readline. + +* Mon Dec 13 2004 Harald Hoyer - 4.2.0.a.20040617-5 +- patched ntp to build with -D_FORTIFYSOURCE=2 -Wall -Wextra -Werror + +* Mon Oct 11 2004 Harald Hoyer - 4.2.0.a.20040617-4 +- removed firewall hole punching from the initscript; rely on iptables + ESTABLISHED,RELATED or manual firewall configuration + +* Fri Oct 8 2004 Harald Hoyer - 4.2.0.a.20040617-3 +- improved postsection +- BuildRequires readline-devel +- PreReq grep + +* Thu Sep 30 2004 Harald Hoyer - 4.2.0.a.20040617-2 +- set pool.ntp.org as the default timeserver pool + +* Mon Sep 13 2004 Harald Hoyer - 4.2.0.a.20040617-1 +- version ntp-stable-4.2.0a-20040617 + +* Tue Aug 17 2004 Harald Hoyer - 4.2.0.a.20040616-4 +- added ntp-4.2.0-sbinpath.patch (bug 130536) + +* Tue Aug 17 2004 Harald Hoyer - 4.2.0.a.20040616-3 +- added ntp-stable-4.2.0a-20040616-groups.patch (bug 130112) + +* Thu Jul 29 2004 Harald Hoyer - 4.2.0.a.20040616-2 +- take chroot in account (bug 127252) + +* Fri Jul 23 2004 Harald Hoyer - 4.2.0.a.20040616-1 +- new version ntp-stable-4.2.0a-20040616 +- removed most patches + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Thu Mar 11 2004 Harald Hoyer - 4.2.0-7 +- ntpgenkey fixed (117378) +- fixed initscript to call ntpdate with -U (117894) + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Wed Jan 28 2004 Harald Hoyer - 4.2.0-5 +- readded ntp-wait and ntptrace +- new filter-requires to prevent perl dependency + +* Mon Jan 26 2004 Harald Hoyer 4.2.0-4 +- added autofoo patch + +* Tue Oct 28 2003 Harald Hoyer 4.2.0-3 +- removed libmd5 dependency +- removed perl dependency + +* Tue Oct 28 2003 Harald Hoyer 4.2.0-2 +- fixed initscript to use new FW chain name + +* Mon Oct 27 2003 Harald Hoyer 4.2.0-1 +- 4.2.0 +- added PIE + +* Thu Sep 11 2003 Harald Hoyer 4.1.2-4 +- changed ntp.conf driftfile path #104207 + +* Fri Aug 29 2003 Florian La Roche +- also build as non-root + +* Thu Aug 28 2003 Harald Hoyer 0:4.1.2-2 +- added ntpstat +- added manpages + +* Tue Jul 01 2003 Harald Hoyer 0:4.1.2-1.rc3.5 +- move driftfile to /var + +* Tue Jul 01 2003 Harald Hoyer 0:4.1.2-1.rc3.4 +- make a seperate directory for drift +- security fix, patch ntp-4.1.1c-rc3-authkey.patch #96927 + +* Wed Jun 18 2003 Harald Hoyer 0:4.1.2-1.rc3.3 +- %%{_sysconfdir}/ntp/drift.TEMP needs to be writable by ntp #97754 +- no duplicate fw entries #97624 + +* Wed Jun 18 2003 Harald Hoyer 0:4.1.2-1.rc3.2 +- changed permissions of config files + +* Tue Jun 17 2003 Harald Hoyer 0:4.1.2-1.rc3.1 +- updated to rc3 + +* Wed Jun 04 2003 Elliot Lee +- rebuilt + +* Thu May 22 2003 Harald Hoyer 0:4.1.2-0.rc2.2 +- corrected pid file name in %%{_sysconfdir}/sysconfig/ntpd + +* Mon Apr 28 2003 Harald Hoyer 0:4.1.2-0.rc2.1 +- update to 4.1.1rc2 + +* Tue Feb 25 2003 Harald Hoyer 0:4.1.2-0.rc1.3 +- better awk for timeservers #85090, #82713, #82714 + +* Thu Feb 13 2003 Harald Hoyer 0:4.1.2-0.rc1.2 +- added loopfilter patch, -x should work now! +- removed slew warning + +* Mon Feb 10 2003 Harald Hoyer 1:4.1.1-2 +- ok, messed up with the versions... added epoch :( + +* Fri Feb 07 2003 Harald Hoyer 4.1.1-1 +- going back to stable 4.1.1 with the limit patch +- added limit patch +- added slew warning + +* Thu Jan 30 2003 Harald Hoyer 4.1.73-2 +- removed exit on ntpdate fail, better add '-g' option + +* Wed Jan 29 2003 Harald Hoyer 4.1.73-1 +- update to version 4.1.73 +- removed most of the patches +- limit ntp_adjtime parameters + +* Wed Jan 22 2003 Tim Powers +- rebuilt + +* Wed Nov 20 2002 Harald Hoyer 4.1.1b-1 +- updated to version 4.1.1b +- improved initscript - use ntpdate on -x +- improved initscript - open firewall only for timeservers +- ntp-4.1.1a-adjtime.patch removed (already in source) +- ntp-4.1.1a-mfp.patch removed (already in source) +- ntp-4.0.99j-vsnprintf.patch removed (already in source) + +* Tue Nov 19 2002 Harald Hoyer 4.1.1a-12 +- added adjtime patch #75558 + +* Wed Nov 13 2002 Harald Hoyer +- more ntpd.init service description #77715 + +* Mon Nov 11 2002 Harald Hoyer +- ntp-4.1.1a-mfp.patch fixes #77086 + +* Sat Aug 31 2002 Florian La Roche +- add option -n to initscript to avoid DNS lookups #72756 + +* Fri Aug 23 2002 Jeremy Katz +- service should fail to start ntpd if running ntpdate fails + +* Tue Aug 20 2002 Harald Hoyer +- added two more 'echo's in the initscript + +* Thu Aug 15 2002 Harald Hoyer +- added firewall opener in initscript + +* Tue Jul 23 2002 Harald Hoyer +- removed libelf dependency +- removed stripping + +* Fri Jun 21 2002 Tim Powers +- automated rebuild + +* Tue Jun 11 2002 Harald Hoyer 4.1.1a-3 +- refixed #46464 +- another genkeys/snprintf bugfix + +* Wed May 22 2002 Harald Hoyer 4.1.1a-1 +- update to version 4.1.1a + +* Mon Apr 08 2002 Harald Hoyer 4.1.1-1 +- update to 4.1.1 (changes are minimal) +- more examples in default configuration + +* Tue Apr 02 2002 Harald Hoyer 4.1.0b-6 +- more secure default configuration (#62238) + +* Mon Jan 28 2002 Harald Hoyer 4.1.0b-5 +- more regex magic for the grep (#57837) + +* Mon Jan 28 2002 Harald Hoyer 4.1.0b-4 +- created drift with dummy value #58294 +- grep for timeservers in ntp.conf also for ntpdate #57837 +- check return value of ntpdate #58836 + +* Wed Jan 09 2002 Tim Powers 4.1.0b-3 +- automated rebuild + +* Tue Jan 08 2002 Harald Hoyer 4.1.0b-2 +- added --enable-all-clocks --enable-parse-clocks (#57761) + +* Thu Dec 13 2001 Harald Hoyer 4.1.0b-1 +- bumped version +- fixed #57391, #44580 +- set startup position to 58 after named + +* Wed Sep 05 2001 Harald Hoyer 4.1.0-4 +- fixed #53184 + +* Tue Sep 04 2001 Harald Hoyer 4.1.0-3 +- fixed #53089 /bin/nologin -> /sbin/nologin + +* Fri Aug 31 2001 Harald Hoyer 4.1.0-2 +- fixed #50247 thx to + +* Thu Aug 30 2001 Harald Hoyer 4.1.0-1 +- wow, how stupid can a man be ;).. fixed #50698 +- updated to 4.1.0 (changes are small and in non-critical regions) + +* Wed Aug 29 2001 Harald Hoyer 4.0.99mrc2-5 +- really, really :) fixed #52763, #50698 and #50526 + +* Mon Aug 27 2001 Tim Powers 4.0.99mrc2-4 +- rebuilt against newer libcap +- Copyright -> license + +* Wed Jul 25 2001 Harald Hoyer 4.0.99mrc2-3 +- integrated droproot patch (#35653) +- removed librt and libreadline dependency + +* Sat Jul 7 2001 Tim Powers +- don't build build sgid root dirs + +* Mon Jun 18 2001 Harald Hoyer +- new snapshot +- removed typos and security patch (already there) +- commented multicastclient in config file + +* Thu Jun 07 2001 Florian La Roche +- call libtoolize to compile on newer archs + +* Mon Apr 9 2001 Preston Brown +- remove ghost files make RHN happy +- modify initscript to match accordingly + +* Fri Apr 6 2001 Pekka Savola +- Add the remote root exploit patch (based on ntp-hackers). +- Enhance droproot patch (more documentation, etc.) +- Tweak the droproot patch to include sys/prctl.h, not linux/prctl.h +(implicit declarations) +- Remote groupdel commands, shouldn't be needed. +- Removed -Wcast-qual and -Wconversion due to excessive warnings (hackish). +- Make ntp compilable with both glibc 2.1 and 2.2.x (very dirty hack) +- Add %%{_sysconfdir}/sysconfig/ntpd which drops root privs by default + +* Thu Apr 5 2001 Preston Brown +- security patch for ntpd + +* Mon Mar 26 2001 Preston Brown +- don't run configure macro twice (#32804) + +* Sun Mar 25 2001 Pekka Savola +- require/buildprereq libcap/libcap-devel +- use 'ntp' user, tune the pre/post scripts, %%files +- add $OPTIONS to the init script + +* Tue Mar 20 2001 Jarno Huuskonen +- droproot/caps patch +- add ntpd user in pre +- make %%{_sysconfdir}/ntp ntpd writable + +* Mon Mar 5 2001 Preston Brown +- allow comments in %%{_sysconfdir}/ntp/step-tickers file (#28786). +- need patch0 (glibc patch) on ia64 too + +* Tue Feb 13 2001 Florian La Roche +- also set prog=ntpd in initscript + +* Tue Feb 13 2001 Florian La Roche +- use "$prog" instead of "$0" for the init script + +* Thu Feb 8 2001 Preston Brown +- i18n-neutral .init script (#26525) + +* Tue Feb 6 2001 Preston Brown +- use gethostbyname on addresses in %%{_sysconfdir}/ntp.conf for ntptime command (#26250) + +* Mon Feb 5 2001 Preston Brown +- start earlier and stop later (#23530) + +* Mon Feb 5 2001 Bernhard Rosenkraenzer +- i18nize init script (#26078) + +* Sat Jan 6 2001 Jeff Johnson +- typo in ntp.conf (#23173). + +* Mon Dec 11 2000 Karsten Hopp +- rebuilt to fix permissions of /usr/share/doc/ntp-xxx + +* Thu Nov 2 2000 Jeff Johnson +- correct mis-spellings in ntpq.htm (#20007). + +* Thu Oct 19 2000 Jeff Johnson +- add %%ghost %%{_sysconfdir}/ntp/drift (#15222). + +* Wed Oct 18 2000 Jeff Johnson +- comment out default values for keys, warn about starting with -A (#19316). +- take out -A from ntpd startup as well. +- update to 4.0.99k. + +* Wed Aug 23 2000 Jeff Johnson +- use vsnprintf rather than vsprintf (#16676). + +* Mon Aug 14 2000 Jeff Johnson +- remove Conflicts: so that the installer is happy. + +* Tue Jul 25 2000 Jeff Johnson +- workaround glibc-2.1.90 lossage for now. + +* Thu Jul 20 2000 Bill Nottingham +- move initscript back + +* Wed Jul 12 2000 Prospector +- automatic rebuild + +* Mon Jun 26 2000 Preston Brown +- move and update init script, update post/preun/postun scripts + +* Wed Jun 21 2000 Preston Brown +- noreplace ntp.conf,keys files + +* Mon Jun 12 2000 Jeff Johnson +- Create 4.0.99j package. +- FHS packaging.