From a4efd6824a92258f46903c886e89e1b342169570 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 4 Jul 2018 14:12:09 +0000 Subject: [PATCH] MFC r335575, r335786 r335575: Use 'mv -f' in rc.d/ntpd to avoid spuriously halting the boot. The final 'mv' to install a fetched leap-list file can fail (due to a readonly fs, or schg flags, for example), and that leads to mv(1) prompting the user, stopping the boot process. Instead, use mv -f to supress the prompting, and if verbose mode is on, emit a warning that the existing file cannot be replaced. PR: 219255 r335786: Rename variable ntp_tmp_leapfile to have a leading underbar, to distinguish it from variables with similar names which are set in rc.conf. This will make more sense as the script grows more similar-name local variables in some upcoming changes. git-svn-id: svn://svn.freebsd.org/base/stable/10@335952 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- etc/rc.d/ntpd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/etc/rc.d/ntpd b/etc/rc.d/ntpd index a79252be7..2005276b4 100755 --- a/etc/rc.d/ntpd +++ b/etc/rc.d/ntpd @@ -18,7 +18,7 @@ extra_commands="fetch" fetch_cmd="ntpd_fetch_leapfile" start_precmd="ntpd_precmd" -ntp_tmp_leapfile="/var/run/ntpd.leap-seconds.list" +_ntp_tmp_leapfile="/var/run/ntpd.leap-seconds.list" load_rc_config $name @@ -54,7 +54,7 @@ ntpd_precmd() ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" ) fi ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift - ln -fs "${ntpd_chrootdir}${ntp_tmp_leapfile}" ${ntp_tmp_leapfile} + ln -fs "${ntpd_chrootdir}${_ntp_tmp_leapfile}" ${_ntp_tmp_leapfile} # Change run_rc_commands()'s internal copy of $ntpd_flags # @@ -123,15 +123,16 @@ ntpd_fetch_leapfile() { $verbose Within ntp leapfile expiry limit, initiating fetch for url in $ntp_leapfile_sources ; do $verbose fetching $url - fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break + 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) + 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_expiry_db" -o \ "$ntp_expiry_tmp" -eq "$ntp_expiry_db" -a \ "$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" ]; then $verbose using $url as $ntp_db_leapfile - mv $ntp_tmp_leapfile $ntp_db_leapfile + mv -f $_ntp_tmp_leapfile $ntp_db_leapfile || + $verbose "warning: cannot replace $ntp_db_leapfile (read-only fs?)" else $verbose using existing $ntp_db_leapfile fi -- 2.42.0