diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-01 15:32:14 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-01 15:32:14 +0200 |
commit | 8001f2abcd09c491ff634d0360f0650987669562 (patch) | |
tree | 8a5d8758655ff2e7bc2f6e1e15036262cc0a2813 | |
parent | 0af2dc7d3775f5d40cdfd3fe0cd4325abd6ce40d (diff) | |
parent | 5ebd3a9e89de8a29806987a0a31b0c475566db30 (diff) | |
download | nextcloud-server-8001f2abcd09c491ff634d0360f0650987669562.tar.gz nextcloud-server-8001f2abcd09c491ff634d0360f0650987669562.zip |
Merge pull request #15353 from owncloud/run-cron-with-the-correct-user-master
Cron has to be executed with the correct user
-rw-r--r-- | cron.php | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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'; |