emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53631: closed (coreutils id(1) incorrect behavior)


From: GNU bug Tracking System
Subject: bug#53631: closed (coreutils id(1) incorrect behavior)
Date: Fri, 04 Feb 2022 23:00:03 +0000

Your message dated Fri, 4 Feb 2022 14:59:20 -0800
with message-id <0637488f-498d-be16-95c3-11c722760411@cs.ucla.edu>
and subject line Re: bug#53631: coreutils id(1) incorrect behavior
has caused the debbugs.gnu.org bug report #53631,
regarding coreutils id(1) incorrect behavior
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
53631: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53631
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: coreutils id(1) incorrect behavior Date: Sun, 30 Jan 2022 03:52:29 +0300
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



--- End Message ---
--- Begin Message --- Subject: Re: bug#53631: coreutils id(1) incorrect behavior Date: Fri, 4 Feb 2022 14:59:20 -0800 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 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>.

Attachment: 0001-id-print-groups-of-listed-name.patch
Description: Text Data


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]