git: 92a324a151ce - stable/13 - libbsm: honour AU_OFLAG_NORESOLVE

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 12 Nov 2024 13:44:59 UTC
The branch stable/13 has been updated by emaste:

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

commit 92a324a151ceef49cf52d33e9e30038f6459629a
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-10-23 12:25:29 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-11-12 13:44:47 +0000

    libbsm: honour AU_OFLAG_NORESOLVE
    
    AU_OFLAG_NORESOLVE is documented as "Leave user and group IDs in their
    numeric form" but it was not actually tested.
    
    OpenBSM pull request at https://github.com/openbsm/openbsm/pull/85
    
    PR:             282271
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D47263
    
    (cherry picked from commit ba10bfe509dcb5d408de89c886527035068b8f17)
    (cherry picked from commit 914752d0f7f874ab4fc8393aee28c22df87324f2)
    (cherry picked from commit 6abc57ceb6a0af92ec86d95ba3bca0c396624c90)
---
 contrib/openbsm/libbsm/bsm_io.c           | 4 ++--
 usr.sbin/praudit/tests/input/numeric_form | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/contrib/openbsm/libbsm/bsm_io.c b/contrib/openbsm/libbsm/bsm_io.c
index 4b89ccb8b59c..f0b3e4a1a2df 100644
--- a/contrib/openbsm/libbsm/bsm_io.c
+++ b/contrib/openbsm/libbsm/bsm_io.c
@@ -644,7 +644,7 @@ print_user(FILE *fp, u_int32_t usr, int oflags)
 {
 	struct passwd *pwent;
 
-	if (oflags & AU_OFLAG_RAW)
+	if (oflags & (AU_OFLAG_RAW | AU_OFLAG_NORESOLVE))
 		fprintf(fp, "%d", usr);
 	else {
 		pwent = getpwuid(usr);
@@ -663,7 +663,7 @@ print_group(FILE *fp, u_int32_t grp, int oflags)
 {
 	struct group *grpent;
 
-	if (oflags & AU_OFLAG_RAW)
+	if (oflags & (AU_OFLAG_RAW | AU_OFLAG_NORESOLVE))
 		fprintf(fp, "%d", grp);
 	else {
 		grpent = getgrgid(grp);
diff --git a/usr.sbin/praudit/tests/input/numeric_form b/usr.sbin/praudit/tests/input/numeric_form
index 09f089450ac3..144be694f2e4 100644
--- a/usr.sbin/praudit/tests/input/numeric_form
+++ b/usr.sbin/praudit/tests/input/numeric_form
@@ -2,6 +2,6 @@ header,113,11,socket(2),0,Mon Jun 11 10:18:45 2018, + 380 msec
 argument,1,0x1c,domain
 argument,2,0x2,type
 argument,3,0x0,protocol
-subject,root,root,wheel,root,wheel,7053,4724,37636,10.0.2.2
+subject,0,0,0,0,0,7053,4724,37636,10.0.2.2
 return,success,3
 trailer,113