Some code might clarify. The man page to
read first is perlsec. Tainting and setuid are
very complex issues. Here's a transcript
of what I think
you were trying to do originally. Note that
the last prompt "$" is run as myself instead of
root.
# cat s.c
main(int ac, char **av) { execv("/home/thayer/foo.pl", av); }
# gcc s.c -o s
# chown root s; chmod a+rx,u+s s ; ls -l s
-rwsrwxr-x 1 root users 11394 Dec 15 11:43 s
# cat foo.pl
#!/usr/local/bin/perl -T
print "$< $>\n";
# ls -l foo.pl
-r-xr-xr-x 1 thayer users 43 Dec 15 11:42 foo.pl
$ ./s
3068 0
When it comes to suid and perl, running on the
command line is different than running from a
real file. In unix there's a race condition
running scripts, #! files, between the time
the kernel detects what script program to use and
when the
script actually reads the file.
Using a compiled
wrapper or sudo are common work-arounds.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.