Guest User

Untitled

a guest
Jan 22nd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ## PHP FFI obsoletes pecl/pledge
  2.  
  3. Example with pecl/pledge:
  4.  
  5. ```shell
  6. $ cat test_pecl.php
  7. <?php
  8.  
  9. var_dump(count(scandir('/etc')));
  10. unveil(__DIR__, 'r');
  11. scandir('/etc');
  12.  
  13. $ php -dextension=pledge test_pecl.php
  14. int(77)
  15.  
  16. Warning: scandir(/etc): failed to open dir: No such file or directory in /home/tvl/test_pecl.php on line 5
  17.  
  18. Warning: scandir(): (errno 2): No such file or directory in /home/tvl/test_pecl.php on line 5
  19. ```
  20.  
  21. Same example with (core extension) FFI:
  22.  
  23. ```shell
  24. $ cat test_ffi.php
  25. <?php
  26.  
  27. $libc = FFI::cdef('
  28. int unveil(const char *path, const char *permissions);
  29. ', 'libc.so.92.5');
  30.  
  31. var_dump(count(scandir('/etc')));
  32. $libc->unveil(__DIR__, 'r');
  33. scandir('/etc');
  34.  
  35. $ php -dextension=ffi test_ffi.php
  36. int(77)
  37.  
  38. Warning: scandir(/etc): failed to open dir: No such file or directory in /home/tvl/test_ffi.php on line 9
  39.  
  40. Warning: scandir(): (errno 2): No such file or directory in /home/tvl/test_ffi.php on line 9
  41. ```
Add Comment
Please, Sign In to add comment