Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## PHP FFI obsoletes pecl/pledge
- Example with pecl/pledge:
- ```shell
- $ cat test_pecl.php
- <?php
- var_dump(count(scandir('/etc')));
- unveil(__DIR__, 'r');
- scandir('/etc');
- $ php -dextension=pledge test_pecl.php
- int(77)
- Warning: scandir(/etc): failed to open dir: No such file or directory in /home/tvl/test_pecl.php on line 5
- Warning: scandir(): (errno 2): No such file or directory in /home/tvl/test_pecl.php on line 5
- ```
- Same example with (core extension) FFI:
- ```shell
- $ cat test_ffi.php
- <?php
- $libc = FFI::cdef('
- int unveil(const char *path, const char *permissions);
- ', 'libc.so.92.5');
- var_dump(count(scandir('/etc')));
- $libc->unveil(__DIR__, 'r');
- scandir('/etc');
- $ php -dextension=ffi test_ffi.php
- int(77)
- Warning: scandir(/etc): failed to open dir: No such file or directory in /home/tvl/test_ffi.php on line 9
- Warning: scandir(): (errno 2): No such file or directory in /home/tvl/test_ffi.php on line 9
- ```
Add Comment
Please, Sign In to add comment