svn commit: r304879 - in stable: 10/etc/ntp 10/etc/rc.d 11/etc/ntp 11/etc/rc.d 9/etc/ntp 9/etc/rc.d
Cy Schubert
cy at FreeBSD.org
Sat Aug 27 02:53:23 UTC 2016
Author: cy
Date: Sat Aug 27 02:53:21 2016
New Revision: 304879
URL: https://svnweb.freebsd.org/changeset/base/304879
Log:
MFC r304779, r304780, r304781, r304782, r304802
r304779:
Revert r298887 (spelling fix) and remove $FreeBSD$ because text changes
to leap-seconds invaldidates validation hash at the end of the file.
Remove svn:keywords and replace with fbsd:nokeywords=yes to
support this change.
r304780:
Change the algorithm by which /var/db/leap-seconds is updated.
1. Use the leap-seconds version number (update time) to determine
whether to update the file or not.
2. If the version numbers of the files is the same, use the later
expiry date to determine which file to use.
Suggested by: ian@
r304781:
Add logic to replace the working ntp leap-seconds file in /var/db
if it contains a $FreeBSD$ header. The header will cause the file
to fail checksum of the hash causing ntpd to ignore the file.
r304782:
Make validation of the leap-seconds file unconditional.
r304802:
Remove the gratuitous check for $FreeBSD$ and rename the function
to ntpd_init_leapfile, to ensure a copy exists in /var/db if a copy
isn't already there.
Reported by: ache@
Modified:
stable/9/etc/ntp/leap-seconds (contents, props changed)
stable/9/etc/rc.d/ntpd
Directory Properties:
stable/9/etc/ (props changed)
stable/9/etc/rc.d/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/10/etc/ntp/leap-seconds (contents, props changed)
stable/10/etc/rc.d/ntpd
stable/11/etc/ntp/leap-seconds (contents, props changed)
stable/11/etc/rc.d/ntpd
Directory Properties:
stable/10/ (props changed)
stable/11/ (props changed)
Modified: stable/9/etc/ntp/leap-seconds
==============================================================================
--- stable/9/etc/ntp/leap-seconds Sat Aug 27 02:27:29 2016 (r304878)
+++ stable/9/etc/ntp/leap-seconds Sat Aug 27 02:53:21 2016 (r304879)
@@ -1,6 +1,4 @@
#
-# $FreeBSD$
-#
# In the following text, the symbol '#' introduces
# a comment, which continues from that symbol until
# the end of the line. A plain comment line has a
Modified: stable/9/etc/rc.d/ntpd
==============================================================================
--- stable/9/etc/rc.d/ntpd Sat Aug 27 02:27:29 2016 (r304878)
+++ stable/9/etc/rc.d/ntpd Sat Aug 27 02:53:21 2016 (r304879)
@@ -28,6 +28,8 @@ ntpd_precmd()
rc_flags="-g $rc_flags"
fi
+ ntpd_init_leapfile
+
if [ ! -f $ntp_db_leapfile ]; then
ntpd_fetch_leapfile
fi
@@ -66,15 +68,27 @@ current_ntp_ts() {
}
get_ntp_leapfile_ver() {
+ # Leapfile update date (version number).
expr "$(awk '$1 == "#$" { print $2 }' "$1" 2>/dev/null)" : \
'^\([1-9][0-9]*\)$' \| 0
}
get_ntp_leapfile_expiry() {
+ # Leapfile expiry date.
expr "$(awk '$1 == "#@" { print $2 }' "$1" 2>/dev/null)" : \
'^\([1-9][0-9]*\)$' \| 0
}
+ntpd_init_leapfile() {
+ # Refresh working leapfile with an invalid hash due to
+ # FreeBSD id header. Ntpd will ignore leapfiles with a
+ # mismatch hash. The file must be the virgin file from
+ # the source.
+ if [ ! -f $ntp_db_leapfile ]; then
+ cp -p $ntp_src_leapfile $ntp_db_leapfile
+ fi
+}
+
ntpd_fetch_leapfile() {
local ntp_tmp_leapfile rc verbose
@@ -87,19 +101,23 @@ ntpd_fetch_leapfile() {
ntp_tmp_leapfile="/var/run/ntpd.leap-seconds.list"
ntp_ver_no_src=$(get_ntp_leapfile_ver $ntp_src_leapfile)
+ ntp_expiry_src=$(get_ntp_leapfile_expiry $ntp_src_leapfile)
ntp_ver_no_db=$(get_ntp_leapfile_ver $ntp_db_leapfile)
+ ntp_expiry_db=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
$verbose ntp_src_leapfile version is $ntp_ver_no_src
$verbose ntp_db_leapfile version is $ntp_ver_no_db
- if [ "$ntp_ver_no_src" -gt "$ntp_ver_no_db" ]; then
+ if [ "$ntp_ver_no_src" -gt "$ntp_ver_no_db" -o \
+ "$ntp_ver_no_src" -eq "$ntp_ver_no_db" -a \
+ "$ntp_expiry_src" -gt "$ntp_expiry_db" ]; then
$verbose replacing $ntp_db_leapfile with $ntp_src_leapfile
cp -p $ntp_src_leapfile $ntp_db_leapfile
ntp_ver_no_db=$ntp_ver_no_src
else
$verbose not replacing $ntp_db_leapfile with $ntp_src_leapfile
fi
- ntp_leap_expiry=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
ntp_leapfile_expiry_seconds=$((ntp_leapfile_expiry_days*86400))
+ ntp_leap_expiry=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds))
if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then
$verbose Within ntp leapfile expiry limit, initiating fetch
@@ -107,8 +125,11 @@ ntpd_fetch_leapfile() {
$verbose fetching $url
fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break
done
+ ntp_ver_no_tmp=$(get_ntp_leapfile_ver $ntp_tmp_leapfile)
ntp_expiry_tmp=$(get_ntp_leapfile_expiry $ntp_tmp_leapfile)
- if [ "$ntp_expiry_tmp" -gt "$ntp_leap_expiry" ]; then
+ if [ "$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" -o \
+ "$ntp_ver_no_tmp" -eq "$ntp_ver_no_db" -a \
+ "$ntp_expiry_tmp" -gt "$ntp_expiry_db" ]; then
$verbose using $url as $ntp_db_leapfile
mv $ntp_tmp_leapfile $ntp_db_leapfile
else
More information about the svn-src-stable-9
mailing list