Skip to content

Commit f1976d4

Browse files
committed
fix: Fix data directory permission check and its test
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 947dcbb commit f1976d4

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

lib/private/legacy/OC_Util.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,14 @@ public static function checkServer(SystemConfig $config) {
314314
[$urlGenerator->linkToDocs('admin-dir_permissions')])
315315
];
316316
}
317-
} elseif (!is_writable($CONFIG_DATADIRECTORY) || !is_readable($CONFIG_DATADIRECTORY)) {
317+
} elseif (!is_readable($CONFIG_DATADIRECTORY)) {
318+
$permissionsHint = $l->t('Permissions can usually be fixed by giving the web server write access to the root directory. See %s.',
319+
[$urlGenerator->linkToDocs('admin-dir_permissions')]);
320+
$errors[] = [
321+
'error' => $l->t('Your data directory is not readable.'),
322+
'hint' => $permissionsHint
323+
];
324+
} elseif (!is_writable($CONFIG_DATADIRECTORY)) {
318325
// is_writable doesn't work for NFS mounts, so try to write a file and check if it exists.
319326
$testFile = sprintf('%s/%s.tmp', $CONFIG_DATADIRECTORY, uniqid('data_dir_writability_test_'));
320327
$handle = fopen($testFile, 'w');

tests/lib/UtilCheckServerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ public function testDataDirWritable(): void {
148148
}
149149

150150
/**
151-
* Tests an error is given when the datadir is not writable
151+
* Tests an error is given when the datadir is not readable
152152
*/
153-
public function testDataDirNotWritable(): void {
153+
public function testDataDirNotReadable(): void {
154154
chmod($this->datadir, 0300);
155155
$result = \OC_Util::checkServer($this->getConfig([
156156
'installed' => true,
@@ -163,7 +163,7 @@ public function testDataDirNotWritable(): void {
163163
* Tests no error is given when the datadir is not writable during setup
164164
*/
165165
public function testDataDirNotWritableSetup(): void {
166-
chmod($this->datadir, 0300);
166+
chmod($this->datadir, 0500);
167167
$result = \OC_Util::checkServer($this->getConfig([
168168
'installed' => false,
169169
'version' => implode('.', Util::getVersion())

0 commit comments

Comments
 (0)