Date: Sun, 22 Dec 2019 17:58:00 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356014 - stable/12/libexec/rc/rc.d Message-ID: <201912221758.xBMHw0Cn079879@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Sun Dec 22 17:57:59 2019 New Revision: 356014 URL: https://svnweb.freebsd.org/changeset/base/356014 Log: MFC r355100: Allow opt-out of automatic ntpd leapfile checking/fetching. When a system has no internet connection, or when it is configured to obtain ntpd leapfiles from some source other than the internet, or even when the sysadmin has decided for some reason to customize ntp.conf to eliminate use of the leapfile, the rc.d/ntpd script emits various error messages related to the file. This change allows setting the rc var ntp_db_leapfile to NONE to disable all automatic processing related to that file in rc.d/ntpd. Differential Revision: https://reviews.freebsd.org/D22461 Modified: stable/12/libexec/rc/rc.d/ntpd Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.d/ntpd ============================================================================== --- stable/12/libexec/rc/rc.d/ntpd Sun Dec 22 17:15:48 2019 (r356013) +++ stable/12/libexec/rc/rc.d/ntpd Sun Dec 22 17:57:59 2019 (r356014) @@ -28,6 +28,16 @@ pidfile="${_ntp_default_dir}/${name}.pid" load_rc_config $name +leapfile_is_disabled() { + # Return true (0) if automatic leapfile handling is disabled. + case "$ntp_db_leapfile" in + [Nn][Oo] | [Nn][Oo][Nn][Ee] ) + return 0;; + * ) + return 1;; + esac +} + can_run_nonroot() { # If the admin set what uid to use, we don't change it. @@ -107,7 +117,12 @@ ntpd_precmd() command_args="${command_args} -g" fi - # Make sure the leapfile is ready to use. + # Make sure the leapfile is ready to use, unless leapfile + # handling is disabled. + if leapfile_is_disabled; then + return + fi + ntpd_init_leapfile if [ ! -f "${ntp_db_leapfile}" ]; then ntpd_fetch_leapfile @@ -135,6 +150,11 @@ get_ntp_leapfile_expiry() { } ntpd_init_leapfile() { + + if leapfile_is_disabled; then + return + fi + # 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 @@ -146,7 +166,12 @@ ntpd_init_leapfile() { ntpd_needfetch_leapfile() { local rc verbose - + + if leapfile_is_disabled; then + # Return code 1: ntp leapfile fetch not needed + return 1 + fi + if checkyesno ntp_leapfile_fetch_verbose; then verbose=echo else @@ -182,6 +207,11 @@ ntpd_needfetch_leapfile() { } ntpd_fetch_leapfile() { + + if leapfile_is_disabled; then + return + fi + if checkyesno ntp_leapfile_fetch_verbose; then verbose=echo else
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912221758.xBMHw0Cn079879>