I have a script that needs to run with the setuid bit on since it ends up writing to the file that eval can't evaluate. The script is securely accessed, so immediate security concerns regarding setuid should be allayed. Further, I'm not giving it super user power, just simple owner of the file power.

The script is run through a web browser and therefore starts life off with $< = getpwnam(nobody)[2] (not actually written but here for those of you needing a refresher on unix calls).

Anyway, here's the code that fails and the error message:

sub _read_config { my $fh = FileHandle->new("Config_filename", "r"); eval <$fh>; die "Config_filename improperly formatted:\n$@" if ($@); $fh->close(); }

Insecure dependency in eval while running setuid at ../Tools/CSSconfig +.pm line 38, <GEN0> line 1. Compilation failed in require at ../Tools.pm line 15, <GEN0> line1. BEGIN failed -- compilation aborted at ../Tools.pm line 15. Compilation failed in require at /home/PsychoSpunk/public_html/cgi-bin +/Tools/saveconfig.cgi line 7. BEGIN failed -- compilation aborted at /home/PsychoSpunk/public_html/c +gi-bin/Tools/saveconfig.cgi line 7.

The script itself is setuid, while my modules aren't. Would this be the cause of the adverse effect reported in my error_log file? Or is there something more insidious at play here? Of course, use strict and -w are in effect, and I did try placing the eval in a block with no strict; These efforts just moved the line numbers for the error.

Thanks for any advice. /msg me if you have questions.

ALL HAIL BRAK!!!


In reply to eval $fh while setuid... by PsychoSpunk

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.