From: Eric E. Coe Date: Wed, 18 Oct 2000 04:03:54 +0000 (-0400) Subject: Make Cwd more bulletproof in chrooted environments. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea54c8bdf9458e2c187f15a2e52ca7cc0f735ef1;p=p5sagit%2Fp5-mst-13.2.git Make Cwd more bulletproof in chrooted environments. Subject: [ID 20001018.001] Fix for Cwd.pm (chroot) Message-Id: <39ED596A.70E599FE@oracle.com> p4raw-id: //depot/perl@7358 --- diff --git a/lib/Cwd.pm b/lib/Cwd.pm index dbeae69..7279591 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -89,7 +89,15 @@ sub _backtick_pwd { # Since some ports may predefine cwd internally (e.g., NT) # we take care not to override an existing definition for cwd(). -*cwd = \&_backtick_pwd unless defined &cwd; +unless(defined &cwd) { + # The pwd command is not available in some chroot(2)'ed environments + if(grep { -x "$_/pwd" } split(':', $ENV{PATH})) { + *cwd = \&_backtick_pwd; + } + else { + *cwd = \&getcwd; + } +} # By Brandon S. Allbery