Why does @INC change when the setgid bit of the C shell around the perl script changes?

All this on RHEL6

I am trying to run a perl script as a specific user (the owner of a perl script), wrapping it inside the C binary, and then setting the setgid bit of the binary (ref: https://superuser.com/questions/440363/can-i-make-a -script-always-execute-as-root ). The perl script uses various perl modules. If the perl modules are in the PERL5LIB account trying to run the C binary, and the setgid bit is NOT set in the C binary, it works fine. If the setgid bit IS is set, then it fails because the perl modules used are not in @INC.

Some code to demonstrate how @INC changes with a sticky bit ...

the.pl

#!/usr/bin/env perl
print "Size of INC: ".scalar(@INC)."\n";
exit;

wrapper.c

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  exit(execvp("/home/me/the.pl",(char **)argv));
}

perl script: -rwxrwxr-x

-rwxr-xr-x ( , setgid ), , ...

Size of INC = 87

... , ( PERL5LIB 87 ).

-rwxr-sr-x ( , setgid ), , ...

Size of INC = 4

, PERL5LIB 87 .cshrc perl script, , .

perl script, , . root .

PERL5LIB? ?

, Advance!

+6
1

Setuid perl script taint, perlsec :

taint ( "-T" ), "."         @INC, "PERL5LIB" "PERLLIB" -         Perl. @INC         "-I", perlrun.         , ,         , , "-I"         .

@INC (, use lib ...), C, perl script, argv script -I..., .

+7

All Articles