Mailing List Archive

Installation - Warning: $wgProxyKey is insecure
Sorry if there is not the correct location to post this. If not, could someone
let me know where is the more approriate list/board etc. Thank you.

"Warning: $wgProxyKey is insecure Can't find a writable temp directory for the
XHTML template. Check that the TMP environment variable points to a writable
directory, or that the default temp dir (/tmp) exists and is writable."

That is the error that I am getting in attempting to install MediaWiki.

From here:
http://mail.wikipedia.org/pipermail/wikitech-l/2004-August/024401.html it was
mentioned that it was something to do with the tmp-directory on the virtual
hosting machine. I asked my provider to look into that and they tried a couple
of things but it still didn't work.

Is that actually the issue? The manner in which the virtual hosting machine is
configured in respect to the tmp directory?

Any insight or assistance would be greatly accepted.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Re: Installation - Warning: $wgProxyKey is insecure [ In reply to ]
On Nov 22, 2004, at 5:37 PM, dbw@ozreef.org wrote:
> Sorry if there is not the correct location to post this. If not,
> could someone
> let me know where is the more approriate list/board etc. Thank you.
>
> "Warning: $wgProxyKey is insecure
^^ ignore the above part, it's unrelated and harmless.

> Can't find a writable temp directory for the
> XHTML template. Check that the TMP environment variable points to a
> writable
> directory, or that the default temp dir (/tmp) exists and is writable."

Most likely in the messages above this, there is something about PHP
being in safe mode. (The installer asks that you post the complete
output when seeking help; this is so that instead of guessing what your
problem is, we have a better chance of being able to tell for sure.)
Safe mode (and also some related options) can make it pretty much
impossible for a PHP script to access the /tmp directory.

As a fallback, the wiki will try to use the images subdirectory to
store the compiled template, as this is more likely to work -- but you
have to make it writable first.

If you are able to set the TMP environment variable (for instance from
an .htaccess file, if your hosting provider allows this) then you can
also use that to set a directory for it to try using.

As a worst case, you can try disabling the template for the MonoBook
skin, and it will fall back to the old default look. If the
installation completed, you can set this in LocalSettings.php:

$wgUsePHPTal = false;

If installation itself is not completing, edit includes/Default.php to
force it off.

>> From here:
> http://mail.wikipedia.org/pipermail/wikitech-l/2004-August/024401.html
> it was
> mentioned that it was something to do with the tmp-directory on the
> virtual
> hosting machine. I asked my provider to look into that and they tried
> a couple
> of things but it still didn't work.

What things did they try, exactly?

-- brion vibber (brion @ pobox.com)
Installation - Warning: $wgProxyKey is insecure [ In reply to ]
Thank you for the assistance.

>Most likely in the messages above this, there is something about PHP
>being in safe mode. (The installer asks that you post the complete
>output when seeking help; this is so that instead of guessing what your
>problem is, we have a better chance of being able to tell for sure.)

NP, sorry about that, here it is, but everything else appears to be fine up
until that stage.

# PHP 4.3.9: ok
# PHP server API is apache2handler; ok, using pretty URLs
(index.php/Page_Title)
# Have XML / Latin1-UTF-8 conversion support.
# PHP's memory_limit is 8M. If this is too low, installation may fail!
Attempting to raise limit to 20M... ok.
# Have zlib support; enabling output compression.
# Found GD graphics library built-in, image thumbnailing will be enabled if you
enable uploads.
# Installation directory: /home/httpd/vhosts/domain.com/httpdocs/masa
# Script URI path: /masa
Warning: $wgProxyKey is insecure Can't find a writable temp directory for the
XHTML template. Check that the TMP environment variable points to a writable
directory, or that the default temp dir (/tmp) exists and is writable.

>Safe mode (and also some related options) can make it pretty much
>impossible for a PHP script to access the /tmp directory.

PHP safe mode is off, since I needed that for Gallery in the same domain.

I can provide the appropriate PHP configuration info if that helps.

They attempted to ensure that apache had access etc to the tmp directory, as
indicated in the email that I provided the URL for in the first post.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Re: Installation - Warning: $wgProxyKey is insecure [ In reply to ]
On Nov 22, 2004, at 7:44 PM, dbw@ozreef.org wrote:
>> Safe mode (and also some related options) can make it pretty much
>> impossible for a PHP script to access the /tmp directory.
>
> PHP safe mode is off, since I needed that for Gallery in the same
> domain.
>
> I can provide the appropriate PHP configuration info if that helps.

Is PHP's open_base_dir option on, maybe? Or is the TMP environment
variable set to some directory that is not writable?

Did you try the other recommendations I gave? Did they work, or not?

-- brion vibber (brion @ pobox.com)
Installation - Warning: $wgProxyKey is insecure [ In reply to ]
>Is PHP's open_base_dir option on, maybe?

From phpinfo.php .....

open_basedir /usr/bin:/home/httpd/vhosts/domain.com/httpdocs

upload_tmp_dir /home/httpd/vhosts/domain.com/httpdocs/tmp

The tmp file exists and should be writable. What chmod should it be?

OK, I changed the image directory to 777 and the installation worked fine ....

