Re: perl lost its modules!
by boftx (Deacon) on Apr 01, 2014 at 23:51 UTC
|
This is a long shot, but is it possible that one of the earlier dirs in @INC has permissions that prevent perl from looking in it and is causing perl to terminate the search early? That "permission denied" message might make that feasible.
Edit: Another thought, do you know for sure what effective uid/gid perl is running under? Is it possible the SUID bit is set? Like I said, these are long shots at best.
It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
| [reply] |
|
This is a long shot, but is it possible that one of the earlier dirs in @INC has permissions that prevent perl from looking in it and is causing perl to terminate the search early?
Actually that is almost certainly the issue. The OP has /root first in the path which normally isn't accessible, and perl 5.18.0 onwards stops and errs on failure:
$ perl5180 -I/root -Mstrict -e 1
Can't locate strict.pm: Permission denied.
BEGIN failed--compilation aborted.
$
Dave. | [reply] [d/l] |
|
| [reply] |
|
|
|
|
Re: perl lost its modules!
by roboticus (Chancellor) on Apr 01, 2014 at 23:25 UTC
|
seandarcy:
Is it possibly finding them in a previous directory (e.g., /root/perl5/lib/perl5) where they exist but you *don't* have permission to read/execute them?
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
|
# locate strict.pm
/usr/share/perl5/strict.pm
And there's only one lib.pm in the @INC hierarchy:
# locate /lib.pm
/root/.cpan/build/local-lib-1.008004-GOPHT9/blib/lib/local/lib.pm
/root/.cpan/build/local-lib-1.008004-GOPHT9/lib/local/lib.pm
/usr/lib64/perl5/lib.pm
The Fedora installation does set PERL5LIB to /root/perl5, but that folder does not exist,
$ echo $PERL5LIB
/root/perl5/lib/perl5/x86_64-linux-thread-multi:/root/perl5/lib/perl5
# ls -l /root/perl5
ls: cannot access /root/perl5: No such file or directory
I'm really stumped.
| [reply] [d/l] [select] |
Re: perl lost its modules!
by LanX (Saint) on Apr 01, 2014 at 21:40 UTC
|
hmm shooting in the dark:
- which permissions does the directory /usr/share/perl5 have?
- does use lib '/usr/share/perl5' help?
- could you try printing @INC within a BEGIN block to exclude weird settings which only apply afterwards?
Cheers Rolf
( addicted to the Perl Programming Language)
| [reply] [d/l] [select] |
|
ls -l /usr/share | grep perl5
drwxr-xr-x. 49 root root 4096 Mar 31 18:40 perl5
I don't see how it's a system permissions issue. As user, I can cat the file
made a small test script:
$ cat perl-test.pl
#!/usr/bin/perl
use lib '/usr/share/perl5';
use strict;
print "ok";
$ chmod +x perl-test.pl
$ ./perl-test.pl
Can't locate lib.pm: Permission denied at ./perl-test.pl line 2.
BEGIN failed--compilation aborted at ./perl-test.pl line 2.
Not sure what you mean by printing @INC in a BEGIN block, but I sure don't know how. | [reply] [d/l] [select] |
|
> I don't see how it's a system permissions issue. As user, I can cat the file
Directory permissions distinguish between accessing files and reading the directory. If Perl can't read the dir then it can't find the modules, while it's still possible to access the files by full path.
Anyway it seems boftx already found the solution further down. :)
Cheers Rolf
( addicted to the Perl Programming Language)
| [reply] |
Re: perl lost its modules!
by hippo (Bishop) on Apr 01, 2014 at 21:44 UTC
|
Have you checked the audit log? It may simply be a case of incorrect contexts. For reference, my strict.pm is system_u:object_r:usr_t:s0
| [reply] |
|
grep ^SELINUX= /etc/selinux/config
SELINUX=permissive
And I thought this would be a winner! | [reply] [d/l] |
Re: perl lost its modules!
by Laurent_R (Canon) on Apr 01, 2014 at 22:39 UTC
|
No idea, but maybe changing file permissions to 755 or possibly even 775 for every file in the INC hierarchy might solve the issue.
| [reply] |
|
That's a bad idea.
You shouldn't change the permissions on files in /usr directories except for the ones that you (the system administrator) own like in /usr/local.
Furthermore, running a command like chmod -R is especially dangerous, if you do not understand what you are doing.
The *.pm files in /usr are supposed to have 0644 permissions. They should not be set with execute. They are not executable files, after all.
Having said all that, this particular change is most likely benign. But you should never change files in the /usr directory except your own. These files and their permissions are managed by the system and rpm(8) in the OP's case.
Run the command rpm -V perl to see all the "damage" now.
| [reply] [d/l] [select] |
|
| [reply] [d/l] |
Re: perl lost its modules!
by Anonymous Monk on Sep 07, 2015 at 18:10 UTC
|
Hi,
Thanks to this thread I found out why my script was failing with a similar error. All was fine with the root and user account, but failed when I sudo -u myser in root crontab. The @INC included (last, well hidden) the '.' which was actually... /root of course. So just a cd in the launching shell script and voila, but it took me too much effort and wasted time over this (stupid) new perl behaviour. I do not give a damn if @INC (or PATH, or LD_LIBRARY_PATH or WHATEVER PATH) includes a sometimes non-readable directory. My special thanks for the wasted time (and VERY unhappy clients of mine) to all the morons who coded this new perl behavior. | [reply] |
|
I agree that it's really frustrating when upgrading your Perl breaks stuff.
In this case, the error message that Perl spits out when it cannot compile for this reason (missing permissions on a directory in @INC) should include a warning about the fact that it has stopped searching @INC. It does emit a message (with brevity, and still without specifically saying that the directory permissions were missing, and stating the full path of the file even if it doesn't know whether the file exists), starting in Perl 5.21.7:
$ perl5217 -I/root -Mstrict -e 1
Can't locate strict.pm: /root/strict.pm: Permission denied.
BEGIN failed--compilation aborted.
There is a currently open bug discussing this, with the reporter calling for the change to be rolled back. You can also read the bug issue report that prompted the change in the first place.
Note that the directory must be executable, and the file readable. Having the directory readable if it's not executable doesn't help, on my machine at least. Using Perl 5.22:
[14:14][nick:~]$ sudo ls -la /var/noperms
total 0
dr--r--r-- 3 root wheel 102 Sep 7 14:06 .
drwxr-xr-x 28 root wheel 952 Sep 7 13:38 ..
-r--r--r-- 1 root wheel 0 Sep 7 14:06 strict.pm
[14:14][nick:~]$ perl -I/var/noperms/ -Mstrict -e 1
Can't locate strict.pm: /var/noperms/strict.pm: Permission denied.
BEGIN failed--compilation aborted.
. . . the directory doesn't have to be readable at all, as long as it's executable:
[14:17][nick:~]$ sudo ls -la /var/noperms
total 0
d--x--x--x 3 root wheel 102 Sep 7 14:06 .
drwxr-xr-x 28 root wheel 952 Sep 7 13:38 ..
-r--r--r-- 1 root wheel 0 Sep 7 14:06 strict.pm
[14:17][nick:~]$ perl -I/var/noperms/ -Mstrict -e 1
strict.pm did not return a true value.
BEGIN failed--compilation aborted.
And it definitely prints the full path of the file it's looking for, even if it can't read the directory, making for a very confusing error message:
[14:19][nick:~]$ sudo ls -la /var/noperms
total 0
d--------- 2 root wheel 68 Sep 7 14:19 .
drwxr-xr-x 28 root wheel 952 Sep 7 13:38 ..
[14:19][nick:~]$ perl -I/var/noperms/ -Mstrict -e 1
Can't locate strict.pm: /var/noperms/strict.pm: Permission denied.
BEGIN failed--compilation aborted.
The way forward always starts with a minimal test.
| [reply] [d/l] [select] |
|
| [reply] |
|
|
Hi, Thanks to this thread I found out why my script was failing with a similar error. All was fine with the root and user account, but failed when I sudo -u myser in root crontab. The @INC included (last, well hidden) the '.' which was actually... /root of course. So just a cd in the launching shell script and voila, but it took me too much effort and wasted time over this (stupid) new perl behaviour. I do not give a damn if @INC (or PATH, or LD_LIBRARY_PATH or WHATEVER PATH) includes a sometimes non-readable directory. My special thanks for the wasted time (and VERY unhappy clients of mine) to all the morons who coded this new perl behavior. :) Why did you make an upgrade without testing first?
| [reply] |
|
Hi, I'm having the same problem here, bud I don't understand how you solve it.
I'm a non-root user, and have no authority to root.
| [reply] |
|
| [reply] |
|
Solve what exactly? Complain to whomever has root?
| [reply] |
|