Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: setuid and setgid leaves user in 0 (wheel) group

by bingos (Vicar)
on Dec 17, 2010 at 12:21 UTC ( #877631=note: print w/replies, xml ) Need Help??

in reply to setuid and setgid leaves user in 0 (wheel) group

According to perlvar for $):

The first number sets the effective gid, and the rest (if any) are passed to setgroups(). To get the effect of an empty list for setgroups(), just repeat the new effective gid


$) = "$gid $gid";

The following code on my machine (NetBSD):

use strict; use warnings; use POSIX; my( $uid, $gid ) = qw/32767 32766/; setgid( $gid ); $) = "$gid $gid"; $( = $gid; die "Set group ($gid): $! +" if ( $( != $gid ) or ( $) != $gid ); setuid( $uid ); $> = $uid; $< = $uid; die "Set user ($uid): $!" if ( $< != $uid ) or ( $> != $uid ); print `id`;


uid=32767(nobody) gid=32766(nogroup) groups=32766(nogroup)

Replies are listed 'Best First'.
Re^2: setuid and setgid leaves user in 0 (wheel) group
by petr999 (Acolyte) on Dec 17, 2010 at 13:26 UTC
    $) = "$gid $gid"
    Cool, it works, thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877631]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2016-10-21 21:03 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.