From nobody Tue Apr 8 13:41:17 2025 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 4ZX6g324wMz5sQTq; Tue, 08 Apr 2025 13:41:19 +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 4ZX6g23cYXz3F29; Tue, 08 Apr 2025 13:41:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744119678; 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=TkxBE6dFLSjEfMJH+tqiec/HTYCR9UmsZfBlbECmPW8=; b=wikzVF7RPXcJ6At2xg6ofqncScq6ODxM+mL4q/Ea3A5KuWnv0GB9oF/lhd8xwoszInZa8F qcUaHL91NwePsSCYLfgJrZ7VPcHSJHmJ58/SXd80+Atv+6KCzY0i85mZ9EP0Y4DVe4FKqr 4XRRW3ee8T8E+s0zNqxTJNMSW30slgjRXHgRzfN7F6SlW3d2qU9lPQV2tgfuGwn9/rTWgR 1Ut9otQyDIsMVlU4OXPGJBvXaiIDB75JwVITwM+1fWcZnnYJoddH3L0Z6PLEA5NMubvcom 15llgjsPjtdumQNmbAObvlSSXUHuD42OtXbgj73p6T5cLqoQyf5+bTnG4ZCjbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744119678; a=rsa-sha256; cv=none; b=oYRR1h+MLaLuqSOV9O75x9LeuI3wYX+YmyFEx+iWJfH26Sq0qFIk7ChUmxi0OrWncOfJ1K jw5L6RXDC21V87eqz9KvccZTY8Nx3moqaRR8hrhmCE01MswlYMNEepfzxpF6hrRJoNOPay eLhbMkiqxGGdaVuNLbK8ptw5G8svFcEV3Z72jMg9C+5hbvwQyk9fePblDGLvdo3oPgKTwA MwbdaJMGWtsTgJlR1omEOlLpHu5TJRG99DWBd2X31guHQYwG6cgk9UE/raI3dFVt+X/WcL mStxNFjU0BCdDC2kRCeYW+5MyYFLkVFJU/aoSAX6afytcrb+IoIL5mnU2D+S9w== 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=1744119678; 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=TkxBE6dFLSjEfMJH+tqiec/HTYCR9UmsZfBlbECmPW8=; b=qwt8n9xjRP6p96ZSyfawNZC4MzPr6rhpg9deKr74Jkt71oflDO2qK//DZDHno20VmpgrDD YI3j7HvZJ30El694+hKoWnKHgz9xQhmCbsIUSQXNHBbmG/OCu/basF0duzXpwwee5QiYPI 8z6s8U17s+oLFvO9GDVEpD5YMlh/Y/9Dd1ql1HtRojxs88x69OaYUL+FAhF8Q5U6Fk35BD uDDUolHMLpsI2QXRXuOz1TY2P9IqgFlr2J4k4EvuwD55D9ZqpgXV9r6+G3iHQSl9gBPX6h 2BdTnCFY+CqmNSIGP8kMPtsIrxTdP7QVPpP4KgqWzPM4o/LjgJpy496s4Ij7hg== 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 4ZX6g21bMKzbD5; Tue, 08 Apr 2025 13:41:18 +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 538DfH5l034712; Tue, 8 Apr 2025 13:41:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 538DfHVD034709; Tue, 8 Apr 2025 13:41:17 GMT (envelope-from git) Date: Tue, 8 Apr 2025 13:41:17 GMT Message-Id: <202504081341.538DfHVD034709@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 8047b85cbe17 - stable/14 - MAC/do: Rules: and parts now to be separated by '>' 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8047b85cbe17b3819ac8acf94a19b5a844025c65 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=8047b85cbe17b3819ac8acf94a19b5a844025c65 commit 8047b85cbe17b3819ac8acf94a19b5a844025c65 Author: Olivier Certner AuthorDate: 2025-04-01 17:06:17 +0000 Commit: Olivier Certner CommitDate: 2025-04-08 13:38:30 +0000 MAC/do: Rules: and parts now to be separated by '>' Previously, we would accept only ':' as the separator, which makes parsing of the rule specification harder for humans, especially those people that are used to UNIX systems where ':' is used as the separator in PATH. With ':', the and parts can look like two different elements that are unrelated, especially to these eyes. Change parse_single_rule() so that '>' is also accepted as a separator between and , and promote it as the one to use. During a transition period, we will still allow the use of ':' for backwards compatibility. The manual page update comes from separate revision D49628. ':' has been completely removed from it on purpose. Reviewed by: bapt, manpages (ziaee) MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49627 (cherry picked from commit f01d26dec67fb6597438ed765269b85d1099a6fa) --- share/man/man4/mac_do.4 | 34 +++++++++++++++++----------------- sys/security/mac_do/mac_do.c | 11 ++++++----- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/share/man/man4/mac_do.4 b/share/man/man4/mac_do.4 index 9a9f669cd51c..4c067205225c 100644 --- a/share/man/man4/mac_do.4 +++ b/share/man/man4/mac_do.4 @@ -75,9 +75,9 @@ and a .Li Aq to part .Pq also called Dq target , -in this order, separated by a colon -.Pq Ql ":" : -.Dl Ao rule Ac \ ⟶\ Ao from Ac So ":" Sc Ao to Ac +in this order, separated by a greater-than sign +.Pq Ql > : +.Dl Ao rule Ac \ ⟶\ Ao from Ac So > Sc Ao to Ac .Ss Rule's Ao from Ac Part The first part of a rule, .Li Aq from , @@ -347,32 +347,32 @@ as this path is currently not configurable. Here are several examples of single rules matching processes having a real user ID of 10001: .Bl -tag -width indent -.It Li uid=10001:uid=10002 +.It Li uid=10001>uid=10002 Allows the process to switch any of its real, effective or saved user ID to 10002, but keeping the groups it is already in, and with the same primary/supplementary groups split. -.It Li uid=10001:uid=10002,uid=10003 +.It Li uid=10001>uid=10002,uid=10003 Same as the first example, but also allows to switch to UID 10003 instead of 10002. -.It Li uid=10001:uid=10002,gid=10002 +.It Li uid=10001>uid=10002,gid=10002 Same as the first example, but the new primary groups must be set to 10002 and no supplementary groups should be set. -.It Li uid=10001:uid=10002,gid=10002,+gid=.\& +.It Li uid=10001>uid=10002,gid=10002,+gid=.\& Same as the previous example, but in addition allowing to retain any current supplementary groups. -.It Li uid=10001:uid=10002,gid=10002,!gid=.\& +.It Li uid=10001>uid=10002,gid=10002,!gid=.\& Same as the previous example, but with the additional constraint that all current supplementary groups must be kept. -.It Li uid=10001:uid=10002,gid=10002,+gid=.,-gid=10001 +.It Li uid=10001>uid=10002,gid=10002,+gid=.,-gid=10001 Same as -.Ql uid=10001:uid=10002,gid=10002,+gid=.\& +.Ql uid=10001>uid=10002,gid=10002,+gid=.\& above, but 10001 cannot be retained as a supplementary group. -.It Li uid=10001:uid=10002,gid=10002,+gid=.,!gid=10003 +.It Li uid=10001>uid=10002,gid=10002,+gid=.,!gid=10003 Same as -.Ql uid=10001:uid=10002,gid=10002,+gid=.\& +.Ql uid=10001>uid=10002,gid=10002,+gid=.\& above, with the additional constraint that 10003 must appear in the supplementary groups. -.It Li uid=10001:uid=10002,gid=*,+gid=* +.It Li uid=10001>uid=10002,gid=*,+gid=* Same as the first example, but lifting any constraints on groups, allowing the process to become part of any groups it sees fit. .El @@ -380,17 +380,17 @@ process to become part of any groups it sees fit. Here are several examples of single rules matching processes having a real group ID of 10001: .Bl -tag -width indent -.It Li gid=10001:uid=0 +.It Li gid=10001>uid=0 Makes 10001 a more powerful .Ql wheel group, allowing its members to switch to root without password. -.It Li gid=10001:gid=10002 +.It Li gid=10001>gid=10002 Allows the process to enter GID 10002 as a primary group, but only if giving up all its supplementary groups. -.It Li security.mac.do.rules=gid=10001:gid=10002,+gid=.\& +.It Li security.mac.do.rules=gid=10001>gid=10002,+gid=.\& Same as the previous example, but allows to retain any current supplementary groups. -.It Li gid=10001:gid=10002,!gid=.\& +.It Li gid=10001>gid=10002,!gid=.\& Same as the previous example, but with the additional constraint that all current supplementary groups must be kept. .El diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 7bd3e2294798..a83c194b24ae 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -891,7 +891,7 @@ parse_single_rule(char *rule, struct rules *const rules, goto einval; } - from_id = strsep_noblanks(&rule, ":"); + from_id = strsep_noblanks(&rule, ":>"); if (is_null_or_empty(from_id)) { make_parse_error(parse_error, 0, "No ID specified."); goto einval; @@ -991,8 +991,9 @@ einval: * to point to a 'struct parse_error' giving an error message for the problem, * else '*parse_error' is set to NULL. * - * Expected format: A semi-colon-separated list of rules of the form - * ":". The part is of the form "=" where + * Expected format: A >-colon-separated list of rules of the form + * ">" (for backwards compatibility, a semi-colon ":" is accepted + * in place of '>'). The part is of the form "=" where * is "uid" or "gid", an UID or GID (depending on ) and is * "*", "any" or a comma-separated list of '=' clauses (see the * comment for parse_single_rule() for more details). For convenience, empty @@ -1002,8 +1003,8 @@ einval: * allowed between '' and ''). * * Examples: - * - "uid=1001:uid=1010,gid=1010;uid=1002:any" - * - "gid=1010:gid=1011,gid=1012,gid=1013" + * - "uid=1001>uid=1010,gid=1010;uid=1002>any" + * - "gid=1010>gid=1011,gid=1012,gid=1013" */ static int parse_rules(const char *const string, struct rules **const rulesp,