http://www.perlmonks.org?node_id=791479

astroboy has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm trying to run a script that changes my effective user id. The permissions are 6550 (-r-sr-s---) owner = root, and I'm running the script as a member of the group that is given group execute permissions.

#!/usr/bin/perl -T use strict; my $user = 'etl'; my $group = 'etl'; my $uid = getpwnam($user) || die "Cannot identify uid"; my $gid = getgrnam($group) || die "Cannot identify gid"; printf("Current Effective User ID: %s\n", $>); printf("Current Effective Group IDs: %s\n", $)); printf("Requested User ID: %s\n", $uid); printf("Requested Group ID: %s\n", $gid); print "Changing Effective IDs\n"; $> = $uid; $) = $gid; printf("Current Effective User ID: %s\n", $>); printf("Current Effective Group IDs: %s\n", $));

When the script as run as myself, the output is:

Current Effective User ID: 500 Current Effective Group IDs: 500 500 Requested User ID: 502 Requested Group ID: 503 Changing Effective IDs Current Effective User ID: 500 Current Effective Group IDs: 500 500

Note the effective ids haven't changed. However, when I run the script as root, the effective user id is what I requested, although the group ids haven't changed

Current Effective User ID: 0 Current Effective Group IDs: 0 0 1 2 3 4 6 10 Requested User ID: 502 Requested Group ID: 503 Changing Effective IDs Current Effective User ID: 502 Current Effective Group IDs: 0 0 1 2 3 4 6 10
So my question is: how do I change my effective user id? I'm using Perl 5.10.0 on Centos 5.3 Thnanks