git: e2d48181239e - stable/14 - inetd: don't assume that initgroups(3) will set the egid

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Sun, 12 Apr 2026 13:44:05 UTC
The branch stable/14 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2d48181239e99b825862156cd5d6a9756875125

commit e2d48181239e99b825862156cd5d6a9756875125
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-08-08 22:34:56 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-04-12 13:43:36 +0000

    inetd: don't assume that initgroups(3) will set the egid
    
    inetd, in the ident provider, seems to be the only initgroups(3)
    caller in base that assumes it will set the egid.  Everyone else uses it
    as it's typically used on other platforms: to initialize supplementary
    groups.
    
    (cherry picked from commit 33dd42e632982ba324789f47041d03ceb65f6560)
---
 usr.sbin/inetd/builtins.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c
index aed304ae99c2..0de2179ef52b 100644
--- a/usr.sbin/inetd/builtins.c
+++ b/usr.sbin/inetd/builtins.c
@@ -606,6 +606,8 @@ ident_stream(int s, struct servtab *sep)
 		 */
 		if (initgroups(pw->pw_name, pw->pw_gid) == -1)
 			iderror(lport, fport, s, ID_UNKNOWN);
+		if (setegid(pw->pw_gid) == -1)
+			iderror(lport, fport, s, ID_UNKNOWN);
 		if (seteuid(pw->pw_uid) == -1)
 			iderror(lport, fport, s, ID_UNKNOWN);
 		/*