Exemplo n.º 1
0
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     $this->loadContext('ocencryption');
     $this->position = 0;
     $this->cache = '';
     $this->writeFlag = false;
     $this->unencryptedBlockSize = $this->encryptionModule->getUnencryptedBlockSize($this->signed);
     if ($mode === 'w' || $mode === 'w+' || $mode === 'wb' || $mode === 'wb+' || $mode === 'r+' || $mode === 'rb+') {
         $this->readOnly = false;
     } else {
         $this->readOnly = true;
     }
     $sharePath = $this->fullPath;
     if (!$this->storage->file_exists($this->internalPath)) {
         $sharePath = dirname($sharePath);
     }
     $accessList = $this->file->getAccessList($sharePath);
     $this->newHeader = $this->encryptionModule->begin($this->fullPath, $this->uid, $mode, $this->header, $accessList);
     if ($mode === 'w' || $mode === 'w+' || $mode === 'wb' || $mode === 'wb+') {
         // We're writing a new file so start write counter with 0 bytes
         $this->unencryptedSize = 0;
         $this->writeHeader();
         $this->headerSize = $this->util->getHeaderSize();
         $this->size = $this->headerSize;
     } else {
         $this->skipHeader();
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * notify encryption module about added/removed users from a file/folder
  *
  * @param string $path relative to data/
  * @throws Exceptions\ModuleDoesNotExistsException
  */
 public function update($path)
 {
     // if a folder was shared, get a list of all (sub-)folders
     if ($this->view->is_dir($path)) {
         $allFiles = $this->util->getAllFiles($path);
     } else {
         $allFiles = array($path);
     }
     $encryptionModule = $this->encryptionManager->getEncryptionModule();
     foreach ($allFiles as $file) {
         $usersSharing = $this->file->getAccessList($file);
         $encryptionModule->update($file, $this->uid, $usersSharing);
     }
 }
Exemplo n.º 3
0
 /**
  * update keyfiles and share keys recursively
  *
  * @param int $fileSource file source id
  */
 private function update($fileSource)
 {
     $path = \OC\Files\Filesystem::getPath($fileSource);
     $info = \OC\Files\Filesystem::getFileInfo($path);
     $owner = \OC\Files\Filesystem::getOwner($path);
     $view = new \OC\Files\View('/' . $owner . '/files');
     $ownerPath = $view->getPath($info->getId());
     $absPath = '/' . $owner . '/files' . $ownerPath;
     $mount = $this->mountManager->find($path);
     $mountPoint = $mount->getMountPoint();
     // if a folder was shared, get a list of all (sub-)folders
     if ($this->view->is_dir($absPath)) {
         $allFiles = $this->util->getAllFiles($absPath, $mountPoint);
     } else {
         $allFiles = array($absPath);
     }
     $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
     foreach ($allFiles as $path) {
         $usersSharing = $this->file->getAccessList($path);
         $encryptionModule->update($path, $this->uid, $usersSharing);
     }
 }