Skip to content

Php v7 filesystem check bug with nfs v3 mount from synology  #7124

Description

@Xarin

Steps to reproduce

  1. Arch linux LAMP stack with nextcloud installed using (https://wiki.archlinux.org/index.php/Nextcloud#Installation)
  2. set fstab to mount synology nfs v3 mount on to data directory (migrating the default data in the process)
  3. Check/fix permissions using script located at https://docs.nextcloud.com/server/9/admin_manual/installation/installation_wizard.html
  4. restart httpd service

Expected behaviour

nextcloud writes data to new nfs mounted data mount without issue

Actual behaviour

nextcloud error "Your data directory is not writable"

[root@lin-virt02 nextcloud]# sudo -u http php occ files:scan admin
Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/12/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /usr/share/webapps/nextcloud/lib/private/Console/Application.php:145
Stack trace:
#0 /usr/share/webapps/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/share/webapps/nextcloud/occ(11): require_once('/usr/share/weba...')

Troubleshooting

[root@lin-virt02 nextcloud]# sudo -u http ls -alh data
total 436K
drwxrwxrwx 1 http http 188 Nov 9 04:00 .
drwxr-x--- 16 http http 4.0K Nov 9 03:54 ..
drwxr-x--- 1 http http 76 Sep 30 02:03 admin
drwxr-x--- 1 http http 146 Sep 27 19:19 appdata_ocb0vuuo4fin
drwxr-x--- 1 http http 26 Oct 25 19:14 files_external
-rw-r--r-- 1 http http 324 Sep 27 17:43 .htaccess
-rw-r----- 1 http http 0 Sep 27 17:43 index.html
-rw-r----- 1 http http 428K Nov 7 15:23 nextcloud.log
-rw-r----- 1 http http 0 Sep 27 17:43 .ocdata

[root@lin-virt02 nextcloud]# sudo -u http touch data/test

[root@lin-virt02 nextcloud]# sudo -u http ls -alh data
total 436K
drwxrwxrwx 1 http http 196 Nov 9 04:00 .
drwxr-x--- 16 http http 4.0K Nov 9 03:54 ..
drwxr-x--- 1 http http 76 Sep 30 02:03 admin
drwxr-x--- 1 http http 146 Sep 27 19:19 appdata_ocb0vuuo4fin
drwxr-x--- 1 http http 26 Oct 25 19:14 files_external
-rw-r--r-- 1 http http 324 Sep 27 17:43 .htaccess
-rw-r----- 1 http http 0 Sep 27 17:43 index.html
-rw-r----- 1 http http 428K Nov 7 15:23 nextcloud.log
-rw-r----- 1 http http 0 Sep 27 17:43 .ocdata
-rw-r--r-- 1 http http 0 Nov 9 04:00 test

FIX

Comment out:

/usr/share/webapps/nextcloud/lib/private/legacy/util.php

                   } 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
                           ];

AND

/usr/share/webapps/nextcloud/lib/private/Console/Application.php

           if ($input->getFirstArgument() !== 'check') {
                   $errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
                   if (!empty($errors)) {
                           foreach ($errors as $error) {
                                   $output->writeln((string)$error['error']);
                                   $output->writeln((string)$error['hint']);
                                   $output->writeln('');
                           }
                           throw new \Exception("Environment not properly prepared.");
                   }
           }

Then reboot httpd service. After doing this uploads and downloads are successful and no errors are presented.

Test

[root@lin-virt02 nextcloud]# sudo -u http php occ files:scan admin
Starting scan for user 1 out of 1 (admin)

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 12 | 19 | 00:00:00 |
+---------+-------+--------------+

Server configuration

Operating system: Arch linux

Web server: Apache

Database: Mariadb

PHP version: 7

Nextcloud version (see Nextcloud admin page): Nextcloud 12.0.3

Updated from an older Nextcloud/ownCloud or fresh install: Installed 6 months ago and kept up to date via package manager.

Where did you install Nextcloud from: Arch repo

Client configuration

Browser: chrome/firefox

Operating system: Windows/Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions