Skip to content

Commit 22ad440

Browse files
Dreamsorcererskjnldsv
authored andcommitted
feat: check datadirectory owner instead of config.php owner
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 455a209 commit 22ad440

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

console.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,20 @@ function exceptionHandler($exception) {
5959

6060
set_exception_handler('exceptionHandler');
6161

62+
$config = \OC::$server->getConfig();
63+
6264
if (!function_exists('posix_getuid')) {
6365
echo "The posix extensions are required - see https://www.php.net/manual/en/book.posix.php" . PHP_EOL;
6466
exit(1);
6567
}
6668
$user = posix_getuid();
67-
$configUser = fileowner(OC::$configDir . 'config.php');
69+
$dataDirectoryUser = fileowner($config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data'));
6870
if ($user !== $configUser) {
69-
echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL;
71+
echo "Console has to be executed with the user that owns the data directory" . PHP_EOL;
7072
echo "Current user id: " . $user . PHP_EOL;
71-
echo "Owner id of config.php: " . $configUser . PHP_EOL;
72-
echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
73-
echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL;
73+
echo "Owner id of the data directory: " . $dataDirectoryUser . PHP_EOL;
74+
echo "Try adding 'sudo -u #" . $dataDirectoryUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL;
75+
echo "If running with 'docker exec' try adding the option '-u " . $dataDirectoryUser . "' to the docker command (without the single quotes)" . PHP_EOL;
7476
exit(1);
7577
}
7678

@@ -90,7 +92,7 @@ function exceptionHandler($exception) {
9092
}
9193

9294
$application = new Application(
93-
\OC::$server->getConfig(),
95+
$config,
9496
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
9597
\OC::$server->getRequest(),
9698
\OC::$server->get(\Psr\Log\LoggerInterface::class),

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

0 commit comments

Comments
 (0)