diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-01-30 09:36:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 09:36:50 +0100 |
commit | ecc8cccc4257580b0867000509bef0b22cec84f4 (patch) | |
tree | e092b7d279851a2d31d7190bf19fc20165d8c8c7 /lib | |
parent | 502c0df2d915fe87cc5cc8bf9d839e074dbd62b7 (diff) | |
parent | a170bf80ec156678abad2ddaf20e1533490d1e4b (diff) | |
download | nextcloud-server-ecc8cccc4257580b0867000509bef0b22cec84f4.tar.gz nextcloud-server-ecc8cccc4257580b0867000509bef0b22cec84f4.zip |
Merge pull request #13237 from rcdailey/nfs-write-checks
Improve data directory write checking for NFS mounts
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/legacy/util.php | 22 |
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)); } |