Skip to content

Commit 8068ad5

Browse files
szaimenbackportbot[bot]
authored andcommitted
Revert: "Check datadirectory owner, not config owner."
Signed-off-by: Simon L <szaimen@e.mail.de>
1 parent cb63ff8 commit 8068ad5

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
@@ -65,28 +65,17 @@ function exceptionHandler($exception) {
6565
exit(1);
6666
}
6767

68-
// Check if the data directory is available and the server is installed
69-
$dataDirectory = $config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data');
70-
if ($config->getSystemValueBool('installed', false) && !is_dir($dataDirectory)) {
71-
echo "Data directory (" . $dataDirectory . ") not found" . PHP_EOL;
68+
$user = posix_getuid();
69+
$configUser = fileowner(OC::$configDir . 'config.php');
70+
if ($user !== $configUser) {
71+
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
72+
echo "Current user id: " . $user . PHP_EOL;
73+
echo "Owner id of config.php: " . $configUser . PHP_EOL;
74+
echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
75+
echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL;
7276
exit(1);
7377
}
7478

75-
// Check if the user running the console is the same as the user that owns the data directory
76-
// If the data directory does not exist, the server is not setup yet and we can skip.
77-
if (is_dir($dataDirectory)) {
78-
$user = posix_getuid();
79-
$dataDirectoryUser = fileowner($dataDirectory);
80-
if ($user !== $dataDirectoryUser) {
81-
echo "Console has to be executed with the user that owns the data directory" . PHP_EOL;
82-
echo "Current user id: " . $user . PHP_EOL;
83-
echo "Owner id of the data directory: " . $dataDirectoryUser . PHP_EOL;
84-
echo "Try adding 'sudo -u #" . $dataDirectoryUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
85-
echo "If running with 'docker exec' try adding the option '-u " . $dataDirectoryUser . "' to the docker command (without the single quotes)" . PHP_EOL;
86-
exit(1);
87-
}
88-
}
89-
9079
$oldWorkingDir = getcwd();
9180
if ($oldWorkingDir === false) {
9281
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
@@ -115,11 +115,11 @@
115115
}
116116

117117
$user = posix_getuid();
118-
$dataDirectoryUser = fileowner($config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data'));
119-
if ($user !== $dataDirectoryUser) {
120-
echo "Cron has to be executed with the user that owns the data directory" . PHP_EOL;
118+
$configUser = fileowner(OC::$configDir . 'config.php');
119+
if ($user !== $configUser) {
120+
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
121121
echo "Current user id: " . $user . PHP_EOL;
122-
echo "Owner id of the data directory: " . $dataDirectoryUser . PHP_EOL;
122+
echo "Owner id of config.php: " . $configUser . PHP_EOL;
123123
exit(1);
124124
}
125125

0 commit comments

Comments
 (0)