]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: Make debug_unix_user_token() use just one DEBUG statement
authorVolker Lendecke <vl@samba.org>
Wed, 30 Aug 2023 11:02:02 +0000 (13:02 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 11 Oct 2023 00:24:58 +0000 (00:24 +0000)
This avoids messing up the debug logs when multiple processes are
writing into the same file.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Oct 11 00:24:58 UTC 2023 on atb-devel-224

source3/auth/token_util.c

index aac5749a8152c06c03daceeeeffb893ce022ad57..e93ec30421ff2733e903378acb46d0583161812a 100644 (file)
@@ -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);
 }
 
 /*