open_basedir error in edit module configuration

Open to all! Ask other shopowners for help.
Post Reply
cut-n-paste
Member
Posts: 28
Joined: Fri Oct 07, 2022 12:20 pm
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

open_basedir error in edit module configuration

Post by cut-n-paste »

I get the following error when trying to configure this holiday message module by @raiwa. I have double checked my config and also done some basic debugging to check the value of DIR_FS_CATALOG etc. I am hosting on a shared host and I think this could be related to a symlinked www basedir.

Code: Select all

Fatal error: Uncaught RuntimeException: SplFileInfo::isFile(): open_basedir restriction in effect. File(/usr/www/users/xxxxmhfc/..) is not within the allowed path(s):

(/usr/www/wwws/users/xxxxmhfc:/usr/wwws/users/xxxxmhfc:/usr/www/users/xxxxmhfc:/usr/home/xxxxmhfc:/usr/local/rmagic:/usr/share/php:/usr/local/lib/php:/tmp:/usr/bin:/usr/local/bin:/usr/local/share/www:/usr/www/share/www:/usr/share/misc:/dev/urandom:/var/www/php_profiler/xhgui) in /usr/www/users/xxxxmhfc/includes/system/versioned/1.0.5.6/page_selection.php:30

Stack trace: 
#0 /usr/www/users/xxxxmhfc/includes/system/versioned/1.0.5.6/page_selection.php(30): SplFileInfo->isFile() 
#1 /usr/www/users/xxxxmhfc/admin/includes/actions/modules/infoboxes/edit.php(20) : eval()'d code(1): page_selection::_edit_pages('index.php', 'MODULE_CONTENT_...') 
#2 /usr/www/users/xxxxmhfc/admin/includes/actions/modules/infoboxes/edit.php(20): eval() 
#3 /usr/www/users/xxxxmhfc/admin/includes/components/infobox.php(15): require('/usr/www/users/...') 
#4 /usr/www/users/xxxxmhfc/admin/modules.php(199): require('/usr/www/users/...') 
#5 {main} thrown in /usr/www/users/xxxxmhfc/includes/system/versioned/1.0.5.6/page_selection.php on line 30
Installed Version: CE Phoenix v1.0.8.20
PHP 8.1

With some help from @raiwa I modified core script page_selection.php from:

Code: Select all

      // main files
      foreach (new DirectoryIterator(DIR_FS_CATALOG) as $file) {
        if ($file->isFile() && ($file->getExtension() === 'php')) {
          $files[] = $file->getFilename();
        }
      }
to:

Code: Select all

      foreach (new DirectoryIterator(DIR_FS_CATALOG) as $file) {
        if ($file->isDot()) { // Skip '.' and '..'
          continue;
        }
        if ($file->isFile() && ($file->getExtension() === 'php')) {
          $files[] = $file->getFilename();
        }
      }


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: open_basedir error in edit module configuration

Post by burt »

Does this error present itself on any core module that uses the core (ie UNCHANGED) page selector?

EG, try it on admin > modules > header tags > No Index
I am not here to build for you.
I am here to build with you. Let's help each other.
cut-n-paste
Member
Posts: 28
Joined: Fri Oct 07, 2022 12:20 pm
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: open_basedir error in edit module configuration

Post by cut-n-paste »

I get the same error on the core module admin > modules > header tags> No Index > Edit if I don't make the mod.

I did a bit more research and it seems like DirectoryIterator does turn up . and .. by default, and so I suppose this is expected behaviour when my host has an open_basedir limit on my www folder.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: open_basedir error in edit module configuration

Post by burt »

I suppose so.

You could try this;

Code: Select all

// main files
$dir = new RecursiveDirectoryIterator(DIR_FS_CATALOG, RecursiveDirectoryIterator::SKIP_DOTS);
foreach ($dir as $file) {
  if ($file->isFile() && ($file->getExtension() === 'php')) {
    $files[] = $file->getFilename();
  }
}
I am not here to build for you.
I am here to build with you. Let's help each other.
cut-n-paste
Member
Posts: 28
Joined: Fri Oct 07, 2022 12:20 pm
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: open_basedir error in edit module configuration

Post by cut-n-paste »

This works and looks a lot better.
cut-n-paste
Member
Posts: 28
Joined: Fri Oct 07, 2022 12:20 pm
Phoenix Version:
Has thanked: 2 times
Been thanked: 5 times

Re: open_basedir error in edit module configuration

Post by cut-n-paste »

Is likely to be a changed in the core file or will I need to do a system override?
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: open_basedir error in edit module configuration

Post by burt »

Just do an override for now.

I don't want to change it now (maybe in the future if more users experience the same), when it's been OK for many hundreds of users since 1.0.5.6.

TY.
I am not here to build for you.
I am here to build with you. Let's help each other.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply