Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2014-06-18 04:04:56 +0400
committerThomas Steur <thomas.steur@gmail.com>2014-06-18 04:04:56 +0400
commit69b4a70048ea681bc62bca79abe7c763f2233a60 (patch)
tree070b876a73f9402664f624e73de74ed4165518f5 /core/Filechecks.php
parent031a2de96a2a3ec3f5f395977ee6c0c822b119b3 (diff)
parent02ffeeb228f88d6053edf777d094b34c47b086b4 (diff)
Merge remote-tracking branch 'origin/master' into report_and_dimension_refactoring
Conflicts: core/Tracker/Settings.php core/Tracker/Visit.php plugins/Actions/Widgets.php plugins/CustomVariables/Widgets.php plugins/DevicesDetection/DevicesDetection.php plugins/DevicesDetection/Widgets.php plugins/Events/Widgets.php plugins/Provider/Widgets.php plugins/UserCountry/Widgets.php plugins/UserSettings/Widgets.php plugins/VisitTime/Widgets.php plugins/VisitorInterest/Widgets.php
Diffstat (limited to 'core/Filechecks.php')
-rw-r--r--core/Filechecks.php36
1 files changed, 30 insertions, 6 deletions
diff --git a/core/Filechecks.php b/core/Filechecks.php
index ddfade4e6e..ab25ae7d9d 100644
--- a/core/Filechecks.php
+++ b/core/Filechecks.php
@@ -84,11 +84,11 @@ class Filechecks
// Also give the chown since the chmod is only 755
if (!SettingsServer::isWindows()) {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
- $directoryList = "<code>chown -R www-data:www-data " . $realpath . "</code><br />" . $directoryList;
+ $directoryList = "<code>chown -R ". self::getUserAndGroup() ." " . $realpath . "</code><br />" . $directoryList;
}
if(function_exists('shell_exec')) {
- $currentUser = trim(shell_exec('whoami'));
+ $currentUser = self::getUser();
if(!empty($currentUser)) {
$optionalUserInfo = " (running as user '" . $currentUser . "')";
}
@@ -178,7 +178,7 @@ class Filechecks
{
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
$message = '';
- $message .= "<code>chown -R www-data:www-data " . $realpath . "</code><br />";
+ $message .= "<code>chown -R ". self::getUserAndGroup() ." " . $realpath . "</code><br />";
$message .= "<code>chmod -R 0755 " . $realpath . "</code><br />";
$message .= 'After you execute these commands (or change permissions via your FTP software), refresh the page and you should be able to use the "Automatic Update" feature.';
return $message;
@@ -198,9 +198,10 @@ class Filechecks
$message .= "On Windows, check that the folder is not read only and is writable.\n
You can try to execute:<br />";
} else {
- $message .= "For example, on a GNU/Linux server if your Apache httpd user
- is www-data, you can try to execute:<br />\n"
- . "<code>chown -R www-data:www-data " . $path . "</code><br />";
+ $message .= "For example, on a GNU/Linux server if your Apache httpd user is "
+ . self::getUser()
+ . ", you can try to execute:<br />\n"
+ . "<code>chown -R ". self::getUserAndGroup() ." " . $path . "</code><br />";
}
$message .= self::getMakeWritableCommand($path);
@@ -208,6 +209,29 @@ class Filechecks
return $message;
}
+ private static function getUserAndGroup()
+ {
+ $user = self::getUser();
+ if(!function_exists('shell_exec')) {
+ return $user . ':' . $user;
+ }
+
+ $group = trim(shell_exec('groups '. $user .' | cut -f3 -d" "'));
+
+ if(empty($group)) {
+ $group = 'www-data';
+ }
+ return $user . ':' . $group;
+ }
+
+ private static function getUser()
+ {
+ if(!function_exists('shell_exec')) {
+ return 'www-data';
+ }
+ return trim(shell_exec('whoami'));
+ }
+
/**
* Returns the help text displayed to suggest which command to run to give writable access to a file or directory
*