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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-04-01 11:31:48 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-01 11:31:48 +0300
commit5ebd3a9e89de8a29806987a0a31b0c475566db30 (patch)
tree5a30b5efeee0b733c6fd9c721280281261491588 /cron.php
parent0edeefd0310eb21699a544f6436b33ca5be54c8a (diff)
Cron has to be executed with the correct user - fixes 13912 and others
Diffstat (limited to 'cron.php')
-rw-r--r--cron.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/cron.php b/cron.php
index 676cb62bb56..c6236897227 100644
--- a/cron.php
+++ b/cron.php
@@ -73,6 +73,22 @@ try {
// set to run indefinitely if needed
set_time_limit(0);
+ // the cron job must be executed with the right user
+ if (!OC_Util::runningOnWindows()) {
+ if (!function_exists('posix_getuid')) {
+ echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
+ exit(0);
+ }
+ $user = posix_getpwuid(posix_getuid());
+ $configUser = posix_getpwuid(fileowner(OC::$SERVERROOT . '/config/config.php'));
+ if ($user['name'] !== $configUser['name']) {
+ echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
+ echo "Current user: " . $user['name'] . PHP_EOL;
+ echo "Web server user: " . $configUser['name'] . PHP_EOL;
+ exit(0);
+ }
+ }
+
$config = OC::$server->getConfig();
$instanceId = $config->getSystemValue('instanceid');
$lockFileName = 'owncloud-server-' . $instanceId . '-cron.lock';