]> source.dussan.org Git - nextcloud-server.git/commitdiff
Cron has to be executed with the correct user - fixes 13912 and others
authorThomas Müller <thomas.mueller@tmit.eu>
Wed, 1 Apr 2015 08:31:48 +0000 (10:31 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Wed, 1 Apr 2015 16:30:20 +0000 (18:30 +0200)
cron.php

index b3ba9605d4f4a516b4589ac3560a096a653184a9..d62650bbe9dea42a2e13db08c7ea82eb6b6f1b17 100644 (file)
--- a/cron.php
+++ b/cron.php
@@ -90,6 +90,22 @@ try {
        }
 
        if (OC::$CLI) {
+               // 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);
+                       }
+               }
+
                // Create lock file first
                TemporaryCronClass::$lockfile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/cron.lock';