From owner-svn-src-all@freebsd.org Thu May 23 01:41:51 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD26E159425E; Thu, 23 May 2019 01:41:50 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 73B0274F4B; Thu, 23 May 2019 01:41:50 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5038425F61; Thu, 23 May 2019 01:41:50 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4N1foFo034144; Thu, 23 May 2019 01:41:50 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4N1fow7034143; Thu, 23 May 2019 01:41:50 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201905230141.x4N1fow7034143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 23 May 2019 01:41:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348141 - head/libexec/rc/rc.d X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/libexec/rc/rc.d X-SVN-Commit-Revision: 348141 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 73B0274F4B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2019 01:41:51 -0000 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}"