In an clean fresh Installation the variable 'file_directory_temp' is not set up correct in the script 'includes/' (function file_directory_temp).

Running Apache 2 with virtual hosts, PHP 4.3.10, Zend Engine v1.3.0, PHP.ini safe_mode=On + open_base_dir=/path/to/my/website + upload_tmp_dir=/path/to/my/website/php_tmp

If 'safe_mode = On' and 'open_base_dir = /srv/www/' is set in php.ini or via apache i get an error when trying to import an language:
open_basedir restriction in effect. '/tmp' is not within the allowed path(s): ...

The error seems to be in includes/ line 687 (function file_directory_temp() ; see underlined line). It is in currently (starting at line 681 for better understanding):

// Has PHP been set with an upload_tmp_dir?
if (ini_get('upload_tmp_dir')) {
$directories[] = ini_get('upload_tmp_dir');

// Operating system specific dirs.
if (substr(PHP_OS, 0, 3) == 'WIN') {
$directories[] = 'c:\\windows\\temp';
$directories[] = 'c:\\winnt\\temp';
$path_delimiter = '\\';
else {
$directories[] = '/tmp';
$path_delimiter = '/';

The error should get fixed if changing line 687 to
elseif (substr(PHP_OS, 0, 3) == 'WIN') {
because if there is set up an upload_tmp_dir in php.ini, there should not be an check for Windows OS.
There should only be an check for Windows OS if no upload_tmp_dir ist set.

The error can only be reproduced when the variable file_directory_temp has not been set by drupal. The easiest way to get this condition should be to set up an new drupal installation.
I got little trouble to reproduce this failure due to some caching effects i think, or because in setup of drupal is set file_directory_temp up in an another script or so.

If you got further questions, please contact me.

#2 windows-temp.png68.35 KBdrutube
Members fund testing for the Drupal project. Drupal Association Learn more


drutube’s picture


Amazing really. I've been pulliing hair trying to figure this out. In fact it will stop the backup module cold. Backup module is hardly maintained and I think this is the cause of the mysterious but never fixed bugs. When you look closely at the error it says

backup_files(): Command 'tar cfz /tmp/backup-htdocs-MVSqRk install.php profiles misc scripts includes themes xmlrpc.php sites UPGRADE.txt update.php b.tar CHANGELOG.txt files .htaccess modules INSTALL.pgsql.txt _notes pictures INSTALL.txt MAINTAINERS.txt robots.txt c:\windows\temp index.php INSTALL.mysql.txt cron.php LICENSE.txt drupal-backup-db-20080327033312-549481290.sql.gz

Now that's funny becasue Drupal is on Cent OS 5. When I run ls I can't see anything in the directory but running ls -l shows c:\windows\temp . I delete with rm -f c:\windows\temp and no problem... but.. when I run backup I get the above error and guess what? The c:\windows\temp is back in the drupal root.

Now how is that? You supplied the answer above. This is a seriously sneaky and as a result very hard to catch bug in Drupal.

drutube’s picture

Version: 5.6 » 5.7
68.35 KB

I'm unable to remove the c:\windows\temp from the drupal root directory. The OS is cent os5. I can see a directory or file called c:\windows\temp but it is indestructable. Yes I'm logged in as root and yes I tried to unlink it. Nothing works.

niccottrell’s picture

You should be able to remove this directory with:

rm -rf "c:\\windows\\temp"/

Damien Tournoud’s picture

Status: Active » Closed (won't fix)

There are no errors here. I guess the original poster forgot to create the "/path/to/my/website/php_tmp" dir.