• Resolved bohwp

    (@bohwp)


    Plug-in looks awesome, but we are on a grid server and I keep getting the following errors. These are posted below this message.

    I contacted our host and there are restrictions in place that stop us from accessing binaries using the absolute node address – (i.e. /nfs/c11/h04/mnt/198641 )

    Is there a way to resolve this using a relative address to run the binary? (i.e. /home/198641/domains/bohdental.com.au/ )

    Thanks!

    *Warning: file_exists(): open_basedir restriction in effect. File(/usr/bin/cwebp) is not within the allowed path(s): (/home/198641/domains/bohdental.com.au/html:/home/198641/data/tmp) in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php, line 385, PHP 5.6.21 (Linux)*

    *Warning: file_exists(): open_basedir restriction in effect. File(/usr/local/bin/cwebp) is not within the allowed path(s): (/home/198641/domains/bohdental.com.au/html:/home/198641/data/tmp) in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php, line 385, PHP 5.6.21 (Linux)*

    *Warning: file_exists(): open_basedir restriction in effect. File(/usr/gnu/bin/cwebp) is not within the allowed path(s): (/home/198641/domains/bohdental.com.au/html:/home/198641/data/tmp) in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php, line 385, PHP 5.6.21 (Linux)*

    *Warning: file_exists(): open_basedir restriction in effect. File(/usr/syno/bin/cwebp) is not within the allowed path(s): (/home/198641/domains/bohdental.com.au/html:/home/198641/data/tmp) in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Cwebp.php, line 385, PHP 5.6.21 (Linux)*

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author rosell.dk

    (@roselldk)

    Hi,

    The warnings that you posted are open_basedir restrictions to the following files:
    – /usr/bin/cwebp
    – /usr/local/bin/cwebp
    – /usr/gnu/bin/cwebp
    – /usr/syno/bin/cwebp

    WebP Express is looking for cwebp executables in common system locations. These files are placed in outside your open_basedir (/home/198641/domains/bohdental.com.au/). Tricks such as ‘/home/198641/domains/bohdental.com.au/../../../../usr/bin/cwebp’ will not work. If the host was to be persuaded to adding ‘/usr/bin/’ to your open_basedir restrictions, you’d be fine. But that is probably not going to happen.
    I suggest you click “configure” next to the cwebp conversion method and disable the “Try to execute cweb binary at common locations” option.

    However. Besides trying these cwebps found in the system, WebP Express also tries a precompiled cwebp which is part of the plugin. THAT executable should be reachable. – I would have thought until now. But it might not be because there could be an issue with open_dir restriction and symlinks here.

    It seems that your host has created a symlink so /home/198641/domains/bohdental.com.au/html points to /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/.

    WebP Express does something that boils down to this when it gets the path to a supplied binary (for a given OS):

    
    $binaryFile = realpath(__DIR__ . './Binaries/'cwebp-linux-1.0.2-shared');
    

    The __DIR__ constant has symbolic links expanded. Doing realpath would also expand them (if they were not already expanded). So WebP Express will try the “physical” path rather than the symlinked. But in your setup, it seems that only the symlinked is within open_basedir.

    I shall consider if there is a way to use the symlinked path instead.
    I shall get back!

    Plugin Author rosell.dk

    (@roselldk)

    I just recalled that you can set the path to use directly.

    In wp-config.php:

    
    define('WEBPCONVERT_CWEBP_PATH', '/home/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux-1.0.2-shared');
    

    (or whatever binary you want to use and is appropriate for your OS – you can browse /home/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/)

    Unfortunately this definition will not be seen by scripts that receive a request to convert (when “Redirection rules > Enable redirection to converter? or “Create webp files upon request?” is enabled. But it will work with Bulk conversion and convert on upload.

    To make it work with those scripts as well, add this line in your .htaccess or vhost configuration:

    # Set ewww api key for WebP Convert
    SetEnv WEBPCONVERT_CWEBP_PATH /home/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux-1.0.2-shared

    Plugin Author rosell.dk

    (@roselldk)

    I tested restricting open_basedir to a symlinked folder (and not the physical). Doing that will still allow access to the physical path.

    So file_exists(__DIR__); and realpath(__DIR__) does not fail. At least not the setup I just tested (Linux, Apache, PHP fpm 7.3). This means that the open dir restriction ought not to be block the precompiled cwebps that comes with the library, as I feared.

    Can you please try the following:
    1. Click “settings” next to the cwebp conversion method
    2. Disable the “Try to execute cweb binary at common locations” option
    3. Click “test” next to the cwebp conversion method
    4. Show me the output

    Thanks in advance

    Thread Starter bohwp

    (@bohwp)

    Detecting versions of the cwebp binaries found (and verifying that they can be executed in the process)
    Executing: /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux-1.0.2-shared -version
    Exec failed (return code: 126)
    PS: Return code 126 means “Permission denied”. The user that the command was run with does not have permission to execute that binary.
    Executing: /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux-1.0.2-static -version
    Exec failed (return code: 126)
    PS: Return code 126 means “Permission denied”. The user that the command was run with does not have permission to execute that binary.
    Executing: /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/vendor/rosell-dk/webp-convert/src/Convert/Converters/Binaries/cwebp-linux-0.6.1 -version
    Exec failed (return code: 126)
    PS: Return code 126 means “Permission denied”. The user that the command was run with does not have permission to execute that binary.

    **Error: ** **None of the cwebp files located can be executed. All failed with return code 126 (permission denied)**

    *Warning: dirname() expects exactly 1 parameter, 2 given in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/lib/classes/SanityCheck.php, line 185, PHP 5.6.21 (Linux)*

    *Warning: dirname() expects exactly 1 parameter, 2 given in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/lib/classes/SanityCheck.php, line 185, PHP 5.6.21 (Linux)*

    *Warning: dirname() expects exactly 1 parameter, 2 given in /nfs/c11/h04/mnt/198641/domains/bohdental.com.au/html/wp-content/plugins/webp-express/lib/classes/SanityCheck.php, line 185, PHP 5.6.21 (Linux)*

    Thread Starter bohwp

    (@bohwp)

    Thanks for the help! No luck so far, I had a feeling it was the path directory and permissions on the grid not being compatible.

    Happy to try anything you suggest.

    Plugin Author rosell.dk

    (@roselldk)

    That warning in your last log is quite critical. I wasn’t aware that dirname() doesn’t take the second optional parameter in PHP 5.6. I shall fix that.

    The errors you get when running cwebp now boils down to:

    “None of the cwebp files located can be executed. All failed with return code 126 (permission denied)”

    It means that the server setup has not allowed the web server (the “www-data” user) to executing binaries. The server setup needs to be modified in order to use the “cwebp” conversion method. Contact your host or simply disable that method and see if you can get one of the others to work.

    Plugin Author rosell.dk

    (@roselldk)

    I have fixed the dirname() error in 0.15.0.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Open_basedir error’ is closed to new replies.