use OCP\Files\Node;
use OC\Files\Storage\FailedStorage;
use OC\Files\Storage\Wrapper\PermissionsMask;
+use OC\Files\Storage\Wrapper\Wrapper;
use OC\User\NoUserException;
use OCA\Files_External\Config\ExternalMountPoint;
use OCP\Constants;
private string $sourcePath = '';
+ private static int $initDepth = 0;
+
public function __construct($arguments) {
$this->ownerView = $arguments['ownerView'];
$this->logger = \OC::$server->getLogger();
if ($this->initialized) {
return;
}
+
$this->initialized = true;
+ self::$initDepth++;
+
try {
+ if (self::$initDepth > 10) {
+ throw new \Exception("Maximum share depth reached");
+ }
+
/** @var IRootFolder $rootFolder */
$rootFolder = \OC::$server->get(IRootFolder::class);
$this->ownerUserFolder = $rootFolder->getUserFolder($this->superShare->getShareOwner());
$this->cache = new FailedCache();
$this->rootPath = '';
} else {
+ if ($this->nonMaskedStorage instanceof Wrapper && $this->nonMaskedStorage->isWrapperOf($this)) {
+ throw new \Exception('recursive share detected');
+ }
$this->nonMaskedStorage = $ownerNode->getStorage();
$this->sourcePath = $ownerNode->getPath();
$this->rootPath = $ownerNode->getInternalPath();
if (!$this->nonMaskedStorage) {
$this->nonMaskedStorage = $this->storage;
}
+ self::$initDepth--;
}
/**
public function getDirectoryContent($directory): \Traversable {
return $this->getWrapperStorage()->getDirectoryContent($directory);
}
+
+ public function isWrapperOf(IStorage $storage) {
+ $wrapped = $this->getWrapperStorage();
+ if ($wrapped === $storage) {
+ return true;
+ }
+ if ($wrapped instanceof Wrapper) {
+ return $wrapped->isWrapperOf($storage);
+ }
+ return false;
+ }
}