
Can't locate module when using suid - why?
After a couple of weeks of re-re-reading the perl documentation, I finally
managed to run a PERL script as another user id using the suid bit (this is
ultimately for a CGI script I'm working on, but for now I'm running it from
the shell).
I've written a really simple script, test.pl (see end of post) and a test
module, testmod.pl (ditto) and then used the wrapsuid.pl script which came
with PERL to make a C wrapper: test.pl is renamed as .test.pl, and a C
executable called test.pl is put in its place, which calls .test.pl.
This is running under Linux by the way...
The file permissions are such:
(the directory where my test files live)
drwxr-x--- 2 listmast list 1024 Apr 5 14:11 ./
(the files)
-rwxr-x--- 1 listmast list 191 Apr 5 13:10 .test.pl*
-rws--x--- 1 listmast list 3952 Apr 5 13:59 test.pl*
-rwxr-x--- 1 listmast list 62 Apr 5 13:10 testmod.pm*
Now, running as user 'lars', which is also in the list group, I can quite
happily execute the .test.pl script directly. But, although my test script
doesn't do anything which requires suid'ing to another use, that's what I
intend to do eventually...
So, as user 'lars', I chdir into the above directory and try executing test.pl
(ie. the C executable), and get the following error:
Nevertheless, I can run PERL scripts using the above method if they don't
contain modules. At the moment I have worked around it by putting an absolute
pathname, but I would rather not do this.
Can anyone explain why the PERL script doesn't seem to know where to look for
modules when run from the C wrapper?
Here are my test scripts:
test.pl
--------
#!/usr/local/bin/perl
require (testmod);
print "Content-type: text/html\n\n";
print "<html><head></head><body><p>\n";
print "Hello there...\n";
&blah::test;
print "</p></body></html>\n";
testmod.pm
--------------
package blah;
sub test {
print "This is working!\n";
Quote:
}
1;
If you wish to e-mail me, write to:
(after removing notthisbit that is)