Skip to content

Commit c1e7330

Browse files
authored
Merge pull request #45302 from nextcloud/revert/27613/get-config-owner
Revert: "Check datadirectory owner, not config owner."
2 parents 2b2a866 + 88648fa commit c1e7330

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

console.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,17 @@ function exceptionHandler($exception) {
4141
exit(1);
4242
}
4343

44-
// Check if the data directory is available and the server is installed
45-
$dataDirectory = $config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data');
46-
if ($config->getSystemValueBool('installed', false) && !is_dir($dataDirectory)) {
47-
echo "Data directory (" . $dataDirectory . ") not found" . PHP_EOL;
44+
$user = posix_getuid();
45+
$configUser = fileowner(OC::$configDir . 'config.php');
46+
if ($user !== $configUser) {
47+
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
48+
echo "Current user id: " . $user . PHP_EOL;
49+
echo "Owner id of config.php: " . $configUser . PHP_EOL;
50+
echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
51+
echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL;
4852
exit(1);
4953
}
5054

51-
// Check if the user running the console is the same as the user that owns the data directory
52-
// If the data directory does not exist, the server is not setup yet and we can skip.
53-
if (is_dir($dataDirectory)) {
54-
$user = posix_getuid();
55-
$dataDirectoryUser = fileowner($dataDirectory);
56-
if ($user !== $dataDirectoryUser) {
57-
echo "Console has to be executed with the user that owns the data directory" . PHP_EOL;
58-
echo "Current user id: " . $user . PHP_EOL;
59-
echo "Owner id of the data directory: " . $dataDirectoryUser . PHP_EOL;
60-
echo "Try adding 'sudo -u #" . $dataDirectoryUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
61-
echo "If running with 'docker exec' try adding the option '-u " . $dataDirectoryUser . "' to the docker command (without the single quotes)" . PHP_EOL;
62-
exit(1);
63-
}
64-
}
65-
6655
$oldWorkingDir = getcwd();
6756
if ($oldWorkingDir === false) {
6857
echo "This script can be run from the Nextcloud root directory only." . PHP_EOL;

cron.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@
130130
}
131131

132132
$user = posix_getuid();
133-
$dataDirectoryUser = fileowner($config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data'));
134-
if ($user !== $dataDirectoryUser) {
135-
echo "Cron has to be executed with the user that owns the data directory" . PHP_EOL;
133+
$configUser = fileowner(OC::$configDir . 'config.php');
134+
if ($user !== $configUser) {
135+
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
136136
echo "Current user id: " . $user . PHP_EOL;
137-
echo "Owner id of the data directory: " . $dataDirectoryUser . PHP_EOL;
137+
echo "Owner id of config.php: " . $configUser . PHP_EOL;
138138
exit(1);
139139
}
140140

0 commit comments

Comments
 (0)