Effective Group ID not changing

A

Aaron Baugher

I have a program that runs as root and accepts logins and commands
through a network socket. On each login, it changes the effective uid
and gid to that of the user, like so:

my( $uid, $gid ) = (getpwnam($user))[2,3];
$> = $uid;
$) = $gid;

In most cases, $gid will be 1001, and $uid will be > 1000. This
worked fine on FreeBSD, and files created after this point would be
created with the uid/gid ownership assigned here. I recently tried
running this program on RedHat (perl 5.6.1), and the gid doesn't
change, although the uid does. If I print $), it still contains a
list of root's groups, and files created get root's group ownership.

Is there something I should be doing differently to get this to work?
My program has to be able to reset these values repeatedly; that's why
I don't set $( (Real gid). I figured I wouldn't be able to set it
back after that.


Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top