Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: maxya on March 23, 2024, 10:35:43 AM

Title: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 23, 2024, 10:35:43 AM
SMF 2.1.4
PHP 8.2.16 (cli) (built: Mar  7 2024 08:55:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.16, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.16, Copyright (c), by Zend Technologies
Hestia control panel

2: is_writable(): open_basedir restriction in effect. File(/Packages/temp) is not within the allowed path(s): (/home/admin/.composer:/home/admin/web/si.org.ua/public_html:/home/admin/web/si.org.ua/private:/home/admin/web/si.org.ua/public_shtml:/home/admin/tmp:/tmp:/var/www/html:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt)
Granted rights to 777 directories
Granted rights to admin and www-data users

php runs as admin user

Tell me what to do?
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Aleksi "Lex" Kilpinen on March 23, 2024, 01:45:43 PM
That's an open_basedir restriction, something usually only the host / server's admin can change.
https://www.php.net/manual/en/ini.core.php#ini.open-basedir
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: shawnb61 on March 23, 2024, 02:48:50 PM
There is a set of changes in the pipeline that address php 8.x issues with basedir restrictions with certain hosts. 

https://github.com/SimpleMachines/SMF/pull/7741

So, first have your host confirm basedir is ok.

If so, you might try php 7.4.  If that works, manually applying the PR above will help you run later versions of php.  There may be another PR needed as well.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 24, 2024, 06:30:25 AM
I can change the version to php 7.3 or php 7.4 but not work
But when installing the module I get an error - You cannot download or install new packages because the Packages directory, or one of the files in it, is not writable!

a function public function chmod($ftp_file, $chmod)
stops with error bad_file smf 550 SITE CHMOD command failed

Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Doug Heffernan on March 24, 2024, 06:50:50 AM
It looks like a permission issue. You said previously that the Packages directory is chmodded, but it looks like that's not the case. You should contact your host and tell them to give your permissions to chmodd the Packages folder.

On a side note, can you try something? Assuming that everything is fine with basedir on the server side of things, create a temp folder inside your Packaged directory, chmodd it and give mod installation another go and see if it would help.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Aleksi "Lex" Kilpinen on March 24, 2024, 06:57:23 AM
Running PHP and Apache as different users might also cause a whole lot of weird permission issues, because this can lead to files having different owners.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 24, 2024, 07:03:02 AM
No hoster. Free Hestia Panel on VPS
There are rights to directories.
The forum is working, attachments are loading without problems.

The only problem is with installing plugins.
I'm loading the archive, it's in the catalog
/Packages # ls -l | grep glo
-rw-r--r-- 1 admin admin  32865 Mar 24 13:01 globalhf2.1.zip
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 24, 2024, 08:09:26 AM
Quote from: Aleksi "Lex" Kilpinen on March 24, 2024, 06:57:23 AMRunning PHP and Apache as different users might also cause a whole lot of weird permission issues, because this can lead to files having different owners.

I set the permissions for all files to 777
I tried to give the user rights 500:500, as is done by default.
I tried to give permissions for admin and for www-data
Nothing helps
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Oldiesmann on March 24, 2024, 03:31:16 PM
The problem here is that the path to the Packages directory in Settings.php is wrong. Based on that error message, it should be "/home/admin/web/si.org.ua/public_html/Packages" rather than just "/Packages".
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 24, 2024, 03:45:40 PM
Quote from: Oldiesmann on March 24, 2024, 03:31:16 PMThe problem here is that the path to the Packages directory in Settings.php is wrong. Based on that error message, it should be "/home/admin/web/si.org.ua/public_html/Packages" rather than just "/Packages".

Settings.php
$packagesdir = '/home/admin/web/si.org.ua/public_html/Packages';
I suspect that the script incorrectly determines the root directory. But why?

"/Packages/temp/delme.tmp" bool(false) string(3) "644"
"/Packages/temp/delme.tmp" bool(false) string(3) "644"
"/Packages/temp" bool(false) string(3) "644"

These files cannot be created and the path displays like this
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Doug Heffernan on March 24, 2024, 04:01:23 PM
Quote from: Oldiesmann on March 24, 2024, 03:31:16 PMThe problem here is that the path to the Packages directory in Settings.php is wrong. Based on that error message, it should be "/home/admin/web/si.org.ua/public_html/Packages" rather than just "/Packages".

Good catch :)

Quote from: maxya on March 24, 2024, 03:45:40 PMI suspect that the script incorrectly determines the root directory. But why?

