From: Volker Lendecke Date: Wed, 30 Aug 2023 11:02:02 +0000 (+0200) Subject: libcli: Make debug_unix_user_token() use just one DEBUG statement X-Git-Tag: tevent-0.16.0~167 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6071220fcb109f93833c45bcc8d8cd24235d6f30;p=thirdparty%2Fsamba.git libcli: Make debug_unix_user_token() use just one DEBUG statement This avoids messing up the debug logs when multiple processes are writing into the same file. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Oct 11 00:24:58 UTC 2023 on atb-devel-224 --- diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c index aac5749a815..e93ec30421f 100644 --- a/source3/auth/token_util.c +++ b/source3/auth/token_util.c @@ -888,16 +888,29 @@ NTSTATUS finalize_local_nt_token(struct security_token *result, void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid, int n_groups, gid_t *groups) { + TALLOC_CTX *frame = talloc_stackframe(); + char *s = NULL; int i; - DEBUGC(dbg_class, dbg_lev, - ("UNIX token of user %ld\n", (long int)uid)); - - DEBUGADDC(dbg_class, dbg_lev, - ("Primary group is %ld and contains %i supplementary " - "groups\n", (long int)gid, n_groups)); - for (i = 0; i < n_groups; i++) - DEBUGADDC(dbg_class, dbg_lev, ("Group[%3i]: %ld\n", i, - (long int)groups[i])); + + s = talloc_asprintf(frame, + "UNIX token of user %ld\n", + (long int)uid); + + talloc_asprintf_addbuf( + &s, + "Primary group is %ld and contains %i supplementary " + "groups\n", + (long int)gid, + n_groups); + for (i = 0; i < n_groups; i++) { + talloc_asprintf_addbuf(&s, + "Group[%3i]: %ld\n", + i, + (long int)groups[i]); + } + + DEBUGC(dbg_class, dbg_lev, ("%s", s ? s : "(NULL)")); + TALLOC_FREE(frame); } /*