Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: Anthony` on November 7th, 2012, 10:31 PM

Title: open_basedir and Load Balancing Page Errors
Post by: Anthony` on November 7th, 2012, 10:31 PM
Trying to view the page shows a blank page.

I investigated and found the cause on line 471 in ManageServer.php,
Code: [Select]
$settings['load_average'] = @file_get_contents('/proc/loadavg');

When I remove the supression operator, I get the following errors,
Quote
Warning: file_get_contents() [function.file-get-contents]: open_basedir restriction in effect. File(/proc/loadavg) is not within the allowed path(s): (/home/...:usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /.../wedge/Sources/ManageServer.php on line 471

Warning: file_get_contents(/proc/loadavg) [function.file-get-contents]: failed to open stream: Operation not permitted in /.../wedge/Sources/ManageServer.php on line 471
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on November 7th, 2012, 10:46 PM
Do you get the same problem in SMF?

/medoesn't recall changing that code.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Anthony` on November 7th, 2012, 11:14 PM
As a matter of fact I do too.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on November 7th, 2012, 11:22 PM
So the problem's an underlying SMF one, less than strictly a Wedge one. Encouraging, but not ideal.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Nao on November 7th, 2012, 11:36 PM
It's more of a server security issue. I remember having the problem at an earlier host. The current one supports this but the only difference is I can see the load average, that's all... If it's not supported -- it doesn't show anything.

Not a biggie IMHO.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on November 7th, 2012, 11:42 PM
But why, if it's not supported, would it generate a white screen error?
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Nao on November 7th, 2012, 11:45 PM
Honestly, I don't know. I don't remember getting a blank page on this, ever...
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Anthony` on November 8th, 2012, 04:16 AM
I went back into the code and the cause of the blank page seems to be the backtick operator executing the shell command here:
Code: [Select]
elseif (($settings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $settings['load_average'], $matches) !== 0)

I suspect it's somewhat like my experience in an earlier bug report with exec(?) hanging on me and producing a blank page as well.

Again, removing the supression operator and I get the following error:
Quote
Warning: shell_exec() has been disabled for security reasons in /.../wedge/Sources/ManageServer.php on line 474
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Nao on November 8th, 2012, 08:48 AM
So, I've replaced this internally with @shell_exec('uptime')... Can you do the same and tell me if it works this time..?
(There's also another occurrence in Load.php, BTW. Done too.)
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on November 8th, 2012, 04:14 PM
I don't get why it's white-screening instead of just giving you an actual error, though.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Anthony` on November 8th, 2012, 10:18 PM
Quote from Nao on November 8th, 2012, 08:48 AM
So, I've replaced this internally with @shell_exec('uptime')... Can you do the same and tell me if it works this time..?
(There's also another occurrence in Load.php, BTW. Done too.)
Still get a blank page and when I take off supression:
Quote
Warning: shell_exec() has been disabled for security reasons in /.../wedge/Sources/ManageServer.php on line 474
Quote from Arantor on November 8th, 2012, 04:14 PM
I don't get why it's white-screening instead of just giving you an actual error, though.
Well, I can see why it wouldn't output the error because it's supressed of course but I don't know why it would just hang PHP like this... Do all shell commands do this? -_-

Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on November 8th, 2012, 10:40 PM
That's the thing - as far as I know they shouldn't.
Title: Re: open_basedir and Load Balancing Page Errors
Post by: Arantor on August 1st, 2013, 06:03 AM
Looks like this has been protected against in the code with can_shell_exec().