Bug #74585 [Nab->Opn]: chroot doesn't change __DIR__ constant

From: Date: Fri, 12 May 2017 20:40:52 +0000
Subject: Bug #74585 [Nab->Opn]: chroot doesn't change __DIR__ constant
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209092@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74585&edit=1 ID: 74585 Updated by: requinix@php.net Reported by: joomla at itronic dot at Summary: chroot doesn't change __DIR__ constant -Status: Not a bug +Status: Open Type: Bug Package: CGI/CLI related Operating System: Linux PHP Version: 7.0.19 Block user comment: N Private report: N New Comment: It's chroot, not chdir. The idea is that __DIR__ and friends should be updated to reflect the new path to the file after the chroot(2) call. Which is not necessarily possible (eg, file is outside the new root) so I don't know if anything can/should be done about it anyways. echo __FILE__; // originally /path/to/file.php chroot("/path"); echo __FILE__; // now /to/file.php Previous Comments: ------------------------------------------------------------------------ [2017-05-12 20:29:18] dm@php.net > __DIR__ The directory of the file. It is not affected by chdir(), as expected, maybe you're looking for getcwd(). ------------------------------------------------------------------------ [2017-05-12 19:28:15] joomla at itronic dot at Description: ------------ If you change the root dir, the __DIR__ doesn't reflect the change. Maybe this effects other Magic constants. Test script: --------------- chroot('/tmp'); echo __DIR__; Expected result: ---------------- __DIR__ should have the correct path. Actual result: -------------- The old path ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74585&edit=1

« previous php.bugs (#209092) next »