Did you move hosts or changed the forum folder/location/name? Try to run What is repair_settings.php? (https://wiki.simplemachines.org/smf/Repair_settings.php) to make sure that all paths and urls are pointing to the right location.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 25, 2024, 02:29:07 AM
Quote from: Doug Heffernan on March 24, 2024, 04:01:23 PMDid you move hosts or changed the forum folder/location/name? Try to run What is repair_settings.php? (https://wiki.simplemachines.org/smf/Repair_settings.php) to make sure that all paths and urls are pointing to the right location.

The host has not changed. The forum is fully operational. I can download attachments. The only problem is with installing plugins.

I download the archive with the plugin through the admin panel - everything is fine. It appears in the /Packages directory, but the installation does not work.

repair_settings.php Everything shows correctly.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 25, 2024, 02:41:16 AM
Loaded the module
firefox_2024-03-25_08-30-38.jpg

The files are in the directory
firefox_2024-03-25_08-30-51.jpg

I'm trying to install
firefox_2024-03-25_08-31-33.jpg

SmartFTP_2024-03-25_08-32-05.jpg

If you create /Packages/temp manually, it allows you to continue and files with a resolution of 666 appear in the directory
SmartFTP_2024-03-25_08-33-20.jpg

But then there is this error
firefox_2024-03-25_08-33-30.jpg

Class-Package.php
public function chmod($ftp_file, $chmod)
{

if (!is_resource($this->connection))
return false;

if ($ftp_file == '')
$ftp_file = '.';

// Do we have a file or a dir?
$is_dir = is_dir($ftp_file);
$is_writable = false;

// Set different modes.
$chmod_values = $is_dir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);

foreach ($chmod_values as $val)
{
// If it's writable, break out of the loop.

var_dump($ftp_file);
var_dump(is_writable($ftp_file));
var_dump(decoct($val));

string(22) "/Packages/temp/LICENSE" bool(false) string(3) "644" string(22) "/Packages/temp/LICENSE" bool(false) string(3) "644" string(36) "/Packages/temp/modifications-1.1.xml" bool(false)
I printed the method verification log. It checks if there is access to files 644, but the files in the directory are 666

bool(false)
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: live627 on March 25, 2024, 11:58:16 PM
Quote from: shawnb61 on March 23, 2024, 02:48:50 PMThere is a set of changes in the pipeline that address php 8.x issues with basedir restrictions with certain hosts. 

https://github.com/SimpleMachines/SMF/pull/7741
...and I've attached those affected files to this post.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 26, 2024, 05:58:21 AM
Quote from: live627 on March 25, 2024, 11:58:16 PM...and I've attached those affected files to this post.

You cannot download or install new packages because the Packages directory, or one of the files in it, is not writable!

/index.php?action=admin;area=packages;sa=install;package=globalhf2.1.zip
/home/admin/web/si.org.ua/public_html/Sources/Class-Package.php (Line 908)
Backtrace information

Type of error: General
Error message Select
2: is_writable(): open_basedir restriction in effect. File(/Packages/temp) is not within the allowed path(s): (/home/admin/.composer:/home/admin/web/si.org.ua/public_html:/home/admin/web/si.org.ua/private:/home/admin/web/si.org.ua/public_shtml:/home/admin/tmp:/tmp:/var/www/html:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt)

public function chmod($ftp_file, $chmod)

$ftp_file =  /Packages/temp/delme.tmp, not /home/admin/web/si.org.ua/public_html/Packages/temp/delme.tmp
its ok?
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Aleksi "Lex" Kilpinen on March 26, 2024, 11:39:06 AM
Quote from: Oldiesmann on March 24, 2024, 03:31:16 PMThe problem here is that the path to the Packages directory in Settings.php is wrong. Based on that error message, it should be "/home/admin/web/si.org.ua/public_html/Packages" rather than just "/Packages".
No, it's likely the path for the FTP user - so most likely not the full path.

So, yes I still think it could just be an an open_basedir restriction where the path used in the restriction simply isn't the same path that the FTP user sees.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: Sesquipedalian on March 26, 2024, 12:49:13 PM
To elaborate on what Lex said: It is sometimes the case that FTP connections are only shown a subdirectory of the complete directory structure on disk, which means that that subdirectory appears to the FTP user as if it were the root directory of the disk. For example, if the FTP user can only see the directory /path/to/forum and its subdirectories, then /path/to/forum will appear to the FTP user as /, and /path/to/forum/Packages will appear to the FTP user as /Packages, etc.
Title: Re: I can't install plugins - open_basedir restriction in effect
Post by: maxya on March 26, 2024, 05:10:53 PM
Madhouse! I cleared the cookies in Mozilla Firefox and installed the plugin  ???
Thanks everyone

The open_basedir error does not go away