Skip to content

cron.php reports misleading error messages when testing executing user #5548

@lcts

Description

@lcts

Even when both the nextcloud cronjob and the webserver is run by the same user, e.g. http, the cronjob still fails with the following error when config.php is owned by another user, e.g. root:

  Console has to be executed with the same user as the web server is operated
  Current user: http
  Web server user: root

This is due to cron.php actually checking not for executing users, but for file ownership:

  $user = posix_getpwuid(posix_getuid());
		$configUser = posix_getpwuid(fileowner(OC::$configDir . '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(1);
		}

I don't know if if the message is wrong and cron.php is supposed to test file owbership (if so it would probably be better if it checked writability), or the message is right and cron.php is testing the wrong thing, but in either case, the message is highly misleading, because adjusting the users running the webserver and the cronjob will not fix the error.

Steps to reproduce

  1. run webserver and cronjob by same user
  2. change ownership of config.php to a different user (needs still to be writable by the webserver via group permissions)
  3. run cronjob

Expected behaviour

No error or error because of wrong file ownership

Actual behaviour

Error because of wrong users running webserver/cronjob

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. to developAccepted and waiting to be taken care ofbuggood first issueSmall tasks with clear documentation about how and in which place you need to fix things in.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions