Subject: | abs_path fails if permissions of pwd is 0 |
If the current directory is not readable and executable, abs_path fails.
This issue is present in version 3.05.
To reproduce, use the script provided, and issue the following commands:
Show quoted text
> mkdir /tmp/foo
> cd /tmp/foo
> chmod 0 .
> ~/test_abs_path.pl /tmp
Use of uninitialized value in print at test_abs_path.pl line 6.
XS abs_path is :
fast_abs_path failed: Cannot chdir back to : No such file or directory
at test_abs_path.pl line 11
perl_abs_path is :/tmp
As you can see, the XS version is returning undef, fast_abs_path fails,
but _perl_abs_path works. This problem reared its head when a setuid
perl script tried to use FindBin in a directory owned by a different
user. I traced the problem to an abs_path call in FindBin.
Subject: | test_abs_path.pl |
use strict;
use warnings;
use Cwd;
eval {
print "XS abs_path is :", Cwd::abs_path($ARGV[0]), "\n";
};
warn "XS abs_path failed: $@" if $@;
eval {
print "fast_abs_path is :", Cwd::fast_abs_path($ARGV[0]), "\n";
};
warn "fast_abs_path failed: $@" if $@;
eval {
print "perl_abs_path is :", Cwd::_perl_abs_path($ARGV[0]), "\n";
};
warn "perl_abs_path failed: $@" if $@;