From nobody Sat Dec 02 08:44:14 2023 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 4Sj3Pq27rdz52TcH; Sat, 2 Dec 2023 08:44:15 +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 4Sj3Pq0BPzz3RDv; Sat, 2 Dec 2023 08:44:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701506655; 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=IOOWnK9Wqh4FASgFIEWk9OOnEK5DfGR7WtdYpfks+fM=; b=ENigqqeykQ1zi87Od2T1dudrwPdWSJeNj416oZ74VuiPGG0EMEuvMT2aVeFZ5GexXW4ffp SwaVFa6ak1TGCW6ywASfbDAAwJ+dlnV2m8dSDVHUa5OWgL4vvZBPPSVR6cGnOI9sgowZij 16es0KFa3NILg3SyhHDLYviAZrXKt0TQ68THzHTGJE0bQDgevooGNOOmDJzj5Eho0Ezgnr GykxIk7XfD2Suif5pPWk02H4YnUcZQhTrZOQZ1mh4MkgCGnJERINo3Rmv4KlEqyrTRLn6S qVBUbrAtNwGi+zlMZhEL1OSa7bzpF7v8ShTyZb2Pz07gga6RPOFtQ0pGMwJOxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701506655; 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=IOOWnK9Wqh4FASgFIEWk9OOnEK5DfGR7WtdYpfks+fM=; b=GBlbUCwVWsNWeKzyCS6WZylw+6qz8+1KtP1j9npWFu5vvTeakt6r9nIOjl8ahXzVe8w6Jl if+mPWEcawSXsvwO0bsyzTof1ApZRplIAo/ZByG53B6LPUn1e30BZvLZWH5kch4gq2xWe7 9Qfh/S/KwRS4H3u7z1MP7rSQOJ/JOMq6yoQMzh+gAxMED5P56VeJyf5mpdw6gzs/eUqyJB r9jpwUYxCfXWkhTGw2ceVm94X/DaNaxFuIwo4BcyYyOI6g3/WTnSWYtnpW41OX3UlzdLsw RBmAzoleagZVJxd5GpLoHhAdzIIwWsT1ZKDY5ofD72FDaiTxe64autRB6LjKaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701506655; a=rsa-sha256; cv=none; b=IGMZRQuwdnm9gias5v/zvs2l+LFng2z5mBqUPc9JAjVOGJSjh/0rIazEs4Y9oG2e300RL0 uapBKPqNmczd77AyLCRiwBmmIYy4ic72cH+gWdQ86S7oxSyUn/ussukn2gUy4BMao8ymg6 P8f93vkOudEDayasIAgSV9FxXQIJq/SzqUs7yZIj2mabjEINbVd0rGUnI6FPDILsYgDlKH sY4+6L6z+eQbGct0btzTJ0X7DpAPqeMmZ3r49hWTXrkbQiTxV5pSZ/XtJ+nXNyTYgfV2nu 98eru2DYnosbZxPLFwtCiKFiQJ9rvB8i6ZQqOxh3kgoWFYVlRefaWMNxFwYnWw== 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 4Sj3Pp6Mx5z18Sm; Sat, 2 Dec 2023 08:44:14 +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 3B28iEIr010950; Sat, 2 Dec 2023 08:44:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B28iEsv010947; Sat, 2 Dec 2023 08:44:14 GMT (envelope-from git) Date: Sat, 2 Dec 2023 08:44:14 GMT Message-Id: <202312020844.3B28iEsv010947@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: 2e6541b943ef - stable/12 - rc.conf(5): add _umask to run the service using this value 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/12 X-Git-Reftype: branch X-Git-Commit: 2e6541b943efb785aa6e04957e511a83b452b240 Auto-Submitted: auto-generated The branch stable/12 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=2e6541b943efb785aa6e04957e511a83b452b240 commit 2e6541b943efb785aa6e04957e511a83b452b240 Author: Eugene Grosbein AuthorDate: 2022-08-28 05:45:23 +0000 Commit: Eugene Grosbein CommitDate: 2023-12-02 08:40:59 +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 e9a2feeb6d1a..846965d9a8e6 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -770,6 +770,8 @@ check_startmsgs() # # ${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. @@ -970,7 +972,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 @@ -1331,9 +1334,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 0f82a5df93c6..23f24bc349a8 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 7, 2022 +.Dd August 28, 2022 .Dt RC.CONF 5 .Os .Sh NAME @@ -234,6 +234,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. @@ -4672,6 +4677,7 @@ files. .Xr limits 1 , .Xr protect 1 , .Xr sh 1 , +.Xr umask 1 , .Xr vi 1 , .Xr vidcontrol 1 , .Xr bridge 4 ,