From nobody Sat Dec 02 08:16:10 2023 X-Original-To: dev-commits-src-branches@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 4Sj2nQ6Gt2z53LXy; Sat, 2 Dec 2023 08:16:10 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Sj2nQ5rFZz3Mb2; Sat, 2 Dec 2023 08:16:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701504970; 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=HqmHJQRillvh9nurUUw1X+S0apHDIXgjYvlN0h5h6iY=; b=Y7YAZETA4ECWECT9/W156guuKOKzRwQZDxo0iP1QVRe31x8pHv9ME7qOYQGNXqFZMa1PEA X2Kslov9WK3lWy03Z6IAtus8qrp3h2dWxda7xG6yDOnwGDycBrDMuG91wW1i33dbJIIWde GtuTZP59iNb2stC5nL1ZbiesZCVVtZV7olsGhEG2sPl5FrrGpAn9J+rVtE7dxIz18HygFB c2EfWgG2fabQrYQ7NV4QMCnec+uZwuRi4RghoVmB6BgIb9yrcSZX+F9Yv6872QhhJOPNh0 /IiH4RAAEGwqgV6ksnj00RQxmTJlDdtvvx3iUR641H1ndA35e4ud5UZq/JBa0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701504970; 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=HqmHJQRillvh9nurUUw1X+S0apHDIXgjYvlN0h5h6iY=; b=UYPGfG5eLopJq7/mm4GhR6CLnw9wSdyeiVHT2nDswga1g3RG6MNkiS+jF7t91OVxWFNELH Zy7tKF/0oYfd3K0PO+wVmG7P+qVZxiB1bhYxv9gqwr6S14SNYKyfC/Ex8KfKJCqYcMJd2V sta1VaegF0topwlEOFou8NvtT14HHVhTfoLseReVvePRpwbNquCsPMOWbSULmc5x6kzqX8 X+LHPW4DR6uAUzIZE7R8aHhdN0gcEBl7g45BEWNK3ieStMz2cqtAdAf73DTdfO8inKaalV 8bCLINOaMzhPnWHkGWHaiOh6JgkwF30HVI9oqBw7X9MDdq2eNqCPYvJ/1buG+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701504970; a=rsa-sha256; cv=none; b=gmhXKnZoXAUu22ORGyse58AtghGSwTz/lPcVpECdIKjlFFzjAT35sas/oqsSR1SnTGaJXs xpd/JdopgxKCU/zGcqYEDerT85f8rXnfNg0EWiEMsksb1xkvPWH6TIVIZx9kNoxbkZBoOX ARN8j20qj9HDKZR6PEHS1KkdG2AWJOR+bnOFGPc1ZqgPR8awgu1bpydukvtVoFLiDp7E3G LVsQpp2MzqC5lo+qgp4MWezffL1XNLGYnPAxW4pZFOLgk0Ya85JwPMP5jctutmRSu4gfpC eyB0v27EE1rvycIYHkOXKx75jFe6xnvHB9Y3ZSH9TpZvYQEwj/KPKJWQ6cs1NQ== 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 4Sj2nQ4nKFz18F6; Sat, 2 Dec 2023 08:16:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B28GAWO061513; Sat, 2 Dec 2023 08:16:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B28GA33061510; Sat, 2 Dec 2023 08:16:10 GMT (envelope-from git) Date: Sat, 2 Dec 2023 08:16:10 GMT Message-Id: <202312020816.3B28GA33061510@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eugene Grosbein Subject: git: 2d6a03dd43c7 - stable/13 - rc.conf(5): add _umask to run the service using this value List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: eugen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2d6a03dd43c758cdd7c7dd9590459d1aa77d4333 Auto-Submitted: auto-generated The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=2d6a03dd43c758cdd7c7dd9590459d1aa77d4333 commit 2d6a03dd43c758cdd7c7dd9590459d1aa77d4333 Author: Eugene Grosbein AuthorDate: 2022-08-28 05:45:23 +0000 Commit: Eugene Grosbein CommitDate: 2023-12-02 08:15:52 +0000 rc.conf(5): add _umask to run the service using this value None of tools working with login classes change umask(1) and we had no ways to specify non-default umask for a service not touching its startup script. This change makes in possible. Some file-sharing services that create new files may benefit from it. Differential: https://reviews.freebsd.org/D36309 (cherry picked from commit 160a2f2cdda806e104c0d3194bfb84b208ad1ae8) --- libexec/rc/rc.subr | 10 +++++++++- share/man/man5/rc.conf.5 | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 2f9ce7f54bef..04b30cac40a7 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -790,6 +790,8 @@ startmsg() # # ${name}_oomprotect n Don't kill ${command} when swap space is exhausted. # +# ${name}_umask n The file creation mask to run ${command} with. +# # ${name}_user n User to run ${command} as, using su(1) if not # using ${name}_chroot. # Requires /usr to be mounted. @@ -990,7 +992,8 @@ run_rc_command() _fib=\$${name}_fib _env=\$${name}_env \ _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \ _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ - _setup=\$${name}_setup _env_file=\$${name}_env_file + _setup=\$${name}_setup _env_file=\$${name}_env_file \ + _umask=\$${name}_umask if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env from file set -a @@ -1352,9 +1355,14 @@ _run_rc_postcmd() _run_rc_doit() { + local _m + debug "run_rc_command: doit: $*" + _m=$(umask) + ${_umask:+umask ${_umask}} eval "$@" _return=$? + umask ${_m} # If command failed and force isn't set, request exit. if [ $_return -ne 0 ] && [ -z "$rc_force" ]; then diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 666ccbbc6b6e..8f105e679b55 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 18, 2023 +.Dd December 2, 2023 .Dt RC.CONF 5 .Os .Sh NAME @@ -237,6 +237,11 @@ such as PostgreSQL will not inherit the OOM killer protection. .Pp This variable has no effect on services running within a .Xr jail 8 . +.It Ao Ar name Ac Ns Va _umask +.Pq Vt int +Run the service using this +.Xr umask 1 +value. .It Ao Ar name Ac Ns Va _user .Pq Vt str Run the service under this user account. @@ -4730,6 +4735,7 @@ The default is 10. .Xr limits 1 , .Xr protect 1 , .Xr sh 1 , +.Xr umask 1 , .Xr vi 1 , .Xr vidcontrol 1 , .Xr bridge 4 ,