Opened 14 years ago

Closed 14 years ago

#7997 closed defect (fixed)

open_basedir error due to module loading bug

Reported by: christian.bachert@… Owned by: Rob Smith
Priority: minor Milestone: unknown
Component: Plugin - MythWeb Version: unknown
Severity: medium Keywords: open_basedir open basedir modules
Cc: Ticket locked: no

Description

Hi,

I already saw the 2 similar bugs that won't get fixed, but I believe that the code is still faulty. Have a look at the thrown message: "Warning at /srv/http/mythweb/classes/Modules.php, line 30: file_exists(): open_basedir restriction in effect. File(./modules/welcome.php/init.php) is not within the allowed path(s): (/srv/http)

In fact, the file ./modules/welcome.php/init.php is nonexistent. Modules.php makes a list of files in the modules directory, assumes they are subdirectories and tries to load init.php in each of the directories. welcome.php isn't a directory, hence you shouldn't treat it as one.

Here's a cheap fix: In includes/utils.php is a function called get_sorted_files. Replace

if ($file == '.'
$file == '..') continue;

with

if ($file == '.'
$file == '..' $file == 'welcome.php') continue;

Probably there's someone that can do a lot better than this, but this did it for me.

Change History (2)

comment:1 Changed 14 years ago by anonymous

here was my fix, insert text with +++ below in Modules.php around line 26

if (modules_path && modules_path != 'modules_path') {
     foreach (get_sorted_files(modules_path) as $module) {
+++        if (is_file (modules_path."/$module"))
+++             continue;
        if (preg_match('/^_/', $module))
             continue;

comment:2 Changed 14 years ago by Rob Smith

Resolution: fixed
Status: newclosed

(In [24918]) Fixes #7997, this adds a in is_dir check in the module init code

Note: See TracTickets for help on using tickets.