Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: apache 2.4 mod_perl permission denied on standard modules

by Crackers2 (Parson)
on Aug 28, 2015 at 19:51 UTC ( [id://1140373]=note: print w/replies, xml ) Need Help??


in reply to Re: apache 2.4 mod_perl permission denied on standard modules
in thread apache 2.4 mod_perl permission denied on standard modules

Runs under a dedicated user; if I su to that user I can read the modules in question without issue, and a perl -e'use MyHandler' as that user works fine as well.

If I add a block like this:

use warnings; BEGIN { open my $fh, ">>", "/tmp/x"; print $fh "@INC\n"; open my $in, "<", "/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/D +igest/SHA.pm"; while (<$in>) { print $fh $_; } close $in; close $fh; } use Apache2::Const qw(:common); use Digest::SHA qw(sha256_hex sha1_hex);

then /tmp/x ends up with:

/etc/apache2/script /srv/www/perl-lib /usr/lib/perl5/site_perl/5.18.2/ +x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.18.2 /usr/lib/pe +rl5/vendor_perl/5.18.2/x86_64-linux-thread-multi /usr/lib/perl5/vendo +r_perl/5.18.2 /usr/lib/perl5/5.18.2/x86_64-linux-thread-multi /usr/li +b/perl5/5.18.2 /usr/lib/perl5/site_perl . /srv/www package Digest::SHA; require 5.003000; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use Fcntl; use integer; $VERSION = '5.84_01'; require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); @EXPORT_OK = qw( hmac_sha1 hmac_sha1_base64 hmac_sha1_hex ...

So the script can definitely read the file.

Replies are listed 'Best First'.
Re^3: apache 2.4 mod_perl permission denied on standard modules
by 1nickt (Canon) on Aug 28, 2015 at 20:03 UTC

    Is there another copy of the module in a directory (with different file permissions) that is earlier in @INC than the one you read in your test script?

    The way forward always starts with a minimal test.

      Nope, no copies of Digest/SHA.pm anywhere else

      If I manually add

      require "/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/Digest/SHA.pm +";

      in a BEGIN block, the error in the apache log changes to:

      Can't locate Fcntl.pm: Permission denied at /usr/lib/perl5/5.18.2/x +86_64-linux-thread-multi/Digest/SHA.pm line 7.

      If I also add an explicit

      use lib '/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/'

      It ends up with:

      Can't locate integer.pm: Permission denied at /usr/lib/perl5/5.18.2/ +x86_64-linux-thread-multi/Digest/SHA.pm line 8

      With this BEGIN block:

      BEGIN { foreach (@INC) { use lib $_; } }

      which I think should be pretty much a noop (I also tried with reverse @inc, same result) I end up with:

      Can't locate Carp.pm: Permission denied at /usr/lib/perl5/5.18.2/x86 +_64-linux-thread-multi/lib.pm line 25

      And of course Carp.pm is there

        This really sounds as if there is at least one entry in @INC which is not readable for the user Apache is running as. As soon as Perl encounters such a directory, it will stop searching. So you should make sure that the relevant directories you have in @INC appear before the bad ones where the user does not have read permissions.

Log In?
Username:
Password:

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

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

    No recent polls found