Skip to main content
Check all files against current versions error Started by ahrasis · · Read 11936 times 0 Members and 3 Guests are viewing this topic. previous topic - next topic

Check all files against current versions error

Can anybody running EA 1.1.2 test this (especially with nginx + php7 like me)? Admin > Maintenance > Routine > Check all files against current versions > Run task now

I kinda got an error but will need confirmation from others before reporting.

Re: Check all files against current versions error

Reply #1

It doesn't seems to be the problem with the 1.1.2 update. I will carry on inspecting. Meanwhile, I do appreciate any feedback from others.

Re: Check all files against current versions error

Reply #2

I'm getting an open basedir restriction error.  Which is puzzling.... :-X

Re: Check all files against current versions error

Reply #3

Ok. That is the same with me @badmonkey (we both use ISPConfig).

The error:
QuoteSplFileInfo::isDir(): open_basedir restriction in effect. File(/var/www/clients/client2/web1/web/..) is not within the allowed path(s):

The ".." is not a file at all. The line complained is "if ($dir->isDir())" of which "$dir" revert back to "$iter" in the function below:
Code: [Select]
function readFileVersions(&$version_info, $directories, $pattern, $recursive = false)
{
// The comment looks roughly like... that.
$version_regex = '~\*\s@version\s+(.+)[\s]{2}~i';
$unknown_version = '??';

$ext_offset = -strlen($pattern);

foreach ($directories as $type => $dirname)
{
if ($recursive === true)
{
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dirname, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST,
RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
);
}
else
{
$iter = new IteratorIterator(new DirectoryIterator($dirname));
}

foreach ($iter as $dir)
{
if ($dir->isDir())
{
continue;
}
$entry = $dir->getFilename();

if (substr($entry, $ext_offset) == $pattern)
{
if ($dir->isWritable() === false)
{
continue;
}
// Read the first 768 bytes from the file.... enough for the header.
$header = file_get_contents($dir->getPathname(), false, null, 0, 768);

if ($recursive === true)
{
$entry_key = $dir->getPathname();
}
else
{
$entry_key = $entry;
}

// Look for the version comment in the file header.
if (preg_match($version_regex, $header, $match) == 1)
$version_info[$type][$entry_key] = $match[1];
// It wasn't found, but the file was... show a $unknown_version.
else
$version_info[$type][$entry_key] = $unknown_version;
}
}
}
}

I think, somehow, "$iter" also catches ".." as file which it should not. The php coding is an advanced one (to me), so I am not quite sure I understand correctly nor I am able to help on determining the true error or fixing this one.

I hope @emanule can look into it.

Re: Check all files against current versions error

Reply #4

Yeah, kind of wondered if that was the same error you were getting. 

For sake of full disclosure, nginx 1.13.9, php 7.2.2, mariadb 10.2.13. It's probably irrelevant, but just in case.  8)

Re: Check all files against current versions error

Reply #5

Linux kernel 4.15.7, Nginx 1.13.8, Php 7.2.2, MariaDB 10.2.13 ;)

Re: Check all files against current versions error

Reply #6

Could it be because we are using "DirectoryIterator" instead of "FilesystemIterator" where the former may use "." and ".." ([1]). I tested with the later and it works without error but I need confirmation.

The original code:
Code: [Select]
			$iter = new IteratorIterator(new DirectoryIterator($dirname));

The fixed code?:
Code: [Select]
			$iter = new IteratorIterator(new FilesystemIterator($dirname));

Is this the right way to fix it @emanuele?

Edited: I opened this as an issue and PR the above as suggested fix, so time will not be wasted if it is acceptable as a fix.
Last Edit: March 05, 2018, 12:41:42 am by ahrasis

Re: Check all files against current versions error

Reply #7

works fine for me  ;)

if can be useful test.sss.ovh/skoda/phpinfo_.php
sorry for my bad english

Re: Check all files against current versions error

Reply #8

That is because your open_basedir has no value, which is not safe / advisable. Mine (and probably @badmonkey too) has value to it.

Quote/var/www/clients/client2/web1/web:/var/www/clients/client2/web1/private:/var/www/clients/client2/web1/tmp:/var/www/elkarte.sch.my/web:/srv/www/elkarte.sch.my/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom

Re: Check all files against current versions error

Reply #9

Confirmed it works without the error, and without errors in the forum error log.   8)  Nice work @ahrasis‍ 

Re: Check all files against current versions error

Reply #10

I guess so @ahrasis Iterator are still a bit a mystery for me. :P
Bugs creator.
Features destroyer.
Template killer.

Re: Check all files against current versions error

Reply #11

For me all codes are always mysterious... :P

Re: Check all files against current versions error

Reply #12

LOL
Bugs creator.
Features destroyer.
Template killer.

Re: Check all files against current versions error

Reply #13

Just to note that this is somehow missed in 1.1.3 package. I think issue number was #3120 but I will create a new PR anyway.

Re: Check all files against current versions error

Reply #14

O:-)
Bugs creator.
Features destroyer.
Template killer.