The documentation for the Cwd module states that fast_abs_path
is a "more dangerous, but potentially faster version of abs_path
". In what way is it dangerous? Under what circumstances is it faster? Does the behavior vary by platform?
fast_abs_path
invokes chdir
to have the kernel resolve the path leading up to what you passed it all at once, instead of carefully checking each component and building a new path piece by piece; the problem is that it is possible that permissions would prevent it from chdir
ing back to the original directory afterward. (Some systems can use open
and fchdir
to get around this, but it's not reliably available on all platforms where Perl runs.)
Whether this can even occur depends on whether it is possible for your script to execute in a directory which it would not be able to access directly. On Unix-like systems this can happen when a setuid wrapper chdir
s to a restricted permissions area and then drops the setuid. (Historically the restricted permissions are on a path component named lock
; various mail and Usenet news subsystems have used this to protect their queue directories.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With