MCPcopy Create free account
hub / github.com/coreutils/coreutils / print_full_info

Function print_full_info

src/id.c:355–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353/* Print all of the info about the user's user and group IDs. */
354
355static void
356print_full_info (char const *username)
357{
358 struct passwd *pwd;
359 struct group *grp;
360
361 printf (_("uid=%ju"), (uintmax_t) ruid);
362 pwd = getpwuid (ruid);
363 if (pwd)
364 printf ("(%s)", pwd->pw_name);
365
366 printf (_(" gid=%ju"), (uintmax_t) rgid);
367 grp = getgrgid (rgid);
368 if (grp)
369 printf ("(%s)", grp->gr_name);
370
371 if (euid != ruid)
372 {
373 printf (_(" euid=%ju"), (uintmax_t) euid);
374 pwd = getpwuid (euid);
375 if (pwd)
376 printf ("(%s)", pwd->pw_name);
377 }
378
379 if (egid != rgid)
380 {
381 printf (_(" egid=%ju"), (uintmax_t) egid);
382 grp = getgrgid (egid);
383 if (grp)
384 printf ("(%s)", grp->gr_name);
385 }
386
387 {
388 gid_t *groups;
389
390 gid_t primary_group;
391 if (username)
392 primary_group = pwd ? pwd->pw_gid : -1;
393 else
394 primary_group = egid;
395
396 int n_groups = xgetgroups (username, primary_group, &groups);
397 if (n_groups < 0)
398 {
399 if (username)
400 error (0, errno, _("failed to get groups for user %s"),
401 quote (username));
402 else
403 error (0, errno, _("failed to get groups for the current process"));
404 ok &= false;
405 return;
406 }
407
408 if (n_groups > 0)
409 fputs (_(" groups="), stdout);
410 for (int i = 0; i < n_groups; i++)
411 {
412 if (i > 0)

Callers 1

print_stuffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected