Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 9ec2908

Browse files
committed
Do not silently rename, allow exceptions/error to be caught.
1 parent 73fa3c5 commit 9ec2908

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

core/src/plugins/access.fs/FsAccessDriver.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public function downloadAction(ServerRequestInterface &$request, ResponseInterfa
684684

685685
$node = $selection->getUniqueNode();
686686
$dlFile = $node->getUrl();
687-
if(!is_readable($dlFile)){
687+
if(!$this->isReadable($node)){
688688
throw new \Exception("Cannot access file!");
689689
}
690690
$this->logInfo("Get_content", ["files"=>$this->addSlugToPath($selection)]);
@@ -834,14 +834,14 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
834834
$jsonData = new \stdClass;
835835
if($selection->isUnique()){
836836
$stat = @stat($selection->getUniqueNode()->getUrl());
837-
if ($stat !== false && is_readable($selection->getUniqueNode()->getUrl())) {
837+
if ($stat !== false && !$this->isReadable($selection->getUniqueNode())) {
838838
$jsonData = $stat;
839839
}
840840
}else{
841841
$nodes = $selection->buildNodes();
842842
foreach($nodes as $node){
843843
$stat = @stat($node->getUrl());
844-
if(!$stat || !is_readable($node->getUrl())) {
844+
if(!$stat || !$this->isReadable($node)) {
845845
$stat = new \stdClass();
846846
}
847847
$path = $node->getPath();
@@ -1275,7 +1275,8 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
12751275
$lsOptions = $this->parseLsOptions((isSet($httpVars["options"])?$httpVars["options"]:"a"));
12761276

12771277
$startTime = microtime();
1278-
$path = $selection->nodeForPath(($dir!= ""?($dir[0]=="/"?"":"/").$dir:""))->getUrl();
1278+
$dirNode = $selection->nodeForPath(($dir!= ""?($dir[0]=="/"?"":"/").$dir:""));
1279+
$path = $dirNode->getUrl();
12791280
$nonPatchedPath = $path;
12801281
if ($patch) {
12811282
$nonPatchedPath = PathUtils::unPatchPathForBaseDir($path);
@@ -1284,7 +1285,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
12841285
if($testPath === null || $testPath === false){
12851286
throw new \Exception("There was a problem trying to open folder ". $path. ", please check your Administrator");
12861287
}
1287-
if(!is_readable($path) && !is_writeable($path)){
1288+
if(!$this->isReadable($dirNode) && !$this->isWriteable($dirNode)){
12881289
throw new \Exception("You are not allowed to access folder " . $path);
12891290
}
12901291
// Backward compat
@@ -1317,7 +1318,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
13171318
Controller::applyHook("node.read", [&$parentAjxpNode]);
13181319
$nodesList->setParentNode($parentAjxpNode);
13191320
foreach($uniqueNodes as $node){
1320-
if(!file_exists($node->getUrl()) || (!is_readable($node->getUrl()) && !is_writable($node->getUrl()))) continue;
1321+
if(!file_exists($node->getUrl()) || (!$this->isReadable($node) && !$this->isWriteable($node))) continue;
13211322
$nodeName = $node->getLabel();
13221323
if (!$this->filterNodeName($ctx, $node->getPath(), $nodeName, $isLeaf, $lsOptions)) {
13231324
continue;
@@ -2266,10 +2267,22 @@ public function isWriteable(AJXP_Node $node)
22662267
$real = $node->getRealFile();
22672268
return posix_access($real, POSIX_W_OK);
22682269
}
2269-
//clearstatcache();
22702270
return is_writable($node->getUrl());
22712271
}
22722272

2273+
/**
2274+
* @param AJXP_Node $node
2275+
* @return bool
2276+
*/
2277+
public function isReadable(AJXP_Node $node)
2278+
{
2279+
if ( $this->getContextualOption($node->getContext(), "USE_POSIX") == true && extension_loaded('posix')) {
2280+
$real = $node->getRealFile();
2281+
return posix_access($real, POSIX_R_OK);
2282+
}
2283+
return is_readable($node->getUrl());
2284+
}
2285+
22732286
/**
22742287
* Change file permissions
22752288
*

0 commit comments

Comments
 (0)