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

Commit 42685c3

Browse files
committed
Invoke is_readable() at some places to dynamically compute permissions
1 parent c282ee0 commit 42685c3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

core/src/plugins/access.fs/class.fsAccessDriver.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function switchAction($action, $httpVars, $fileVars)
391391
header("Content-type:application/json");
392392
if($selection->isUnique()){
393393
$stat = @stat($this->urlBase.$selection->getUniqueFile());
394-
if (!$stat) {
394+
if (!$stat || !is_readable($selection->getUniqueNode()->getUrl())) {
395395
print '{}';
396396
} else {
397397
print json_encode($stat);
@@ -401,7 +401,7 @@ public function switchAction($action, $httpVars, $fileVars)
401401
print '{';
402402
foreach($files as $index => $path){
403403
$stat = @stat($this->urlBase.$path);
404-
if(!$stat) $stat = '{}';
404+
if(!$stat || !is_readable($this->urlBase.$path)) $stat = '{}';
405405
else $stat = json_encode($stat);
406406
print json_encode($path).':'.$stat . (($index < count($files) -1) ? "," : "");
407407
}
@@ -854,6 +854,9 @@ public function switchAction($action, $httpVars, $fileVars)
854854
if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass($this->repository->getId()) == "fsAccessWrapper") {
855855
$nonPatchedPath = fsAccessWrapper::unPatchPathForBaseDir($path);
856856
}
857+
if(!is_readable($path) && !is_writeable($path)){
858+
throw new Exception("You are not allowed to access folder " . $path);
859+
}
857860
// Backward compat
858861
if($selection->isUnique() && strpos($selection->getUniqueFile(), "/") !== 0){
859862
$selection->setFiles(array($dir . "/" . $selection->getUniqueFile()));
@@ -892,7 +895,7 @@ public function switchAction($action, $httpVars, $fileVars)
892895
AJXP_XMLWriter::renderAjxpHeaderNode($parentAjxpNode);
893896
}
894897
foreach($uniqueNodes as $node){
895-
if(!file_exists($node->getUrl())) continue;
898+
if(!file_exists($node->getUrl()) || (!is_readable($node->getUrl()) && !is_writable($node->getUrl()))) continue;
896899
$nodeName = $node->getLabel();
897900
if (!$this->filterNodeName($node->getPath(), $nodeName, $isLeaf, $lsOptions)) {
898901
continue;
@@ -1212,6 +1215,7 @@ public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false)
12121215
$metaData["file_owner"] = @fileowner($ajxpNode->getUrl()) || "unknown";
12131216
$crtPath = $ajxpNode->getPath();
12141217
$vRoots = $this->repository->listVirtualRoots();
1218+
$metaData["ajxp_readonly"] = "false";
12151219
if (!empty($crtPath)) {
12161220
if (!@$this->isWriteable($ajxpNode->getUrl())) {
12171221
$metaData["ajxp_readonly"] = "true";
@@ -1655,7 +1659,7 @@ public function rename($filePath, $filename_new, $dest = null)
16551659
$mess = ConfService::getMessages();
16561660
$filename_new=AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($filename_new), AJXP_SANITIZE_FILENAME);
16571661
$filename_new = substr($filename_new, 0, ConfService::getCoreConf("NODENAME_MAX_LENGTH"));
1658-
$old=$this->urlBase."/$filePath";
1662+
$old=$this->urlBase.$filePath;
16591663
if (!$this->isWriteable($old)) {
16601664
throw new AJXP_Exception($mess[34]." ".$nom_fic." ".$mess[99]);
16611665
}

core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public function applyAction($actionName, $httpVars, $fileVars)
207207
$commitIndex = true;
208208
continue;
209209
}
210+
if (!is_readable($tmpNode->getUrl())){
211+
continue;
212+
}
210213
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
211214
if (isSet($returnNodes)) {
212215
$returnNodes[] = $tmpNode;

0 commit comments

Comments
 (0)