Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Might there be some bug in glob under apache?

by markseger (Beadle)
on Feb 14, 2012 at 21:10 UTC ( [id://953771]=perlquestion: print w/replies, xml ) Need Help??

markseger has asked for the wisdom of the Perl Monks concerning the following question:

This is very bizarre and I don't know if anyone can actually test this. I have a very simple script as follows:
#!/usr/bin/perl -w my $foo="/tmp/*"; my @glob=glob($foo); my $size=scalar(@glob); print "Content-type: text/html\n\n"; print "<html><head>\n"; print "SIZE: $size\n"; print"</head></html>\n";
and as expected, when I run it on a webserver it reports the number of files in /tmp.

But when I run in on RHEL6.2 in a VirtualBox VM it reports 0. Furthermore, when I point it to a different directory, in my case /usr/share/collectl/plotfiles, it works correctly. Since /tmp has the sticky bit set I even created /tmp2 and tried it against that directory. Still reported 0.

I had convinced myself it was a problem in RHEL6.2 but then I remembered I has another system running VMware/RHEL6.2 and I tried it there and it works fine! This makes me wonder if there's something funky about a vm in the virtualbox environment and/or a possible problem with glob itself in such an environment.

I did try running readdir instead of glob and it worked just fine, but I'd really like to get to the bottom of this if th is really is a bug.

Can anyone suggest any other experiments I might be able to try to add more context to this?

-mark

Replies are listed 'Best First'.
Re: Might there be some bug in glob under apache?
by Anonymous Monk on Feb 14, 2012 at 21:17 UTC

    Might there be some bug in glob under apache?

    There is no chance of that, that should be the furthest thing from your mind as you're not doing any sort of error checking.

    chroot and SELinux and generally permissions always play a part, always

      Where would you suggest doing error checking? I thought either glob succeeds and returns a list or fails and doesn't. If it succeeds it will print a non-zero number and if it fails it would return zero. It does seem to me it is failing but how would I get more clarity as to why?

      As for bugs being furthest from my mind, I guess my finding solid bugs in both HiRes::Time and Compress::Zlib have reinforced my belief that no code is perfect nor can be tested in all environments.

      -mark

        Where would you suggest doing error checking? I thought either glob succeeds and returns a list or fails and doesn't. If it succeeds it will print a non-zero number and if it fails it would return zero. It does seem to me it is failing but how would I get more clarity as to why?

        One way

        $ perl -le " print glob 'foo/*'; warn sprintf q/ERRRR(%d)(%s)(%d)(%s)/ +, $!,$!,$^E,$^E; " ERRRR(22)(Invalid argument)(5)(Access is denied) at -e line 1. $ perl -le " print glob 'nonexist/*'; warn sprintf q/ERRRR(%d)(%s)(%d) +(%s)/, $!,$!,$^E,$^E; " ERRRR(2)(No such file or directory)(3)(The system cannot find the path + specified) at -e line 1. $ ls -loanh foo ls: reading directory ado: Permission denied total 0 $ ls -loanh nonexist ls: nonexist: No such file or directory

        As for bugs being furthest from my mind ...

        .oO{{{ Something is wrong, but I don't know what, or how to check, must be a bug in my tools }}} -- Ah yes, and you are the first person to have noticed this bug since 1994. Sure.; also known as superstition :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://953771]
Approved by bluescreen
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-18 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found