From nobody Mon Dec 16 14:45:38 2024 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 4YBjRR04nCz5hWWK; Mon, 16 Dec 2024 14:45:39 +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 4YBjRQ4yxWz4cyR; Mon, 16 Dec 2024 14:45:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360338; 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=gG/rj6BFeeMeDZKrCRMKrg/GBXtv1TQ3peJoFIH+Sok=; b=OiTH3nuoeBRCzVQEMUl+VC8KZKfNze/B6ka7n+bkIo7ninj+DxUzqIBCkt/jITweJjQRXq ZXBD8e/mjt52JrAI7IJAk84DQMkpMm9jJPC3QUGdB1NJ73zL2Yj56bD2ubShbUFubQDffB lBflIeh6pJxueZHD0vqmm2XulCp3I20zUiSgoF4Ntku88lKNNX9wwzzEFU8MGuT5e7n49j Dg7vB7YitcYjPtK0pxggo7VKtxVJJLYcY9Fob2e9qrfyCw28T6hdoHOiIBsnD/ff4Gx1xT 5FJN4rNdN2gDDa09exuYwxhABP2g42hytosDWABXjN6ksFopdxdcsfymzP6lGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360338; 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=gG/rj6BFeeMeDZKrCRMKrg/GBXtv1TQ3peJoFIH+Sok=; b=fJXWFISMykoPg2Xbh4OmIO5U+/O8pghfdaHzjHYcsmPhHl+Jb1lsssBNdtCHQGpHq0+gfl 40DSe/MmVakAO1t4YLV36wbcn0Foo+qQIzhAPbKCTmA2urDyUoBr4eHRNkbcb408IIjf+H MiE7vKjLZiy3MBycvxNZ1s3Fbho705xEaLF0oai4jY+9FGqvRMhe6jRV1de6/TG9kW6gMW tSRVyw/ww8yk4u2srfXyI7ElfTpl1c8PAhLLk+IrLoJXuqaeINCvf4n6i0dJquIjVA6CFS Q0Su9wM5nGU+Gp45bNorn8G1IcS5+RAZ2oY/aAr/Va5VJSGrKSiEFkvbC1zC2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734360338; a=rsa-sha256; cv=none; b=B5nff95wK1//hSX7v3ju8cBbNMtgW2rHU6+8xixkk44mEjK04VwhNudvpAfikqeffr/eoz x8bYO5iKEw8Fy+DCbMvf3V9n+FcXAm9FspU+M8mY9eQrFSy026ZvHSKsv4V5GEXzOXANt8 qkksysAPVysmn00i7eUL9ZrHPk5bllEoeO01GAP9SIRI88Nu9lq1m/UnKfIHb7cxbFcLDN jmKRhxfj5zlJUKmoPGA2FNjQM5PNtuxrx6h1UQy13XBjx2Rpy6gIqWSJNlKZS4nXdGF88Z 6izo739ek9SPjOkNB4a8k5e7T+Gl8v6qLGJRgpiUyadPQA25E26HYQQ0HrzJ0A== 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 4YBjRQ4YpZzy0D; Mon, 16 Dec 2024 14:45:38 +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 4BGEjcXj052542; Mon, 16 Dec 2024 14:45:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BGEjcIR052539; Mon, 16 Dec 2024 14:45:38 GMT (envelope-from git) Date: Mon, 16 Dec 2024 14:45:38 GMT Message-Id: <202412161445.4BGEjcIR052539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: ccae2774897c - main - MAC/do: Rename rule_is_valid() => rule_applies() 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ccae2774897c1f8bb11f696d5895fb686db98176 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=ccae2774897c1f8bb11f696d5895fb686db98176 commit ccae2774897c1f8bb11f696d5895fb686db98176 Author: Olivier Certner AuthorDate: 2024-07-01 13:24:47 +0000 Commit: Olivier Certner CommitDate: 2024-12-16 14:42:33 +0000 MAC/do: Rename rule_is_valid() => rule_applies() This function checks whether a rule applies in the current context, i.e., if the subject's users/groups match that of the rule. By contrast, it doesn't check if the rule as specified by the user is valid (i.e., consistent). Reviewed by: bapt Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47592 --- sys/security/mac_do/mac_do.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 2ddc13d62b4f..4cc2a7971545 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -406,7 +406,7 @@ init(struct mac_policy_conf *mpc) } static bool -rule_is_valid(struct ucred *cred, struct rule *r) +rule_applies(struct ucred *cred, struct rule *r) { if (r->from_type == RULE_UID && r->f_uid == cred->cr_uid) return (true); @@ -427,7 +427,7 @@ priv_grant(struct ucred *cred, int priv) rule = mac_do_rule_find(cred->cr_prison, &pr); TAILQ_FOREACH(r, &rule->head, r_entries) { - if (rule_is_valid(cred, r)) { + if (rule_applies(cred, r)) { switch (priv) { case PRIV_CRED_SETGROUPS: case PRIV_CRED_SETUID: @@ -466,7 +466,7 @@ check_setgroups(struct ucred *cred, int ngrp, gid_t *groups) rule = mac_do_rule_find(cred->cr_prison, &pr); TAILQ_FOREACH(r, &rule->head, r_entries) { - if (rule_is_valid(cred, r)) { + if (rule_applies(cred, r)) { mtx_unlock(&pr->pr_mtx); return (0); }