Bug 419396

Summary: When trying to open a 7z encrypted archive, Krusader does not ask for a password
Product: [Applications] krusader Reporter: Toni Asensi Esteve <toni.asensi>
Component: krarcAssignee: Krusader Bugs Distribution List <krusader-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: krusader-bugs-null
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Toni Asensi Esteve 2020-03-29 21:44:42 UTC
SUMMARY

When trying to open a 7z encrypted archive: Krusader does not ask for a password (as it does when opening e.g. encrypted zip archives). Instead, Krusader waits a lot, and finally shows only "..".

STEPS TO REPRODUCE

1) Creating a 7z encrypted archive that can not be browsed without a password (because its headers are also encrypted):
    7z a /tmp/test-mhe.7z -mhe -ptest /etc/papersize /etc/hosts
entering the archive, and finding problems (like not being asked for a password, waiting a lot, and finally seeing only "..").
        
2) Creating a 7z encrypted archive that can be browsed without the password:
    7z a /tmp/test-without-mhe.7z -ptest /etc/hosts /etc/hosts.allow /etc/hosts.deny
entering the archive, and finding problems when trying to use F3 to see the content of e.g. its "hosts" file.
Comment 1 Toni Asensi Esteve 2020-03-30 20:55:36 UTC
There's a proposed solution in https://phabricator.kde.org/D28411
Comment 2 Toni Asensi Esteve 2020-04-15 22:46:15 UTC
Git commit b4e016807f5c334fce253179a38925a5667c0563 by Toni Asensi Esteve.
Committed on 15/04/2020 at 22:38.
Pushed by asensi into branch 'master'.

Archives: Fix a 7z execution, allow password asking, clarify the name of a function

In Krusader, nowadays it turns out that in `kio_krarcProtocol::checkIf7zIsEncrypted()`: 7z is executed with a " t -y " argument, instead of being executed with two arguments, therefore the execution fails. To avoid that, a simple change can be made.

In more detail: After applying the proposed changes, a 7z execution is left as other places are in the Krusader source code like in `KRarcHandler::checkIf7zIsEncrypted(bool &encrypted, QString fileName)`:
    proc << KrServices::fullPathName("7z") << "-y" << "t";
or `KRarcHandler::arcFileCount(const QString& archive, const QString& type, const QString& password, KRarcObserver *observer)`:
    else if (type == "7z")  lister << KrServices::fullPathName("7z") << "-y" << "l";

After the change is applied, at least an improvement is seen: when the user tries to enter a compressed 7z file, its password is asked.

Besides:
    - A `checkOutputForPassword()` function that was used (and useful) only for 7z files was renamed as `check7zOutputForPassword()`.

Test plan: The one described in the task [Solve some bugs related to archives, remove some duplicated code](https://phabricator.kde.org/T12876).

FIXED: [ 419396 ] When trying to open a 7z encrypted archive, Krusader does not ask for a password

Differential Revision: https://phabricator.kde.org/D28411

M  +3    -4    krArc/krarc.cpp
M  +1    -1    krArc/krarc.h

https://commits.kde.org/krusader/b4e016807f5c334fce253179a38925a5667c0563