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 @@ -45,6 +45,7 @@ { # If the admin set what uid to use, we don't change it. if [ -n "${ntpd_user}" ]; then + logger -s -t "rc.d/ntpd" -p daemon.err "user ${ntpd_user} is not found, exiting" return 1 fi @@ -54,6 +55,7 @@ *-f* | *--driftfile* | *-i* | *--jaildir* | \ *-k* | *--keyfile* | *-l* | *--logfile* | \ *-p* | *--pidfile* | *-s* | *--statsdir* ) + logger -s -t "rc.d/ntpd" -p daemon.err "user ${ntpd_user} cannot access files listed in command line, exiting" return 1;; esac @@ -66,15 +68,32 @@ # privileges. Detect whether MAC is compiled into the kernel, load # the policy module if not already present, then check whether the # policy has been disabled via tunable or sysctl. - [ -n "$(sysctl -qn security.mac.version)" ] || return 1 - sysctl -qn security.mac.ntpd >/dev/null || kldload -qn mac_ntpd || return 1 - [ "$(sysctl -qn security.mac.ntpd.enabled)" == "1" ] || return 1 + if [ -z "$(sysctl -qn security.mac.version)" ]; then + logger -s -t "rc.d/ntpd" -p daemon.err "kernel does not support MAC, exiting" + return 1 + fi + if ! sysctl -qn security.mac.ntpd >/dev/null; then + if ! kldload -qn mac_ntpd; then + logger -s -t "rc.d/ntpd" -p daemon.err "failed to load mac_ntpd, exiting" + return 1 + fi + fi + if [ ! "$(sysctl -qn security.mac.ntpd.enabled)" == "1" ]; then + logger -s -t "rc.d/ntpd" -p daemon.err "security.mac.ntpd.enabled is not enabled, exiting" + return 1 + fi # On older existing systems, the ntp dir may by owned by root, change # it to ntpd to give the daemon create/write access to the driftfile. if [ "$(stat -f %u ${_ntp_default_dir})" = "0" ]; then - chown ntpd:ntpd "${_ntp_default_dir}" || return 1 - chmod 0755 "${_ntp_default_dir}" || return 1 + if ! chown ntpd:ntpd "${_ntp_default_dir}"; then + logger -s -t "rc.d/ntpd" -p daemon.err "chown ${_ntp_default_dir} failed, exiting" + return 1 + fi + if ! chmod 0755 "${_ntp_default_dir}"; then + logger -s -t "rc.d/ntpd" -p daemon.err "chmod ${_ntp_default_dir} failed, exiting" + return 1 + fi logger -s -t "rc.d/ntpd" -p daemon.notice \ "${_ntp_default_dir} updated to owner ntpd:ntpd, mode 0755" fi