git: 960dbe036d85 - stable/15 - ddb ps: Print again the effective GID, separately

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Thu, 18 Sep 2025 08:51:55 UTC
The branch stable/15 has been updated by olce:

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

commit 960dbe036d853dee08f3d5220c970bb6964baf2f
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-08-26 08:56:54 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-09-18 08:50:22 +0000

    ddb ps: Print again the effective GID, separately
    
    Following commit be1f7435ef218b1d ("kern: start tracking cr_gid outside
    of cr_groups[]"), cr_groups[] doesn't contain the effective GID anymore.
    Fix the 'show proc' DDB command to show it again, and make it stand out
    with respect to the supplementary ones.
    
    Fixes:          be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]")
    MFC after:      9 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52251
    
    (cherry picked from commit de974a0f1b73e79466c25f3c85fe727004576fea)
---
 sys/ddb/db_ps.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
index 733c440f5ee3..a26cf8161294 100644
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -459,12 +459,11 @@ DB_SHOW_COMMAND(proc, db_show_proc)
 		db_printf("??? (%#x)\n", p->p_state);
 	}
 	if (p->p_ucred != NULL) {
-		db_printf(" uid: %d  gids: ", p->p_ucred->cr_uid);
-		for (i = 0; i < p->p_ucred->cr_ngroups; i++) {
-			db_printf("%d", p->p_ucred->cr_groups[i]);
-			if (i < (p->p_ucred->cr_ngroups - 1))
-				db_printf(", ");
-		}
+		db_printf(" uid: %d gid: %d supp gids: ",
+		    p->p_ucred->cr_uid, p->p_ucred->cr_gid);
+		for (i = 0; i < p->p_ucred->cr_ngroups; i++)
+			db_printf(i == 0 ? "%d" : ", %d",
+			    p->p_ucred->cr_groups[i]);
 		db_printf("\n");
 	}
 	if (p->p_pptr != NULL)