Friday, March 04, 2022

Unveil makes PHP behave strange with "Primary script unknown" errors

How to reproduce:

1. Install PHP-FPM 8.1 and pecl81-pledge-2.0.2p3
2. Enable the module in php-8.1.ini

    extension=pledge

3. Make a simple PHP script that prints "Hello world"

    <?php
    echo '<p>Hello world</p>';

4. Run the script to see all is working normally.
5. Then add an unveil call:

    <?php
    echo '<p>Hello world</p>';
    unveil('/var', 'r');

6. Run the script a couple of times. Refresh. Until the error occurs.

    PHP message: PHP Warning:  Unknown: Failed to open stream: No
    such file or directory in Unknown on line 0Unable to open
    primary script: /htdocs/foo.example.com/public/foo.php <http://foo.example.com/public/foo.php> (No such
    file or directory)

If you keep refreshing, the browser will then eventually print the error:

    File not found.

And the log error message will change to:

    Primary script unknown
    Primary script unknown
    Primary script unknown

You then have to restart PHP-FPM to make it work again.

Kind regards.

--
Sent with Tutanota, the secure & ad-free mailbox.

No comments:

Post a Comment