Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

can't locate under mod_cgi

by hakkr (Chaplain)
on Aug 11, 2005 at 10:56 UTC ( [id://482903]=perlquestion: print w/replies, xml ) Need Help??

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

Monks,

I have spent many hours wrestling this problem.

I have source installs of mod_perl 1.29, apache 1.3.33 and perl 5.8.7.
I have a directory that I wish to add to @INC.

Under mod_perl this works fine, I just PerlSetEnv /dir in httpd.conf and that's it everything works.

The problem occurs whenever I run my scripts under mod_cgi they cannot find any code in my custom lib.

Everything works fine at command line and I have exported PERL5LIB as an environment variable in /etc/profile.

When I use CGI::Carp qw/fatalsToBrowser/;

I get 'Can't locate in @INC', @INC is then shown with my /dir proudly listed at the front laughing at me.

I have tried the follwing:
1. 'SetEnv /dir' in httpd.conf - @INC shows my dir in the error message but still i get the can't locate message.
2. use lib '/dir'; This has no affect on @INC, the script still dies when it hits a use statement.
3. unshift @INC, '/dir'; This also has no affect the script dies on use statement if I remove the use statement and print @INC step 2 and 3 show my dir as present.

This is driving me nuts,how can 'use lib' be ignored and unshifting onto @INC be ignored. I have tried using Module::Locate and printed %INC both to no avail. The only way it works is if I move my dir into the built in path /usr/local/lib/perl5/5.8.7/i686-linux /usr/local/lib/perl5/5.8.7 /usr/local/lib/perl5/site_perl/5.8.7/i686-linux /usr/local/lib/perl5/site_perl/5.8.7/ /usr/local/lib/perl5/site_perl/

I am using this same setup on other servers with the only difference being the perl version. the dir permissions are 755. This must be something todo with apache or taint but I am now at a loss what to try. grateful for any ideas thanks

update: fixed fatalsToBrowser typo

Replies are listed 'Best First'.
Re: can't locate under mod_cgi
by Happy-the-monk (Canon) on Aug 11, 2005 at 11:07 UTC

    use CGI::Carp/fatalstobrowser/;

    try   use CGI::Carp qw/fatalsToBrowser/;

    Cheers, Sören

Re: can't locate under mod_cgi
by extremely (Priest) on Aug 11, 2005 at 16:31 UTC
    Drop the taint flag and test. Consider turning on the full cgi logging stuff so you can see the entire output of the script when erroring... Look for the ScriptLog directive. Also, is suExec involved? It can do really evil and surprising things.

    --
    $you = new YOU;
    honk() if $you->love(perl)

      extremely Many thanks, ScriptLog does not seem to work in this case but it looks very useful. With your suexec tip I think I am now on the right track.

      Discovered that if I move my libs into the dir as root then it does not work. If I move them in as my own user it does. Which is strange as apache runs as nobody, maybe the umask on root is messing with something. root umask is 0022 my umask is 0002, not sure why but I think thats it, boy am I bad at playing the sys admin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found