GNU bug report logs -
#53631
coreutils id(1) incorrect behavior
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#53631: coreutils id(1) incorrect behavior
which was filed against the coreutils package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 53631 <at> debbugs.gnu.org.
--
53631: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53631
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
Thanks for the bug report. I installed the attached patch, which I hope
fixes things for you, and am boldly closing the bug report.
This fix depends on the latest lib/userspec.c from Gnulib; see
<https://lists.gnu.org/r/bug-gnulib/2022-02/msg00000.html>.
[0001-id-print-groups-of-listed-name.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
Hi, bug-coreutils@!
Recently I found an issue in the coreutils id(1) behavior. For coreutils
v8.32-165-g18dbcae25, `id username` prints user and group IDs for the
first matched user with the identical UID. In the case where there are
several users with the identical UID in the system it can be misleading.
Example:
# useradd user1
# groupadd somegroup
# useradd -o -u "$(id -u user1)" -g "$(id -G user1) -G somegroup user2
# id user1
uid=1027(user1) gid=1027(user1) groups=1027(user1)
# id user2
uid=1027(user1) gid=1027(user1) groups=1027(user1)
# su - user2
$ id
uid=1027(user1) gid=1027(user1) groups=1027(user1),1028(somegroup)
Expected behavior is:
# id user1
uid=1027(user1) gid=1027(user1) groups=1027(user1)
# id user2
uid=1027(user1) gid=1027(user1) groups=1027(user1),1028(somegroup)
Looking at the code, I found that id uses parse_user_spec() to obtain
euid of username (or uid) command line argument, and then it obtains all
the rest needed information by this euid.
for (; optind < n_ids; optind++)
{
struct passwd *pwd = NULL;
char const *spec = argv[optind];
/* Disallow an empty spec here as parse_user_spec() doesn't
give an error for that as it seems it's a valid way to
specify a noop or "reset special bits" depending on the system. */
if (*spec)
{
if (parse_user_spec (spec, &euid, NULL, NULL, NULL) == NULL)
{
/* parse_user_spec will only extract a numeric spec,
so we lookup that here to verify and also retrieve
the PW_NAME used subsequently in group lookup. */
pwd = getpwuid (euid);
}
}
--
WBR,
Vladimir D. Seleznev
This bug report was last modified 3 years and 105 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.