GNU bug report logs - #7320
'group' command gives wrong/extra group

Previous Next

Package: coreutils;

Reported by: owen <at> illinois.edu

Date: Tue, 2 Nov 2010 21:41:01 UTC

Severity: normal

Tags: fixed

Fixed in version 8.18

Done: Jim Meyering <meyering <at> hx.meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Petr Stodůlka <pstodulk <at> redhat.com>
Cc: coreutils <at> gnu.org, 7320 <at> debbugs.gnu.org
Subject: bug#7320: [PATCH] 'id' prints incorrectly groups for the session
Date: Thu, 26 Jun 2014 02:53:08 +0100
[Message part 1 (text/plain, inline)]
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.
[id-effective-group.patch (text/x-patch, attachment)]

This bug report was last modified 10 years and 330 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.