Skip to content

copy(/tmp/wp-cli-cacert.pem): failed to open stream: Permission denied #4676

@acki

Description

@acki

If wp-cli is running by more than one user on the same server, there are conflicts creating the cacert.pem file in a global tmp directory. Because every instance of wp-cli is creating the same file, without prefixing it. This results in multiple errors like:

PHP Warning:  copy(/tmp/wp-cli-cacert.pem): failed to open stream: Permission denied in phar:///usr/local/bin/wp/php/utils.php on line 29
Warning: copy(/tmp/wp-cli-cacert.pem): failed to open stream: Permission denied in phar:///usr/local/bin/wp/php/utils.php on line 29
PHP Warning:  copy(/tmp/wp-cli-cacert.pem): failed to open stream: Permission denied in phar:///usr/local/bin/wp/php/utils.php on line 29
Warning: copy(/tmp/wp-cli-cacert.pem): failed to open stream: Permission denied in phar:///usr/local/bin/wp/php/utils.php on line 29

PHP Warning:  unlink(/tmp/wp-cli-cacert.pem): Operation not permitted in phar:///usr/local/bin/wp/php/utils.php on line 34
Warning: unlink(/tmp/wp-cli-cacert.pem): Operation not permitted in phar:///usr/local/bin/wp/php/utils.php on line 34
PHP Warning:  unlink(/tmp/wp-cli-cacert.pem): Operation not permitted in phar:///usr/local/bin/wp/php/utils.php on line 34
Warning: unlink(/tmp/wp-cli-cacert.pem): Operation not permitted in phar:///usr/local/bin/wp/php/utils.php on line 34

The file should be prefixed with either a random runtime ID or minimum with the user name, which is running the command. But the solution with the user name isn't bomb proof, so I would prefer generating a random runtime ID, which is shared with the different functions inside wp cli using the certificate, as long as the command is running.

Can you take a look into it?
Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions