Check for failure in creating htaccessWorking testfile

This commit is contained in:
Bart Visscher 2013-09-10 22:05:20 +02:00
parent 8ae612f693
commit 65aab3dc8c
2 changed files with 20 additions and 6 deletions

View file

@ -60,8 +60,18 @@ class Controller {
$vulnerableToNullByte = true;
}
$errors = array();
// Protect data directory here, so we can test if the protection is working
\OC_Setup::protectDataDirectory();
try {
$htaccessworking = \OC_Util::isHtAccessWorking();
} catch (\OC\HintException $e) {
$errors[] = array(
'error' => $e->getMessage(),
'hint' => $e->getHint()
);
}
return array(
'hasSQLite' => $hasSQLite,
@ -71,9 +81,9 @@ class Controller {
'hasMSSQL' => $hasMSSQL,
'directory' => $datadir,
'secureRNG' => \OC_Util::secureRNGAvailable(),
'htaccessWorking' => \OC_Util::isHtAccessWorking(),
'htaccessWorking' => $htaccessWorking,
'vulnerableToNullByte' => $vulnerableToNullByte,
'errors' => array(),
'errors' => $errors,
);
}
}

View file

@ -689,9 +689,13 @@ class OC_Util {
return false;
}
$fp = @fopen($testfile, 'w');
@fwrite($fp, $testcontent);
@fclose($fp);
$fp = @fopen($testFile, 'w');
if (!$fp) {
throw new OC\HintException('Can\'t create test file to check for working .htaccess file.',
'Make sure it is possible for the webserver to write to '.$testFile);
}
fwrite($fp, $testContent);
fclose($fp);
// accessing the file via http
$url = OC_Helper::makeURLAbsolute(OC::$WEBROOT.'/data'.$fileName);
@ -700,7 +704,7 @@ class OC_Util {
@fclose($fp);
// cleanup
@unlink($testfile);
@unlink($testFile);
// does it work ?
if($content==$testContent) {