Permalink
Browse files

fixes for some permission related bugs

  • Loading branch information...
1 parent 7073a3e commit 7acd74857dd0536cb7aff0f71fc345f97885b848 @voda voda committed May 9, 2012
Showing with 16 additions and 8 deletions.
  1. +16 −8 src/main/php/org/bovigo/vfs/vfsStreamWrapper.php
@@ -249,12 +249,18 @@ public function stream_open($path, $mode, $options, $opened_path)
) {
return false;
}
-
+
if (self::TRUNCATE === $mode) {
$this->content->openWithTruncate();
} elseif (self::APPEND === $mode) {
$this->content->openForAppend();
} else {
+ if (!$this->content->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
+ trigger_error('Permission denied', E_USER_WARNING);
+ }
+ return false;
+ }
$this->content->open();
}
@@ -572,23 +578,25 @@ public function rename($path_from, $path_to)
trigger_error(' No such file or directory', E_USER_WARNING);
return false;
}
-
- $dstContent = clone $srcContent;
- $dstNames = $this->splitPath($dstRealPath);
- // Renaming the filename
- $dstContent->rename($dstNames['basename']);
- // Copying to the destination
+ $dstNames = $this->splitPath($dstRealPath);
$dstParentContent = $this->getContent($dstNames['dirname']);
if (null == $dstParentContent) {
trigger_error('No such file or directory', E_USER_WARNING);
return false;
}
-
+ if (!$dstParentContent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
+ trigger_error('Permission denied', E_USER_WARNING);
+ return false;
+ }
if ($dstParentContent->getType() !== vfsStreamContent::TYPE_DIR) {
trigger_error('Target is not a directory', E_USER_WARNING);
return false;
}
+ $dstContent = clone $srcContent;
+ // Renaming the filename
+ $dstContent->rename($dstNames['basename']);
+ // Copying to the destination
$dstParentContent->addChild($dstContent);
// Removing the source
return $this->doUnlink($srcRealPath);

0 comments on commit 7acd748

Please sign in to comment.