[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exit code of id depending on user group
From: |
Paul Eggert |
Subject: |
Re: Exit code of id depending on user group |
Date: |
Mon, 13 Sep 2004 03:47:24 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Felipe Kellermann <address@hidden> writes:
> $ id fuu
> uid=1018(fuu) gid=199 groups=199
> $ echo $?
> 1
>
> That return code sounds strange to me given the question I did.
I agree. To fix things, I installed the patch enclosed below.
Thanks for reporting this.
> with my version I have the following return code:
>
> $ id -gn fuu
> id: unknown gid 199
> $ echo $?
> 1
Yes that sounds right. Doesn't GNU id do that already, though?
2004-09-13 Paul Eggert <address@hidden>
* src/id.c (print_full_info): Don't exit with failure status simply
because a user or group number can't be turned into a name.
Problem reported by Felipe Kellermann in:
http://lists.gnu.org/archive/html/bug-coreutils/2004-09/msg00081.html
Index: id.c
===================================================================
RCS file: /home/eggert/coreutils/cu/src/id.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -p -u -r1.78 -r1.79
--- id.c 3 Aug 2004 06:27:09 -0000 1.78
+++ id.c 13 Sep 2004 10:43:21 -0000 1.79
@@ -343,25 +343,19 @@ print_full_info (const char *username)
printf ("uid=%lu", (unsigned long int) ruid);
pwd = getpwuid (ruid);
- if (pwd == NULL)
- ok = false;
- else
+ if (pwd)
printf ("(%s)", pwd->pw_name);
printf (" gid=%lu", (unsigned long int) rgid);
grp = getgrgid (rgid);
- if (grp == NULL)
- ok = false;
- else
+ if (grp)
printf ("(%s)", grp->gr_name);
if (euid != ruid)
{
printf (" euid=%lu", (unsigned long int) euid);
pwd = getpwuid (euid);
- if (pwd == NULL)
- ok = false;
- else
+ if (pwd)
printf ("(%s)", pwd->pw_name);
}
@@ -369,9 +363,7 @@ print_full_info (const char *username)
{
printf (" egid=%lu", (unsigned long int) egid);
grp = getgrgid (egid);
- if (grp == NULL)
- ok = false;
- else
+ if (grp)
printf ("(%s)", grp->gr_name);
}
@@ -396,9 +388,7 @@ print_full_info (const char *username)
putchar (',');
printf ("%lu", (unsigned long int) groups[i]);
grp = getgrgid (groups[i]);
- if (grp == NULL)
- ok = false;
- else
+ if (grp)
printf ("(%s)", grp->gr_name);
}
free (groups);