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

In reply to Changing effecive user id by astroboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.