⚠️ This issue respects the following points: ⚠️
Bug description
I wanted to run occ encryption:decrypt-all and for some reason the decryption stopped in the middle. Running the script once again raised an InvalidHeaderException and a type error. I checked where this was coming from and it turned out that the cleanup logic in Storage/Wrapper/Encryption.php is broken:
Having an unencrypted file raises an InvalidHeaderException and in the cleanup step it is checked if the source variable (with a file descriptor) is defined here.
try {
$source = $sourceStorage->fopen($sourceInternalPath, 'r');
[...]
} finally {
if (isset($source) && $source !== false) {
fclose($source);
}
[...]
}
However, there is completely unrelated source variable that gets defined beforehand (with a string) and fclose() in the cleanup raises a TypeError here:
if ($sourceStorage->instanceOfStorage(Common::class) && $sourceStorage->getMountOption('mount_point')) {
$mountPoint = $sourceStorage->getMountOption('mount_point');
$source = $mountPoint . '/' . $sourceInternalPath;
$target = $this->getFullPath($targetInternalPath);
$this->copyKeys($source, $target);
} else {
$this->logger->error('Could not find mount point, can\'t keep encryption keys');
}
Steps to reproduce
- Start
occ encryption:decrypt-all
- Interrupt the process
- Start
occ encryption:decrypt-all again
Expected behavior
The files that are already decrypted should be skipped.
Nextcloud Server version
29
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
Configuration report
{
"system": {
"apps_paths": [
{
"path": "\/snap\/nextcloud\/current\/htdocs\/apps",
"url": "\/apps",
"writable": false
},
{
"path": "\/var\/snap\/nextcloud\/current\/nextcloud\/extra-apps",
"url": "\/extra-apps",
"writable": true
}
],
"supportedDatabases": [
"mysql"
],
"memcache.locking": "\\OC\\Memcache\\Redis",
"memcache.local": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 0
},
"log_type": "file",
"logfile": "\/var\/snap\/nextcloud\/current\/logs\/nextcloud.log",
"logfilemode": 416,
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"192.168.178.111",
"192.168.100.111"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "31.0.7.1",
"overwrite.cli.url": "http:\/\/192.168.178.111",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"maintenance": true,
"loglevel": 0,
"theme": "",
"app_install_overwrite": [
"backup"
],
"maintenance_window_start": 1
}
}
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response
Bug description
I wanted to run
occ encryption:decrypt-alland for some reason the decryption stopped in the middle. Running the script once again raised an InvalidHeaderException and a type error. I checked where this was coming from and it turned out that the cleanup logic in Storage/Wrapper/Encryption.php is broken:Having an unencrypted file raises an InvalidHeaderException and in the cleanup step it is checked if the
sourcevariable (with a file descriptor) is defined here.However, there is completely unrelated
sourcevariable that gets defined beforehand (with a string) andfclose()in the cleanup raises a TypeError here:Steps to reproduce
occ encryption:decrypt-allocc encryption:decrypt-allagainExpected behavior
The files that are already decrypted should be skipped.
Nextcloud Server version
29
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
Configuration report
{ "system": { "apps_paths": [ { "path": "\/snap\/nextcloud\/current\/htdocs\/apps", "url": "\/apps", "writable": false }, { "path": "\/var\/snap\/nextcloud\/current\/nextcloud\/extra-apps", "url": "\/extra-apps", "writable": true } ], "supportedDatabases": [ "mysql" ], "memcache.locking": "\\OC\\Memcache\\Redis", "memcache.local": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 0 }, "log_type": "file", "logfile": "\/var\/snap\/nextcloud\/current\/logs\/nextcloud.log", "logfilemode": 416, "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "192.168.178.111", "192.168.100.111" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "mysql", "version": "31.0.7.1", "overwrite.cli.url": "http:\/\/192.168.178.111", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "mysql.utf8mb4": true, "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "maintenance": true, "loglevel": 0, "theme": "", "app_install_overwrite": [ "backup" ], "maintenance_window_start": 1 } }List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response