Brian Candler
6/3/2007 7:00:00 PM
On Sun, Jun 03, 2007 at 11:28:59PM +0900, Scott McNab wrote:
> irb(main):001:0> `groups`
> => "root bin daemon sys adm disk wheel\n"
> irb(main):002:0> Process::GID.change_privilege(502)
> => 502
> irb(main):003:0> Process::UID.change_privilege(502)
> => 502
> irb(main):004:0> `groups`
> => "scott root bin daemon sys adm disk wheel\n"
> irb(main):005:0>
>
> * Notice here how the process has correctly assumed the privileges of
> group 'scott', but is missing the 'testdev' group.
Try using Process.initgroups
> Note: if I do the same thing using shell commands I get the correct
> result as expected:
>
> [root@localhost ~]# groups
> root bin daemon sys adm disk wheel
> [root@localhost ~]# su - scott
> [scott@localhost ~]$ groups
> scott testdev
> [scott@localhost ~]$
If you look at the source code to su, you'll probably find it calls
initgroups() somewhere.
Regards,
Brian.