Dieser Commit ist enthalten in:
o.pinke 2020-09-01 15:23:56 +02:00
Ursprung 0feff6b9f5
Commit b6fcfc7f13
3 geänderte Dateien mit 303 neuen und 364 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -55,11 +56,9 @@ define("E_BASEDIR_INCOMPATIBLE", 4);
* @param $file string Path to the file, accepts absolute and relative files
* @return boolean true if the file exists and is writeable, false otherwise
*/
function isWriteable ($file)
{
function isWriteable($file) {
clearstatcache();
if (!file_exists($file))
{
if (!file_exists($file)) {
return false;
}
@ -77,17 +76,13 @@ function isWriteable ($file)
* @param $file string Path to the file, accepts absolute and relative files
* @return boolean true if the file exists and is readable, false otherwise
*/
function isReadable ($file)
{
function isReadable($file) {
return is_readable($file);
}
function canReadFile ($sFilename)
{
if (isReadable(dirname($sFilename)))
{
if (isReadable($sFilename))
{
function canReadFile($sFilename) {
if (isReadable(dirname($sFilename))) {
if (isReadable($sFilename)) {
$fp = fopen($sFilename, "r");
fclose($fp);
@ -97,8 +92,7 @@ function canReadFile ($sFilename)
return false;
}
function canWriteFile ($sFilename)
{
function canWriteFile($sFilename) {
#check dir perms, create a new file read it and delete it
if (is_dir($sFilename)) {
@ -110,7 +104,7 @@ function canWriteFile ($sFilename)
$sRandFilename = 'con_test' . rand(0, 1000000000) . 'con_test';
$sRandFilenamePath = '';
if ($sFilename{strlen($sFilename)-1} == '/') {
if ($sFilename[strlen($sFilename) - 1] == '/') {
$sRandFilenamePath = $sFilename . $sRandFilename;
} else {
$sRandFilenamePath = $sFilename . '/' . $sRandFilename;
@ -137,12 +131,9 @@ function canWriteFile ($sFilename)
}
}
if (isWriteable(dirname($sFilename)))
{
if (file_exists($sFilename))
{
if (!isWriteable($sFilename))
{
if (isWriteable(dirname($sFilename))) {
if (file_exists($sFilename)) {
if (!isWriteable($sFilename)) {
return false;
} else {
return true;
@ -155,18 +146,15 @@ function canWriteFile ($sFilename)
$fp = @fopen($sFilename, "w");
@fclose($fp);
if (file_exists($sFilename))
{
if (file_exists($sFilename)) {
@unlink($sFilename);
return true;
} else {
return false;
}
} else {
if (file_exists($sFilename))
{
if (!isWriteable($sFilename))
{
if (file_exists($sFilename)) {
if (!isWriteable($sFilename)) {
return false;
} else {
return true;
@ -175,14 +163,11 @@ function canWriteFile ($sFilename)
}
}
function canDeleteFile ($sFilename)
{
if (isWriteable($sFilename))
{
function canDeleteFile($sFilename) {
if (isWriteable($sFilename)) {
unlink($sFilename);
if (file_exists($sFilename))
{
if (file_exists($sFilename)) {
return false;
} else {
return true;
@ -192,22 +177,18 @@ function canDeleteFile ($sFilename)
}
}
function getFileInfo ($sFilename)
{
if (!file_exists($sFilename))
{
function getFileInfo($sFilename) {
if (!file_exists($sFilename)) {
return false;
}
$oiFilePermissions = fileperms($sFilename);
if ($oiFilePermissions === false)
{
if ($oiFilePermissions === false) {
return false;
}
switch (true)
{
switch (true) {
case (($oiFilePermissions & 0xC000) == 0xC000):
$info = 's';
$type = "socket";
@ -256,33 +237,27 @@ function getFileInfo ($sFilename)
return ($aFileinfo);
}
function checkOpenBasedirCompatibility ()
{
function checkOpenBasedirCompatibility() {
$value = getPHPIniSetting("open_basedir");
if (isWindows())
{
if (isWindows()) {
$aBasedirEntries = explode(";", $value);
} else {
$aBasedirEntries = explode(":", $value);
}
if (count($aBasedirEntries) == 1 && $aBasedirEntries[0] == $value)
{
if (count($aBasedirEntries) == 1 && $aBasedirEntries[0] == $value) {
return E_BASEDIR_NORESTRICTION;
}
if (in_array(".", $aBasedirEntries) && count($aBasedirEntries) == 1)
{
if (in_array(".", $aBasedirEntries) && count($aBasedirEntries) == 1) {
return E_BASEDIR_DOTRESTRICTION;
}
$sCurrentDirectory = getcwd();
foreach ($aBasedirEntries as $entry)
{
if (stristr($sCurrentDirectory, $entry))
{
foreach ($aBasedirEntries as $entry) {
if (stristr($sCurrentDirectory, $entry)) {
return E_BASEDIR_RESTRICTIONSUFFICIENT;
}
}
@ -290,21 +265,18 @@ function checkOpenBasedirCompatibility ()
return E_BASEDIR_INCOMPATIBLE;
}
function predictCorrectFilepermissions ($file)
{
function predictCorrectFilepermissions($file) {
/* Check if the system is a windows system. If yes,
* we can't predict anything.
*/
if (isWindows())
{
if (isWindows()) {
return C_PREDICT_WINDOWS;
}
/* Check if the file is read- and writeable. If yes, we don't need
* to do any further checks.
*/
if (isWriteable($file) && isReadable($file))
{
if (isWriteable($file) && isReadable($file)) {
return C_PREDICT_SUFFICIENT;
}
@ -314,8 +286,7 @@ function predictCorrectFilepermissions ($file)
* If we can't find out the web server UID, we cannot
* predict the correct mask.
*/
if ($iServerUID === false)
{
if ($iServerUID === false) {
return C_PREDICT_NOTPREDICTABLE;
}
@ -325,47 +296,39 @@ function predictCorrectFilepermissions ($file)
* If we can't find out the web server GID, we cannot
* predict the correct mask.
*/
if ($iServerGID === false)
{
if ($iServerGID === false) {
return C_PREDICT_NOTPREDICTABLE;
}
$aFilePermissions = getFileInfo($file);
if (getSafeModeStatus())
{
if (getSafeModeStatus()) {
/* SAFE-Mode related checks */
if ($iServerUID == $aFilePermissions["owner"]["id"])
{
if ($iServerUID == $aFilePermissions["owner"]["id"]) {
return C_PREDICT_CHANGEPERM_SAMEOWNER;
}
if (getSafeModeGidStatus())
{
if (getSafeModeGidStatus()) {
/* SAFE-Mode GID related checks */
if ($iServerGID == $aFilePermissions["group"]["id"])
{
if ($iServerGID == $aFilePermissions["group"]["id"]) {
return C_PREDICT_CHANGEPERM_SAMEGROUP;
}
return C_PREDICT_CHANGEGROUP;
}
} else {
/* Regular checks */
if ($iServerUID == $aFilePermissions["owner"]["id"])
{
if ($iServerUID == $aFilePermissions["owner"]["id"]) {
return C_PREDICT_CHANGEPERM_SAMEOWNER;
}
if ($iServerGID == $aFilePermissions["group"]["id"])
{
if ($iServerGID == $aFilePermissions["group"]["id"]) {
return C_PREDICT_CHANGEPERM_SAMEGROUP;
}
return C_PREDICT_CHANGEPERM_OTHERS;
}
}
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -36,7 +37,6 @@ define("E_EXTENSION_AVAILABLE", 1);
define("E_EXTENSION_UNAVAILABLE", 2);
define("E_EXTENSION_CANTCHECK", 3);
/**
* getPHPIniSetting ($setting)
*
@ -44,8 +44,7 @@ define("E_EXTENSION_CANTCHECK", 3);
* Wrapper to avoid warnings if ini_get is in the
* disable_functions directive.
*/
function getPHPIniSetting ($setting)
{
function getPHPIniSetting($setting) {
/* Avoid errors if ini_get is in the disable_functions directive */
$value = @ini_get($setting);
@ -56,8 +55,7 @@ function getPHPIniSetting ($setting)
* canPHPurlfopen: Checks if PHP is able to use
* allow_url_fopen.
*/
function canPHPurlfopen ()
{
function canPHPurlfopen() {
return getPHPIniSetting("allow_url_fopen");
}
@ -69,80 +67,66 @@ function canPHPurlfopen ()
* Uses the PHP configuration value y2k_compilance which
* is available in all PHP4 versions.
*/
function checkPHPiniget ()
{
function checkPHPiniget() {
$value = @ini_get("y2k_compliance");
if ($value === NULL)
{
if ($value === NULL) {
return false;
} else {
return true;
}
}
function getPHPDisplayErrorSetting ()
{
function getPHPDisplayErrorSetting() {
return getPHPIniSetting("display_errors");
}
function getPHPFileUploadSetting ()
{
function getPHPFileUploadSetting() {
return getPHPIniSetting("file_uploads");
}
function getPHPGPCOrder ()
{
function getPHPGPCOrder() {
return getPHPIniSetting("gpc_order");
}
function getPHPMagicQuotesGPC ()
{
function getPHPMagicQuotesGPC() {
return getPHPIniSetting("magic_quotes_gpc");
}
function getPHPMagicQuotesRuntime ()
{
function getPHPMagicQuotesRuntime() {
return getPHPIniSetting("magic_quotes_runtime");
}
function getPHPMagicQuotesSybase ()
{
function getPHPMagicQuotesSybase() {
return getPHPIniSetting("magic_quotes_sybase");
}
function getPHPMaxExecutionTime ()
{
function getPHPMaxExecutionTime() {
return getPHPIniSetting("max_execution_time");
}
function getPHPOpenBasedirSetting ()
{
function getPHPOpenBasedirSetting() {
return getPHPIniSetting("open_basedir");
}
function getPHPMaxPostSize ()
{
function getPHPMaxPostSize() {
return getPHPIniSetting("post_max_size");
}
function checkPHPSQLSafeMode ()
{
function checkPHPSQLSafeMode() {
return getPHPIniSetting("sql.safe_mode");
}
function checkPHPUploadMaxFilesize ()
{
function checkPHPUploadMaxFilesize() {
return getPHPIniSetting("upload_max_filesize");
}
function return_bytes($val) {
if (strlen($val) == 0)
{
if (strlen($val) == 0) {
return 0;
}
$val = trim($val);
$last = $val{strlen($val)-1};
$last = $val[strlen($val) - 1];
switch ($last) {
case 'k':
case 'K':
@ -157,33 +141,26 @@ function return_bytes($val) {
}
}
function isPHPExtensionLoaded ($extension)
{
function isPHPExtensionLoaded($extension) {
$value = extension_loaded($extension);
if ($value === NULL)
{
if ($value === NULL) {
return E_EXTENSION_CANTCHECK;
}
if ($value === true)
{
if ($value === true) {
return E_EXTENSION_AVAILABLE;
}
if ($value === false)
{
if ($value === false) {
return E_EXTENSION_UNAVAILABLE;
}
}
function isRegisterLongArraysActive ()
{
if (version_compare(phpversion(), "5.0.0", ">=") == true)
{
if (getPHPIniSetting("register_long_arrays") == false)
{
function isRegisterLongArraysActive() {
if (version_compare(phpversion(), "5.0.0", ">=") == true) {
if (getPHPIniSetting("register_long_arrays") == false) {
return false;
}
}
@ -204,4 +181,5 @@ function isPHPCompatible($sVersion = "5.2.0") {
return false;
}
}
?>

Datei anzeigen

@ -527,19 +527,19 @@ class cSetupSystemtest extends cSetupMask {
case C_PREDICT_CHANGEPERM_SAMEOWNER:
$mfileperms = substr(sprintf("%o", fileperms("../" . $sFile)), -3);
$mfileperms{0} = intval($mfileperms{0}) | 0x6;
$mfileperms[0] = intval($mfileperms[0]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server and the owner of your files are identical. You need to enable write access for the owner, e.g. using chmod u+rw %s, setting the file mask to %s or set the owner to allow writing the file."), $sFile, $mfileperms);
break;
case C_PREDICT_CHANGEPERM_SAMEGROUP:
$mfileperms = substr(sprintf("%o", fileperms("../" . $sFile)), -3);
$mfileperms{1} = intval($mfileperms{1}) | 0x6;
$mfileperms[1] = intval($mfileperms[1]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server's group and the group of your files are identical. You need to enable write access for the group, e.g. using chmod g+rw %s, setting the file mask to %s or set the group to allow writing the file."), $sFile, $mfileperms);
break;
case C_PREDICT_CHANGEPERM_OTHERS:
$mfileperms = substr(sprintf("%o", fileperms("../" . $sFile)), -3);
$mfileperms{2} = intval($mfileperms{2}) | 0x6;
$mfileperms[2] = intval($mfileperms[2]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server is not equal to the file owner, and is not in the webserver's group. It would be highly insecure to allow world write acess to the files. If you want to install anyways, enable write access for all others, e.g. using chmod o+rw %s, setting the file mask to %s or set the others to allow writing the file."), $sFile, $mfileperms);
break;
}
@ -558,19 +558,19 @@ class cSetupSystemtest extends cSetupMask {
case C_PREDICT_CHANGEPERM_SAMEOWNER:
$mfileperms = substr(sprintf("%o", @fileperms($sTarget)), -3);
$mfileperms{0} = intval($mfileperms{0}) | 0x6;
$mfileperms[0] = intval($mfileperms[0]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server and the owner of your directory are identical. You need to enable write access for the owner, e.g. using chmod u+rw %s, setting the directory mask to %s or set the owner to allow writing the directory."), dirname($sFile), $mfileperms);
break;
case C_PREDICT_CHANGEPERM_SAMEGROUP:
$mfileperms = substr(sprintf("%o", @fileperms($sTarget)), -3);
$mfileperms{1} = intval($mfileperms{1}) | 0x6;
$mfileperms[1] = intval($mfileperms[1]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server's group and the group of your directory are identical. You need to enable write access for the group, e.g. using chmod g+rw %s, setting the directory mask to %s or set the group to allow writing the directory."), dirname($sFile), $mfileperms);
break;
case C_PREDICT_CHANGEPERM_OTHERS:
$mfileperms = substr(sprintf("%o", @fileperms($sTarget)), -3);
$mfileperms{2} = intval($mfileperms{2}) | 0x6;
$mfileperms[2] = intval($mfileperms[2]) | 0x6;
$sPredictMessage = sprintf(i18n_setup("Your web server is not equal to the directory owner, and is not in the webserver's group. It would be highly insecure to allow world write acess to the directory. If you want to install anyways, enable write access for all others, e.g. using chmod o+rw %s, setting the directory mask to %s or set the others to allow writing the directory."), dirname($sFile), $mfileperms);
break;
}
@ -580,5 +580,3 @@ class cSetupSystemtest extends cSetupMask {
}
}
?>