Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for problematic modules reqtimeout, deflate and pagespeed #14699

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/private/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ public static function checkServer(\OCP\IConfig $config) {
// functions = function_exists
// defined = defined
// ini = ini_get
// module = apacheModuleEnabled
// If the dependency is not found the missing module name is shown to the EndUser
// When adding new checks always verify that they pass on Travis as well
// for ini settings, see https://github.com/owncloud/administration/blob/master/travis-ci/custom.ini
Expand Down Expand Up @@ -602,8 +603,14 @@ public static function checkServer(\OCP\IConfig $config) {
'output_buffering' => false,
'default_charset' => 'UTF-8',
],
'modules' => array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New array annotation please while at it :)

['foo']

'mod_pagespeed' => 'mod_pagespeed',
'mod_reqtimeout' => 'mod_reqtimeout',
'mod_deflate' => 'mod_deflate'
),
);
$missingDependencies = array();
$problematicModules = array();
$invalidIniSettings = [];
$moduleHint = $l->t('Please ask your server administrator to install the module.');

Expand Down Expand Up @@ -647,6 +654,11 @@ public static function checkServer(\OCP\IConfig $config) {
}
}
}
foreach ($dependencies['modules'] as $checkModule => $module) {
if (self::apacheModuleEnabled($checkModule)) {
$problematicModules[] = $module;
}
}
}

foreach($missingDependencies as $missingDependency) {
Expand Down Expand Up @@ -675,6 +687,14 @@ public static function checkServer(\OCP\IConfig $config) {
);
$webServerRestart = true;
}
foreach($problematicModules as $problematicModule) {
$errors[] = array(
'error' => $l->t('The Apache module %s is enabled.', array($problematicModule)),
'hint' => $l->t('This module can cause various issues when enabled.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no string concat please - translation extraction will fail - thx

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

then you might want to fix the whole util.php as this is used on several places. But i will just close the PR as the module check is not very reliable.

. ' Please ask your server administrator to disable it.')
);
$webServerRestart = true;
}

/**
* PHP 5.6 ships with a PHP setting which throws notices by default for a
Expand Down Expand Up @@ -1464,4 +1484,17 @@ public static function needUpgrade(\OCP\IConfig $config) {
}
}

/**
* Check if an apache module is enabled.
*
* @param string $module The module to check
* @return bool true if the module is enabled, false otherwise
*/
private static function apacheModuleEnabled($module) {
if (function_exists('apache_get_modules')) {
return in_array($module, apache_get_modules());
} else {
return false;
}
}
}