coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] 'id' prints incorrectly groups for the session


From: Petr Stodůlka
Subject: Re: [PATCH] 'id' prints incorrectly groups for the session
Date: Thu, 26 Jun 2014 08:36:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 26.6.2014 03:53, Pádraig Brady wrote:
On 06/25/2014 01:17 PM, Petr Stodůlka wrote:
Hi,

command 'id' prints wrong groups for the session. This is similar to reported 
bug #7320 [0],
which was patched earlier for 'groups' and 'id -G', however just 'id' still 
prints wrong groups.
I propose this patch based on previous solution:
----------------------------------------------------------------------
diff --git a/src/id.c b/src/id.c
index 3348f80..6cfe884 100644
--- a/src/id.c
+++ b/src/id.c
@@ -399,8 +399,12 @@ print_full_info (const char *username)
      gid_t *groups;
      int i;

-    int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1),
-                               &groups);
+    int n_groups;
+    if(username)
+      n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1),
+                             &groups);
+    else
+      n_groups = xgetgroups (username, egid, &groups);
      if (n_groups < 0)
        {
          if (username)
--------------------------------------------------------------------

[0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7320
Logic looks correct.
The attached refactors slightly, and adds a test and NEWS.
I'll apply upon your ack.

thanks!
Pádraig.
Yes, it looks better now

Thanks
Petr



reply via email to

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