svn commit: r348141 - head/libexec/rc/rc.d

Ian Lepore ian at FreeBSD.org
Thu May 23 01:41:51 UTC 2019


Author: ian
Date: Thu May 23 01:41:49 2019
New Revision: 348141
URL: https://svnweb.freebsd.org/changeset/base/348141

Log:
  Handle the driftfile option correctly when ntpd_flags is empty.
  
  The logic I originally wrote to detect whether a driftfile option was in the
  set of flags was based on the result of removing the pattern *flag* being an
  empty string.  That didn't handle the case where the string was empty to
  begin with.  Doh!  So now it also specifically checks for an empty string.
  
  The result of the bad check was that ntpd would run without a driftfile, but
  it would do so only if it was running as root instead of the non-priveleged
  ntpd user, which isn't a typical case.  Ntpd runs fine without a driftfile,
  although it does take it longer to stabilize the clock frequency at startup.
  
  Reported by:	avg@
  Pointy hat:	ian@
  MFC after:	some testing

Modified:
  head/libexec/rc/rc.d/ntpd

Modified: head/libexec/rc/rc.d/ntpd
==============================================================================
--- head/libexec/rc/rc.d/ntpd	Thu May 23 01:25:34 2019	(r348140)
+++ head/libexec/rc/rc.d/ntpd	Thu May 23 01:41:49 2019	(r348141)
@@ -87,12 +87,14 @@ ntpd_precmd()
 	# Otherwise, figure out what to do about the driftfile option.  If set
 	# by the admin, we don't add the option.  If the file exists in the old
 	# default location we use that, else we use the new default location.
+
 	if can_run_nonroot; then
 		_user="ntpd"
 		driftopt="-f ${_ntp_default_driftfile}"
-	elif [ -z "${rc_flags##*-f*}" ] ||
-	     [ -z "${rc_flags##*--driftfile*}" ] ||
-	     grep -q "^[ \t]*driftfile" "${ntpd_config}"; then
+	elif grep -q "^[ \t]*driftfile" "${ntpd_config}" ||
+	     [ -n "${rc_flags}" ] &&
+	     ( [ -z "${rc_flags##*-f*}" ] ||
+	       [ -z "${rc_flags##*--driftfile*}" ] ); then
 		driftopt="" # admin set the option, we don't need to add it.
 	elif [ -f "${_ntp_old_driftfile}" ]; then
 		driftopt="-f ${_ntp_old_driftfile}"


More information about the svn-src-head mailing list