I can't install plugins - open_basedir restriction in effect

Started by maxya, March 23, 2024, 10:35:43 AM

Previous topic - Next topic

maxya

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?

Aleksi "Lex" Kilpinen

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
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

shawnb61

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.
A question worth asking is born in experience & driven by necessity. - Fripp

maxya

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


Doug Heffernan

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.

Aleksi "Lex" Kilpinen

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.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

maxya

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

maxya

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

Oldiesmann

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".
Michael Eshom
Christian Metal Fans

maxya

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

Doug Heffernan

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? to make sure that all paths and urls are pointing to the right location.

maxya

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? 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.

maxya

Loaded the module
You cannot view this attachment.

The files are in the directory
You cannot view this attachment.

I'm trying to install
You cannot view this attachment.

You cannot view this attachment.

If you create /Packages/temp manually, it allows you to continue and files with a resolution of 666 appear in the directory
You cannot view this attachment.

But then there is this error
You cannot view this attachment.

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)

live627

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.

maxya

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?

Aleksi "Lex" Kilpinen

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.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Sesquipedalian

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.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

maxya

Madhouse! I cleared the cookies in Mozilla Firefox and installed the plugin  ???
Thanks everyone

The open_basedir error does not go away

Advertisement: