Within suidperl, I can do:
system("/bin/touch /test");
but
system("/bin/echo testing > /test");
fails with error: sh /test: Permission denied
I have the script suid 4754 with owner root.
/ is owned by root.root with perms 755.
Adding the line system("/usr/bin/id") confirms that I indeed am euid=0(root) with my normal uid/gid.
I don't understand why suidperl allows me to create (i.e. touch) a file by doesn't allow me to write to it by standard shell redirection.
Note, what I'm really trying to do is the following -- write the output of a command that I need to run suid root to a compressed file in a directory owned by root, but I simplified the code above to isolate the problem. Here is a snippet of the code I am trying to use (where nothing is tainted)
open STDOUT, "| /bin/gzip >| /logfile.gz";
system("my command", "arg1", "arg2")
I can get it to work if I do the 'gzip' within a system command rather than as part of the pipe but then I need an intermediate file and 2 system calls.
open STDOUT, "/logfile";
system("my command", "arg1", "arg2")
system("gzip","-f","/logfile");
Is there any way to code what I want without that problem? (note that for added security, I am trying to not use the shell as part of the 'system' command)
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.