################
# PHP 4.3.9: ok
# PHP server API is apache2handler; ok, using pretty URLs
(index.php/Page_Title)
# Have XML / Latin1-UTF-8 conversion support.
# PHP's memory_limit is 8M. If this is too low, installation may fail!
Attempting to raise limit to 20M... ok.
# Have zlib support; enabling output compression.
# Found GD graphics library built-in, image thumbnailing will be enabled if you
enable uploads.
# Installation directory: /home/httpd/vhosts/domain.com/httpdocs/masa
# Script URI path: /masa
# Warning: $wgProxyKey is insecure MySQL error 1045: Access denied for user:
'root@localhost' (Using password: NO)
# Trying regular user... ok.
# Connected to database... 4.0.20-Max; enabling MySQL 4 enhancementsWarning:
$wgProxyKey is insecure
# Database wikidb exists
# Creating tables... done.
# Initializing data...
# Created sysop account WikiSysop.
# Initialising log pages...
#

Initialising "MediaWiki" namespace...
Clearing message cache...Done.
###########

Should the image directory chmod be changed now? Or does it have to stay
writable? Is it OK to run the wiki using that instead of the /tmp directory?
Security wise etc.

Thank you very much for your assistance.

Would I be allowed to put this up onto the installation wiki for this
(MediaWiki)? Or the troubleshooting etc when it is full resolved?

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Re: Installation - Warning: $wgProxyKey is insecure [ In reply to ]
On Nov 23, 2004, at 4:05 PM, dbw@ozreef.org wrote:
>> Is PHP's open_base_dir option on, maybe?
>
>> From phpinfo.php .....
>
> open_basedir /usr/bin:/home/httpd/vhosts/domain.com/httpdocs

Yes, that would keep you from accessing /tmp. If the TMP environment
variable is not set (or is set to an unreachable directory), and the
images subdirectory is not writable, it will try to use /tmp and fail.

> upload_tmp_dir /home/httpd/vhosts/domain.com/httpdocs/tmp
>
> The tmp file exists and should be writable. What chmod should it be?

upload_tmp_dir is not the general /tmp directory; that's where PHP
stores files that have been uploaded in an HTTP POST request with
attached files.

> OK, I changed the image directory to 777 and the installation worked
> fine ....

Great!

> Should the image directory chmod be changed now? Or does it have to
> stay writable?

It should probably stay writable; if for instance you update
xhtml_slim.pt it will need to recompile the template again. Also you
will need that directory (or equivalent) to be writable if you want to
enable the upload or TeX rendering features.

> Is it OK to run the wiki using that instead of the /tmp directory?
> Security wise etc.

The compiled template script file itself is safe, it's a PHP file that
simply defines a function and so shouldn't be able to be executed in a
malicious manner.

If you're on shared hosting and there are other users who can directly
access the filesystem from the web server, perhaps by running arbitrary
shell commands or CGI scripts (bypassing PHP's safe_mode or
open_base_dir restrictions) it's possible that they could write
arbitrary files into your writable directory. (They could also read
your database password in the config files, whether you have a writable
directory or not, if they are able to get direct filesystem access.)

Assuming that other protections are in place and open_base_dir is
sufficient to prevent access to arbitrary filesystem locations by other
users' scripts (it is your hosting provider's job to assure this), then
there should not be any real risk.

> Thank you very much for your assistance.
>
> Would I be allowed to put this up onto the installation wiki for this
> (MediaWiki)? Or the troubleshooting etc when it is full resolved?

The directions already state that you should make the images directory
writable if /tmp doesn't work, but the warning doesn't (yet) trigger on
the open_base_dir setting.

-- brion vibber (brion @ pobox.com)
Re: Installation - Warning: $wgProxyKey is insecure [ In reply to ]
I just ran into a very similar problem myself while installing a new wiki on
a shared server where php was configured with safe mode.

I didn't realize I could set the TMP environment variable in the .htaccess,
and learned that while the mediawiki code respects the $wgUploadDirectory,
PHPTal still tries to create files in the /tmp directory.

I think this is because when PHPTAL.php checks (is_writable) to see if it
can write in /tmp, php returns true that the /tmp dir is writeable, even if
safe_mode is on.

Perhaps if the PHPTAL.php code added another test to the is_writable
condition, setting the TMP environment variable could be avoided?

something like:
if( is_writable( $default_temp ) &&
!ini_get('safe_mode') ) {
define('PHPTAL_DEFAULT_CACHE_DIR',
$default_temp.DIRECTORY_SEPARATOR);
} else {
global $wgUploadDirectory;
define('PHPTAL_DEFAULT_CACHE_DIR',
$wgUploadDirectory.DIRECTORY_SEPARAT
OR);

Just a thought,
Jonah
Re: Re: Installation - Warning: $wgProxyKey is insecure [ In reply to ]
On Nov 23, 2004, at 8:51 PM, Jonah Bossewitch wrote:
> I didn't realize I could set the TMP environment variable in the
> .htaccess, and learned that while the mediawiki code respects the
> $wgUploadDirectory, PHPTal still tries to create files in the /tmp
> directory.
>
> I think this is because when PHPTAL.php checks (is_writable) to see if
> it can write in /tmp, php returns true that the /tmp dir is writeable,
> even if safe_mode is on.

In my testing (PHP 4.3.8 on Linux), is_writable("/tmp") returns false
if either safe_mode is on or open_basedir has been set in a way that
excludes /tmp.

The current checks we've put in however will _not_ fall back to the
upload directory if the TMP environment variable is set; so if the
environment has preconfigured TMP=/tmp then you'll get the "can't write
to /tmp" message.

Anyway, because of a pile of such troubles I've converted the MonoBook
skin in the upcoming 1.4 release so it longer will require PHPTAL and
doesn't need to write out a compiled template.

-- brion vibber (brion @ pobox.com)