1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-30 16:51:41 +00:00

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
This commit is contained in:
Ian Lepore 2019-05-23 01:41:49 +00:00
parent c63f1e21da
commit a2119d62c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348141

View File

@ -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}"