From nobody Thu Sep 28 15:10:54 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 4RxH3y726jz4tv7j; Thu, 28 Sep 2023 15:10:54 +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 4RxH3y6J44z3Ykn; Thu, 28 Sep 2023 15:10:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695913854; 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=QV/2cfSfKqZ/4MgoLOxlchgs8wScGS+69xfn+GNgSiI=; b=kpDVtc8FgEMVZHaz/b+6/F+5QeWc0vSS6sD0qQOIAg4xO2H6EseIMdkYbQSERFTzGsIHMY u1TttR20wzlICfjqEniep5KjTntqDX6gf5j8AZqOWa4HEfnR3+j708zfqGL8yQYLP6Z8OP k0DTA5OT/D8fwlzOEP1KmXPfxBTvmrsqU6D+6cK7dgzbc1fE4bz40Owo6HfYbDT/FywVGU qNUNR5jOW3bFJQtVRsOLiEre8yPPi+QThZor/wpHwoUZkMDDwU7MdvEsv9EHygZ92zQYqi WQzscYbbSMHYhekXLiFk1M9GAXOM5Yvaz2UB7sGfOezGiwX0lzubD+bVTrk35g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695913854; a=rsa-sha256; cv=none; b=l1kW3D3uzIHLLOLWJMMq4gCgFhbackMOJuj0BA0HsV/sy2UAC5TPY5CxMP9eP+B8VGn315 hfevRnItTNEmzqFZcfysGxsaSzqPUqFmR+l6xRDjrnSE4fTsPMoTaYGt42wqSg2gWwNApg OrblmIyFH4mXuxcdegecxw0og/rBK6cQxykpsxqKsCpRfbMw+YeEEmH2Zsu+wpXOdKWmvT ywdSOs/L7pOhphE220nc30BKLbBLaGnPClE69IZwWDhFGSu9G7O0YGiYKxQHWr5JWEyiAw 2k/ZYB7j/qLR0RZyn6buUr0LO/0cf92duEIL0hNjw+sg8nf6miOItGzdV4OGZg== 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=1695913854; 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=QV/2cfSfKqZ/4MgoLOxlchgs8wScGS+69xfn+GNgSiI=; b=qy9lWQ6acVTMNxb4h5uFzdBl95XpvR297wQG90m1TarhiorjPfPJdVNpi2yJcHk126x3rd dMWNpq43Q+Y/L8DsCYkCKYMC4jmJFOfExIBa+mJMK1lvDydfRd0yqwXbMJNj48YF5EtUqS +nHThKv/Bwyb6xvJraIU22325Kd4ABhxWQYZtp+WDKO8eCl41MnEdVSr+VZLAa883wM31A K/SH2kUN0IZLQSL5N2efXDRRKg4gH7ObovPLNO52YvlpED/Y5e89KV0VWWYE0yuyEy3PWb Sw59nhf6quYSopjVCGxXwdppf6YERCxfbxlBd9zPHn7c23E/W6+CTiM+lwOIzA== 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 4RxH3y5P0xzC4p; Thu, 28 Sep 2023 15:10:54 +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 38SFAsLj047995; Thu, 28 Sep 2023 15:10:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38SFAsnI047992; Thu, 28 Sep 2023 15:10:54 GMT (envelope-from git) Date: Thu, 28 Sep 2023 15:10:54 GMT Message-Id: <202309281510.38SFAsnI047992@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: ffd3ef8ee025 - main - groupmember(), realgroupmember(): Return a bool instead of an int 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ffd3ef8ee0253ffaf214cf711251d112f6a2bcf6 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=ffd3ef8ee0253ffaf214cf711251d112f6a2bcf6 commit ffd3ef8ee0253ffaf214cf711251d112f6a2bcf6 Author: Olivier Certner AuthorDate: 2023-08-17 23:54:47 +0000 Commit: Mitchell Horne CommitDate: 2023-09-28 15:05:46 +0000 groupmember(), realgroupmember(): Return a bool instead of an int Requested by: mhorne Reviewed by: mhorne MFC after: 2 weeks MFC to: stable/14 releng/14.0 Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40958 --- sys/kern/kern_prot.c | 12 ++++++------ sys/sys/ucred.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 0f15771fb00d..00eb2fccdeef 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1279,7 +1279,7 @@ sys___setugid(struct thread *td, struct __setugid_args *uap) /* * Returns whether gid designates a supplementary group in cred. */ -static int +static bool supplementary_group_member(gid_t gid, struct ucred *cred) { int l, h, m; @@ -1306,12 +1306,12 @@ supplementary_group_member(gid_t gid, struct ucred *cred) * Check if gid is a member of the (effective) group set (i.e., effective and * supplementary groups). */ -int +bool groupmember(gid_t gid, struct ucred *cred) { - if (cred->cr_groups[0] == gid) - return (1); + if (gid == cred->cr_groups[0]) + return (true); return (supplementary_group_member(gid, cred)); } @@ -1320,11 +1320,11 @@ groupmember(gid_t gid, struct ucred *cred) * Check if gid is a member of the real group set (i.e., real and supplementary * groups). */ -int +bool realgroupmember(gid_t gid, struct ucred *cred) { if (gid == cred->cr_rgid) - return (1); + return (true); return (supplementary_group_member(gid, cred)); } diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index 633bf436fcd4..7c9e46e47774 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -158,8 +158,8 @@ void crcowfree(struct thread *td); void cru2x(struct ucred *cr, struct xucred *xcr); void cru2xt(struct thread *td, struct xucred *xcr); void crsetgroups(struct ucred *cr, int n, gid_t *groups); -int groupmember(gid_t gid, struct ucred *cred); -int realgroupmember(gid_t gid, struct ucred *cred); +bool groupmember(gid_t gid, struct ucred *cred); +bool realgroupmember(gid_t gid, struct ucred *cred); #endif /* _KERNEL */ #endif /* !_SYS_UCRED_H_ */