Skip to content

Commit

Permalink
Only use realpath for real directories (#26060)
Browse files Browse the repository at this point in the history
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 owncloud/core#26060

Signed-off-by: Lukas Reschke <[email protected]>
  • Loading branch information
Vincent Petry authored and LukasReschke committed Sep 26, 2016
1 parent e0dd676 commit 7535d3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public function __construct($arguments) {
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 .= '/';
}
Expand Down

0 comments on commit 7535d3e

Please sign in to comment.