mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #13237 from rcdailey/nfs-write-checks
Improve data directory write checking for NFS mounts
This commit is contained in:
commit
ecc8cccc42
1 changed files with 15 additions and 7 deletions
|
|
@ -43,6 +43,7 @@
|
|||
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
|
||||
* @author Vincent Petry <pvince81@owncloud.com>
|
||||
* @author Volkan Gezer <volkangezer@gmail.com>
|
||||
* @author Robert Dailey <rcdailey@gmail.com>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
|
|
@ -789,13 +790,20 @@ class OC_Util {
|
|||
];
|
||||
}
|
||||
} else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
|
||||
//common hint for all file permissions error messages
|
||||
$permissionsHint = $l->t('Permissions can usually be fixed by giving the webserver write access to the root directory. See %s.',
|
||||
[$urlGenerator->linkToDocs('admin-dir_permissions')]);
|
||||
$errors[] = [
|
||||
'error' => 'Your data directory is not writable',
|
||||
'hint' => $permissionsHint
|
||||
];
|
||||
// is_writable doesn't work for NFS mounts, so try to write a file and check if it exists.
|
||||
$testFile = sprintf('%s/%s.tmp', $CONFIG_DATADIRECTORY, uniqid('data_dir_writability_test_'));
|
||||
$handle = fopen($testFile, 'w');
|
||||
if (!$handle || fwrite($handle, 'Test write operation') === FALSE) {
|
||||
$permissionsHint = $l->t('Permissions can usually be fixed by giving the webserver write access to the root directory. See %s.',
|
||||
[$urlGenerator->linkToDocs('admin-dir_permissions')]);
|
||||
$errors[] = [
|
||||
'error' => 'Your data directory is not writable',
|
||||
'hint' => $permissionsHint
|
||||
];
|
||||
} else {
|
||||
fclose($handle);
|
||||
unlink($testFile);
|
||||
}
|
||||
} else {
|
||||
$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue