From 717ae79b9a73dbb66fce4667c14b5153692f4f77 Mon Sep 17 00:00:00 2001 From: ribalba Date: Tue, 4 Mar 2008 18:03:35 +0100 Subject: [PATCH] On AFS Systems groups where not outputted correctly * src/id.c : Moved and renamed pwd and used it for names * src/groups.c : Pass the username as parameter if possible Signed-off-by: ribalba --- src/groups.c | 2 +- src/id.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/groups.c b/src/groups.c index baac7b9..b24b70a 100644 --- a/src/groups.c +++ b/src/groups.c @@ -102,7 +102,7 @@ main (int argc, char **argv) egid = getegid (); rgid = getgid (); - if (!print_group_list (NULL, ruid, rgid, egid, true)) + if (!print_group_list (getlogin(), ruid, rgid, egid, true)) ok = false; putchar ('\n'); } diff --git a/src/id.c b/src/id.c index e4eda40..05c1bee 100644 --- a/src/id.c +++ b/src/id.c @@ -196,16 +196,18 @@ of a different user")); error (EXIT_FAILURE, 0, _("cannot print only names or real IDs in default format")); + struct passwd *pwdg = NULL; if (argc - optind == 1) { - struct passwd *pwd = getpwnam (argv[optind]); - if (pwd == NULL) + pwdg = getpwnam (argv[optind]); + if (pwdg == NULL) error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]); - ruid = euid = pwd->pw_uid; - rgid = egid = pwd->pw_gid; + ruid = euid = pwdg->pw_uid; + rgid = egid = pwdg->pw_gid; } else { + pwdg = getpwuid (geteuid()); euid = geteuid (); ruid = getuid (); egid = getegid (); @@ -223,7 +225,7 @@ of a different user")); } else if (just_group_list) { - if (!print_group_list (argv[optind], ruid, rgid, egid, use_name)) + if (!print_group_list (pwdg->pw_name, ruid, rgid, egid, use_name)) ok = false; } else if (just_context) @@ -232,7 +234,7 @@ of a different user")); } else { - print_full_info (argv[optind]); + print_full_info (pwdg->pw_name); } putchar ('\n'); -- 1.5.2.5