]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only use realpath for real directories (#26060) 1517/head
authorVincent Petry <pvince81@owncloud.com>
Thu, 8 Sep 2016 13:14:20 +0000 (15:14 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Mon, 26 Sep 2016 09:22:46 +0000 (11:22 +0200)
In some cross-local-storage use cases, the Local storage is
instantiated with "/" as data directory. In such cases, calling
realpath() would cause PHP warnings when open_basedir is set.

This fix bypasses the realpath() call when dealing with a root storage.

Downstreaming of https://github.com/owncloud/core/pull/26060

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
lib/private/Files/Storage/Local.php

index 19674fc9413745a86a1da7b009307e4a0849e81a..0d63fd46ecca8587cb82de8b79a3330c78500c11 100644 (file)
@@ -54,7 +54,12 @@ class Local extends \OC\Files\Storage\Common {
                        throw new \InvalidArgumentException('No data directory set for local storage');
                }
                $this->datadir = $arguments['datadir'];
-               $this->realDataDir = rtrim(realpath($this->datadir), '/') . '/';
+               // some crazy code uses a local storage on root...
+               if ($this->datadir === '/') {
+                       $this->realDataDir = $this->datadir;
+               } else {
+                       $this->realDataDir = rtrim(realpath($this->datadir), '/') . '/';
+               }
                if (substr($this->datadir, -1) !== '/') {
                        $this->datadir .= '/';
                }