Subject: bug#18946: a problem or a 'bug' about the command groups

From: Eric Blake <[email-masked]>
Date: Tue, 04 Nov 2014 18:10:02 +0100

On 11/04/2014 06:04 PM, Eric Blake wrote:
> tag 18946 notabug
> thanks
> 
> On 11/04/2014 12:43 PM, yangzhao wrote:
>> Excuse me,
>>              I use command 'group -d ' to delete   user  ak from a group  testgroup. Then ,something confusing comes to me.I use command groups as ak ,and get ak ,testgroup  ,them two. But when I use groups ak , I get ak only. And I take a look at /etc/group for testgroup ,there is nothing with ak,so I want to ask ,which file does command groups look up ?
> 
> 'groups' tells you the groups associated with the current process, which
> is not necessarily the same as you would get by starting a new session
> for that user.  'groups ak' tells you the groups that are associated
> with the user name 'ak' as determined by an /etc/group lookup (or
> similar action), which is what you would get when starting a new session.
> 
> Most likely, what happened is that in your testing, you have NOT YET
> logged out and back in to start a new session.  Thus, the current
> process is STILL associated with testgroup, even though new sessions
> (and though 'group ak') will no longer be associated with testgroup.

If you want to see what operations are being done in the two scenarios,
try running 'strace groups' and 'strace groups ak'; you'll notice
different syscalls between the two (those for determining the group
membership of the current process, vs. those used for determining the
groups to use when starting a new session).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org