diff --git a/libexec/rc/rc.d/ntpd b/libexec/rc/rc.d/ntpd --- a/libexec/rc/rc.d/ntpd +++ b/libexec/rc/rc.d/ntpd @@ -23,6 +23,7 @@ _ntp_default_dir="/var/db/ntp" _ntp_default_driftfile="${_ntp_default_dir}/ntpd.drift" _ntp_old_driftfile="/var/db/ntpd.drift" +_ntpd_user_arg="-u ntpd:ntpd" pidfile="${_ntp_default_dir}/${name}.pid" @@ -101,9 +102,12 @@ # 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 grep -q "^[ \t]*driftfile" "${ntpd_config}" || + elif [ -n "${ntpd_user}" ]; then + _ntpd_user_arg="-u ${ntpd_user}" + unset ntpd_user + fi + if grep -q "^[ \t]*driftfile" "${ntpd_config}" || [ -n "${rc_flags}" ] && ( [ -z "${rc_flags##*-f*}" ] || [ -z "${rc_flags##*--driftfile*}" ] ); then @@ -115,7 +119,7 @@ fi # Set command_args based on the various config vars. - command_args="-p ${pidfile} -c ${ntpd_config} ${driftopt}" + command_args="-p ${pidfile} -c ${ntpd_config} ${driftopt} ${_ntpd_user_arg}" if checkyesno ntpd_sync_on_start; then command_args="${command_args} -g" fi