Didi <[EMAIL PROTECTED]> wrote: > After some work, here the final patch proposal. > > Thank you very much for your help Jim. > > Summary of the patch: > > On some systems with AFS 'id' and 'groups' outputted a very big group > number if no user was specified on the command line. This is now > fixed.
Thanks. That would fail (dereference NULL) upon getpwuid failure. How about this instead? >From 78ee912f890d64af43fc3a49d08bc19759a42ad0 Mon Sep 17 00:00:00 2001 From: ribalba <[EMAIL PROTECTED]> Date: Tue, 4 Mar 2008 18:03:35 +0100 Subject: [PATCH] Work around AFS bug: id and groups would print invalid group info * src/id.c (main): Call print_group_list with a user name, if possible. * src/groups.c (main): Likewise. For details, see http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12852 http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12875 Signed-off-by: ribalba <[EMAIL PROTECTED]> --- src/groups.c | 2 +- src/id.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/groups.c b/src/groups.c index baac7b9..c8e617b 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..9ee52e1 100644 --- a/src/id.c +++ b/src/id.c @@ -196,17 +196,22 @@ of a different user")); error (EXIT_FAILURE, 0, _("cannot print only names or real IDs in default format")); + char const *user_name; if (argc - optind == 1) { - struct passwd *pwd = getpwnam (argv[optind]); + struct passwd const *pwd = getpwnam (argv[optind]); if (pwd == NULL) error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]); + user_name = argv[optind]; ruid = euid = pwd->pw_uid; rgid = egid = pwd->pw_gid; } else { + struct passwd const *pwd; euid = geteuid (); + pwd = getpwuid (euid); + user_name = pwd ? pwd->pw_name : NULL; ruid = getuid (); egid = getegid (); rgid = getgid (); @@ -223,7 +228,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 (user_name, ruid, rgid, egid, use_name)) ok = false; } else if (just_context) @@ -232,7 +237,7 @@ of a different user")); } else { - print_full_info (argv[optind]); + print_full_info (user_name); } putchar ('\n'); -- 1.5.4.3.432.g4eb06 _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils