Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2019 01:41:50 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348141 - head/libexec/rc/rc.d
Message-ID:  <201905230141.x4N1fow7034143@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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}"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905230141.x4N1fow7034143>