From nobody Tue Feb 25 00:37:56 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Z1zGX6n7kz5p2MF; Tue, 25 Feb 2025 00:37:56 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z1zGX5qXhz3Yk0; Tue, 25 Feb 2025 00:37:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740443876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TCxx4Ubhqy0Kxr7kjyNqsZnVWXeeTIpbLnMOR4EtCJU=; b=rgGy6HehBmR4/pBSCJra7VyEOayvQqda2LGnAgOF3bZ+J/dFqZio7uEHHRBHBlsEYa2g8b JdKda6H+qlVoh5LdKA08s+gVaq1M5oI76CI4ERsrXpn6/pHgItQt6VdACrKu9rwH3AA4/Q E43ZlKXYXOVJirU++8Z0HzKPrCAzDXnWTkywWAv8/4dGHI+Rrf5/qunwrPP1cd8PBMEXy1 ctIRpTYE3oBHxtuwfDYBaSmWUtvTL4LI7bi6YveB2eu32AKTThk5wzxXzJsPPOosx6hWHp 3VUDr0b+fcLjnhC+jkYqa/Le/uP+4HPKQOc8copgvP00MBkdsRP9C7PWFpm9cQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740443876; a=rsa-sha256; cv=none; b=Rz0T0kF8nuf7cajVByTD1kBSHdtbBmB8aZHo2YRJG+kWLw9wSh9rcPlo/QRlu/xxFWbf6s nxGepBMTNL7TEvL+41UegEBfRCSbrFUowpfjmrMw0z8IHISxac0nimNT7VlvIDWjTpx7g0 Nsq/WFVCYAtqP7Mo5aKp0JnsBNz+j/T59oHZjiRArFBQTgZ0ovqMvR5cBYL67De+xXoTs5 kJf8AsmpCEe4u+fNvixev2VxHw1JKCS34T4ACspjYr9aKVjP9X/n9ZYk3SQU0pt3mc/Tnv l9kuTqF/MOaCwdNqjL8X/dJP8t+crorJH1jm24HsOusaMd7lOQKy0di2Cs5SnA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740443876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TCxx4Ubhqy0Kxr7kjyNqsZnVWXeeTIpbLnMOR4EtCJU=; b=nQphNk1uF01AGW4WyBBljtxpSJ7vw1aWgvzg4rURvH2ZZRBPE5WC4zHkvvDQ+vsVsOe2zq mwBUAISI0uvevn6CzmVfw7KmgRu4qytTayr5/G7KB7A8TrMGC170Jf8Ni9hfULNc82eqGW loVW75tDGxipHbhMV+TQSTWIj8iohMF+fe1vCOkKYRNks4Ve6m980I/3jtLwGaWQJlMmi/ +W10ryP1y+t6EtvfTWR/DKMigM28HaMxTZ8E5BtjfRd5qArw4eEtsEjF33kNr5om1x8DV0 g2WMUHLjPwN7wlapq6yYEwRU4SKJ57vslq6ue+h/UvYVJ++BG6QSuv+AWBOIMQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Z1zGX52rPz13FZ; Tue, 25 Feb 2025 00:37:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51P0buqh096625; Tue, 25 Feb 2025 00:37:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51P0buNT096622; Tue, 25 Feb 2025 00:37:56 GMT (envelope-from git) Date: Tue, 25 Feb 2025 00:37:56 GMT Message-Id: <202502250037.51P0buNT096622@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: 1a241a911dc8 - stable/14 - ntpd: Use the ntpd -u option in preference to the rc su plumbing List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1a241a911dc8635c3803f1a6620e1ab4692f6ecf Auto-Submitted: auto-generated The branch stable/14 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=1a241a911dc8635c3803f1a6620e1ab4692f6ecf commit 1a241a911dc8635c3803f1a6620e1ab4692f6ecf Author: Cy Schubert AuthorDate: 2024-12-12 20:03:09 +0000 Commit: Cy Schubert CommitDate: 2025-02-25 00:37:46 +0000 ntpd: Use the ntpd -u option in preference to the rc su plumbing Using the rc plumbing to setuid(2) is preferred as it allows the user to use the -i option in ntpd_flags to chroot ntpd. Chrooting ntpd by default will be a 2025 project. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D48191 (cherry picked from commit 521f66715afb312b356afafc68cbc044a436a753) --- libexec/rc/rc.d/ntpd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libexec/rc/rc.d/ntpd b/libexec/rc/rc.d/ntpd index 76d83149ae1a..36df4ae08c96 100755 --- a/libexec/rc/rc.d/ntpd +++ b/libexec/rc/rc.d/ntpd @@ -98,7 +98,6 @@ ntpd_precmd() # 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}" || [ -n "${rc_flags}" ] && @@ -112,7 +111,13 @@ ntpd_precmd() 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} -u ${ntpd_user:=ntpd:ntpd}" + + # Unset ntpd_user because rc.subr uses $${name}_user to determine + # whether to invoke su(1) to setuid() to $ntpd_user for us. We want + # ntpd to do the setuid() itself through the -u argument, above. + unset ntpd_user + if checkyesno ntpd_sync_on_start; then command_args="${command_args} -g" fi