Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/Command/Info/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OC\Core\Command\Info;

use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\GroupFolders\Mount\GroupMountPoint;
Expand Down Expand Up @@ -71,6 +72,15 @@ public function execute(InputInterface $input, OutputInterface $output): int {
} else {
$output->writeln(' <error>encryption key not found</error> should be located at: ' . $keyPath);
}
$storage = $node->getStorage();
if ($storage->instanceOfStorage(Encryption::class)) {
/** @var Encryption $storage */
if (!$storage->hasValidHeader($node->getInternalPath())) {
$output->writeln(' <error>file doesn\'t have a valid encryption header</error>');
}
} else {
$output->writeln(' <error>file is marked as encrypted, but encryption doesn\'t seem to be setup</error>');
}
}

if ($node instanceof Folder && $node->isEncrypted() || $node instanceof OCPFile && $node->getParent()->isEncrypted()) {
Expand Down
12 changes: 12 additions & 0 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,4 +894,16 @@ public function clearIsEncryptedCache(): void {
public function setEnabled(bool $enabled): void {
$this->enabled = $enabled;
}

/**
* Check if the on-disk data for a file has a valid encrypted header
*
* @param string $path
* @return bool
*/
public function hasValidHeader(string $path): bool {
$firstBlock = $this->readFirstBlock($path);
$header = $this->util->parseRawHeader($firstBlock);
return (count($header) > 0);
}
}
Loading