docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.81k stars 2k forks source link

Broken exec(), shell_exec() and similar functions in Bookworm docker images #1432

Closed Pinkbyte closed 9 months ago

Pinkbyte commented 1 year ago

Test script:

<?php
error_reporting(E_ALL);

exec('/bin/ls /', $output, $err);
print_r($output);
echo $err;
?>

With 8.2.8-apache-bookworm and 8.1.22-apache-bookworm i got this output(broken):

Warning: exec(): Unable to fork [/bin/ls /] in /var/www/html/2.php on line 4
Array
(
)
-1

With 8.2.8-apache-bullseye and 8.1.22-apache-bullseye i got this output(works fine):

Array
(
    [0] => bin
    [1] => boot
    [2] => dev
    [3] => etc
    [4] => home
    [5] => lib
    [6] => lib64
    [7] => media
    [8] => mnt
    [9] => opt
    [10] => proc
    [11] => root
    [12] => run
    [13] => sbin
    [14] => srv
    [15] => sys
    [16] => tmp
    [17] => usr
    [18] => var
)
0
tianon commented 9 months ago

This is likely due to seccomp -- probably need to update Docker, runc, and libseccomp on your host.

https://github.com/docker-library/python/issues/837#issuecomment-1599640563

Barbery commented 3 months ago

upgrade docker version can solve this problem