I have a line in a script that looks like this:

opendir(DIR, $Path->{'real'});

This call returns false. The value of $Path->{'real'} is defined by a module that gets the value from a conf file. If I print out the value I get the following:

/usr/

This directory of course exists, so the following code returns true:

opendir(DIR, "/usr/");

Strangely, so does this code:

$Path->{'real'} = "/usr/"; opendir(DIR, $Path->{'real'});

This led me to think $Path->{'real'} was tainted and therefore not usable in the opendir call, however it still doesn't work if I untaint it like so:

$Path->{'real'} =~ /(.*)/; $Path->{'real'} = $1; opendir(DIR, $Path->{'real'});

This code is a functioning part of mozilla.org's installation of LXR running on a Solaris box with perl 5.004. I am trying to get it working on my own RedHat Linux 7.0 machine running 5.6.1. What could be going wrong here?


In reply to why would opendir fail? by Anonymous Monk

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.