oh yeah, and be careful.. make sure your script has an array of commands its allowed to run, that way no one can cat /etc/passwd through your script or something like that. if you're going to need to cehck files on the system.. it might pay to setup an array of those files, that way no one can access anything you don't want them to see via your script. ie:
my @CMDS = ("ps", "top", "df", "vmstat", "blah"); my @FILES = ( "/etc/running.cfg", "/home/me/lastchecked.txt", "/var/l +og/httpd/error_log"); my ($cmd, @ARGS) = split(/\s/, $input); my $ok; for(@CMDS) { if($cmd eq $_) { $ok=1; } } if(!$ok) { die "tried to do something that wasn't cool: $input\n"; } # then check for files in args my $ok=0; my $arg; foreach $arg (@ARGS) if(-e $arg) { # we have a file $file=true; for(@FILES) { if($arg eq $_) { $ok=1; } } } } if($file && !$ok) { die "tried to access a bad thing: $input\n"; } # We're pretty much safe to continue

untested, but you get the idea.. make sure that only what you anticipate being input is actually input, that way you can pretty much secure the script.. also run it as a user with as little privileges as possible..

-brad

In reply to Re: RPC by reyjrar
in thread RPC by jeffa

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.