summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobert Dailey <rcdailey@gmail.com>2018-12-22 11:14:55 -0600
committerRobert Dailey <rcdailey@gmail.com>2019-01-24 20:39:52 -0600
commita170bf80ec156678abad2ddaf20e1533490d1e4b (patch)
treeec530b2503e4672c68f931506126ce00c243c82e /lib/private
parent20854f463bd046de344eae7ee176c37651819e94 (diff)
downloadnextcloud-server-a170bf80ec156678abad2ddaf20e1533490d1e4b.tar.gz
nextcloud-server-a170bf80ec156678abad2ddaf20e1533490d1e4b.zip
Improve data directory write checking for NFS mounts
If `is_writable()` fails, fall back to logic that attempts to create a file and then checks if it exists. If this check fails, an error occurs as it did before. Discussion on this solution was found here: https://help.nextcloud.com/t/write-errors-for-nfs-mount/23328 Fixes #7124 Signed-off-by: Robert Dailey <rcdailey@gmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/legacy/util.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index a94ced8bb1f..7ab13716547 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -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));
}