From nobody Thu Jul 3 12:01:12 2025 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 4bXwMs3ClXz60qfb; Thu, 03 Jul 2025 12:01:13 +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 4bXwMs0bbtz3mtr; Thu, 03 Jul 2025 12:01:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751544073; 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=iXBBPyjoz+LcFJZdnij9nwzuimhRvIrWO9LZTFMGknM=; b=ic/ADU3S0vFZZ3BhpLW9QWCPDp2VyRl+RS9juauHe2zPeXV5GAAIPMb3oMyzKw9/+qQxRa r4vXydu9Bcv2byq0W4QaWGmOfLX9UJsNR6Oo5w7uEWi7wQxs9Drf//IP0vQmzwDWpbUYi6 T2RaCrMbyVTFoezlohe73ntZ0F8U4K9YWxmZnSxreMxCxkS8W8LOUKH+6b1gAEVIk+zQnr Z6TNEvDXYBlXexVY+T8Qsugv4ghWTePwAjlHr4/3E1rDovKoJTDgfZFWnf3Zzo5y45JSqe 1N8E4PGRx4M290GEItTQ3/nFyGxSFJfpnOptSRHLmGszyAQDTFcHcgcn9tlBmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751544073; 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=iXBBPyjoz+LcFJZdnij9nwzuimhRvIrWO9LZTFMGknM=; b=EwEq4b1qaagv3pdLzttEYg6XB2FZeWNa4VqltyBwozrss4PdnOeo5S2Y9huUB8ysKRpvye 0ViJc3ciXxsfa8dfWmkeLS2OdxS6SzdX8dNWA4OQBkC1nbJibJalu4ifaAZgX80kLC05YI zBFVsAc6hZWL8/fIlWlcOZqxvAIH66oKdUjKaD/Jnz5bA78oNtDOzWoa2yz4JtFtU1pPfV e29kYWuLIcfaNsICZgy6TwHC830ejPmSXriTp54wUacHbhiVSwUaaJL02VbgrkHgBwLdm6 YhZVX71hYUSTFjInr1aKa2q1G4r7+Q2dlXqJbiQj4Cosf8eUIfosZgG6CWnJhQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751544073; a=rsa-sha256; cv=none; b=SIL7mxtrHkeJLo9fWnTW+fheJ4TznSxIfNmqMnK/iaC+kY8VBaDWFagi17ZL45QzN4uKHL zqtW0Be87LqUMTayRgse5mkFiK9ArnYQ0CL2R7cAZNVW2+9U3sQ42Pmp/MRBOIht+eeYdS J65XeOW2mjCIkG0YrlTfSdPF8Sk1On0WsySglDqaH8nfKSVPOtDFQdGxQNOI/XApMTVwg2 4qWrUsPiYZYmFPjo6sjCc4ipb0J6qj6OYQmW8on0N4R+/8MjlB9uIRd+CjLSC4MoG3roAJ Q8B1qbExEBkj75SQl0SuLfBD0CoJ8UA3ZHMY5QUVf6T8GFwQC2rlDL4vF89b1A== 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 4bXwMs01mCz13Jn; Thu, 03 Jul 2025 12:01:13 +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 563C1CnR052115; Thu, 3 Jul 2025 12:01:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 563C1CEL052112; Thu, 3 Jul 2025 12:01:12 GMT (envelope-from git) Date: Thu, 3 Jul 2025 12:01:12 GMT Message-Id: <202507031201.563C1CEL052112@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 8e4db537c34f - main - pfctl: Use uid_from_user(3) and gid_from_group(3) 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e4db537c34fcdea2a14afc84f6bd5ccaa086ddb Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=8e4db537c34fcdea2a14afc84f6bd5ccaa086ddb commit 8e4db537c34fcdea2a14afc84f6bd5ccaa086ddb Author: Kristof Provost AuthorDate: 2025-06-30 08:09:22 +0000 Commit: Kristof Provost CommitDate: 2025-07-03 07:16:15 +0000 pfctl: Use uid_from_user(3) and gid_from_group(3) in utilities that do repeated lookups. OK tb@ Obtained from: OpenBSD, millert , a0f924b8c9 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/parse.y | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index f05e5608ba9d..c939b5ae7cce 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -3926,14 +3926,14 @@ uid : STRING { if (!strcmp($1, "unknown")) $$ = UID_MAX; else { - struct passwd *pw; + uid_t uid; - if ((pw = getpwnam($1)) == NULL) { + if (uid_from_user($1, &uid) == -1) { yyerror("unknown user %s", $1); free($1); YYERROR; } - $$ = pw->pw_uid; + $$ = uid; } free($1); } @@ -4004,14 +4004,14 @@ gid : STRING { if (!strcmp($1, "unknown")) $$ = GID_MAX; else { - struct group *grp; + gid_t gid; - if ((grp = getgrnam($1)) == NULL) { + if (gid_from_group($1, &gid) == -1) { yyerror("unknown group %s", $1); free($1); YYERROR; } - $$ = grp->gr_gid; + $$ = gid; } free($1); }