Bug 420784 (anarcho) - Restore of Vaults fail
Summary: Restore of Vaults fail
Status: RESOLVED FIXED
Alias: anarcho
Product: Plasma Vault
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Ivan Čukić
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-30 06:09 UTC by Justin
Modified: 2020-05-05 18:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Justin 2020-04-30 06:09:28 UTC
SUMMARY

I have restored a backup of the home folder,
I copied over vault files but Vaults does not recognise an existing Vault.
STEPS TO REPRODUCE
1. Copy of home folder (with Vault directory included)
2. Copy over plasmavaultrc from backup into home/.config
3. Copy over plasma-vault from backup into home/.local/share/

OBSERVED RESULT
Clicking on the Vault icon gives a message to '+ Create a new vault'


EXPECTED RESULT
Clicking on Vault icon presents option to enter vault password.


SOFTWARE/OS VERSIONS 
Linux/KDE Plasma: 
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.4.0-28-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-7820HQ CPU @ 2.90GHz
Memory: 31.2 GiB of RAM


ADDITIONAL INFORMATION
Attention Nate Graham: plasmavaultrc which could not be found in the Timeshift snapshots was discovered in an older snapshot.
Comment 1 Nate Graham 2020-05-01 13:42:07 UTC
I debugged this with Justin and we think we migrated all the old files into the correct locations on his mew machine, but the Vaults applet was still not showing his existing vault.
Comment 2 Ivan Čukić 2020-05-01 15:36:25 UTC
> I debugged this with Justin and we think we migrated all the old files into the 

This is not all that helpful :)

1. Can you try creating a new vault (with the same backend as the last one) and checking that it works at all?
2. What does the following command return?
qdbus --literal org.kde.kded5 /modules/plasmavault availableDevices
3. Open the vaultrc file and check whether the newly created vault is there
4. Is the old vault present in the config?
5. Check that the encrypted directory location (path in the square brackets) and the path specified in mountPoint exist
6a. What is the value of activities field for that vault?
6b. If the field is not empty, what does this command return:
kactivities-cli --list-activities
7. Can you mount the old vault manually using encfs/cryfs from command line?


I'm marking this as needsinfo - I don't expect it to be a vault issue per se, but let's triage this and make it working anyhow.
Comment 3 Justin 2020-05-02 01:55:06 UTC
Hello Ivan,

I created a new vault called 'Safe'. I attempted to place it in the same directory as my previous vault called 'Vault'at /home/anarcho/Personal/Vault It said the directory was not empty. I clicked Ok and it created 'Safe' at /home/anarcho/Vault. My previous vault still would not show in the taskbar icon. I ran the command:

anarcho@LuNoHo:~$ qdbus --literal org.kde.kded5 /modules/plasmavault av
[Argument: a(sssqsasb) {[Argument: (sssqsasb) "Safe", "/home/anarcho/.lt/Safe.enc", "", 2, "", {}, false], [Argument: (sssqsasb) "Vault", "/hoe/plasma-vault/Vault.enc", "", 2, "", {"5e847ac8-3735-4647-ad07-ac753d5
anarcho@LuNoHo:~$ 

I did a sudo apt update.
Trying to open the old vault via Dolphin, brought a pop up saying cryfs needed to be updated. I clicked ok. I was then able to access the vault!

'Safe' appears under the taskbar icon but 'Vault' seems to not always be there, yet I can access it through Dolphin.

I ran the command again:

anarcho@LuNoHo:~$ anarcho@LuNoHo:~$ qdbus --literal org.kde.kded5 /modules/plasmavault
anarcho@LuNoHo:~$: command not found
anarcho@LuNoHo:~$ qdbus --literal org.kde.kded5 /modules/plasmavault
signal void org.kde.plasmavault.hasOpenVaultsChanged(bool hasOpenVaults)
signal void org.kde.plasmavault.vaultAdded({D-Bus type "(sssqsasb)"} vaultData)
signal void org.kde.plasmavault.vaultChanged({D-Bus type "(sssqsasb)"} vaultData)
signal void org.kde.plasmavault.vaultRemoved(QString device)
method {D-Bus type "a(sssqsasb)"} org.kde.plasmavault.availableDevices()
method void org.kde.plasmavault.closeAllVaults()
method void org.kde.plasmavault.closeVault(QString device)
method void org.kde.plasmavault.configureVault(QString device)
method void org.kde.plasmavault.deleteVault(QString device, QString name)
method void org.kde.plasmavault.forceCloseAllVaults()
method void org.kde.plasmavault.forceCloseVault(QString device)
method bool org.kde.plasmavault.hasOpenVaults()
method void org.kde.plasmavault.openVault(QString device)
method void org.kde.plasmavault.openVaultInFileManager(QString device)
method void org.kde.plasmavault.requestImportVault()
method void org.kde.plasmavault.requestNewVault()
method void org.kde.plasmavault.updateStatus()
signal void org.freedesktop.DBus.Properties.PropertiesChanged(QString interface_name, QVariantMap changed_properties, QStringList invalidated_properties)
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()

Thanks for the help Ivan (and Nate)!
You may mark this as solved and close if you think there is nothing more to explore!
Comment 4 Ivan Čukić 2020-05-02 06:08:20 UTC
If I'm not mistaken (some parts are missing in you response, so I'm making an educated guess :) ), you haven't restored activity configuration and your vault is assigned to an activity with an id of "5e847ac8-3735-4647-ad07-ac753d5" which no longer exists.

Try to do this - open konsole and:
killall kded5
cd ~/.config
mv plasmavaultrc plasmavaultrc.backup
grep -v 5e847ac8-3735-4647 plasmavaultrc.backup > plasmavaultrc
kded5 &
Comment 5 Nate Graham 2020-05-02 22:43:43 UTC
Ah of course, I forgot the activity integration.

If you're right though, then IMO there's a real bug here. When a user restores their system, their vaults shouldn't disappear due to the implementation detail that the UUID of the activity they were assigned to on the old system is no longer valid on the new system. A vault becoming inaccessible after restoring from backup amounts to data loss.
Comment 6 Ivan Čukić 2020-05-03 07:45:13 UTC
Incomplete backup restoration is not something I can cover in the general case.

But, I have been planning to handle missing activities more gracefully.

The usual mantra for encryption is that data loss is preferred to a data leak, but I guess that the 'leak' in this case is not a real problem - if an attacker has system access, they can access the rc file and see the list of all existing vaults regardless of what is shown in the applet.
Comment 7 Ivan Čukić 2020-05-04 14:39:37 UTC
Git commit 2befe1ffd7d75be3603e38270c5db2847083f292 by Ivan Čukić.
Committed on 04/05/2020 at 14:39.
Pushed by ivan into branch 'master'.

Unassign activity from vault on activity deletion

Summary: CCBUG: 420784

Reviewers: ngraham, davidedmundson, mart

Reviewed By: mart

Subscribers: plasma-devel

Tags: #plasma

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

M  +60   -14   kded/service.cpp
M  +2    -0    kded/service.h

https://commits.kde.org/plasma-vault/2befe1ffd7d75be3603e38270c5db2847083f292
Comment 8 Nate Graham 2020-05-04 14:47:52 UTC
Thanks Ivan! So is there anything more we can do here?
Comment 9 Justin 2020-05-05 06:16:23 UTC
(In reply to Ivan Čukić from comment #4)
> If I'm not mistaken (some parts are missing in you response, so I'm making
> an educated guess :) ), you haven't restored activity configuration and your
> vault is assigned to an activity with an id of
> "5e847ac8-3735-4647-ad07-ac753d5" which no longer exists.
> 
> Try to do this - open konsole and:
> killall kded5
> cd ~/.config
> mv plasmavaultrc plasmavaultrc.backup
> grep -v 5e847ac8-3735-4647 plasmavaultrc.backup > plasmavaultrc
> kded5 &

This worked! Thanks Ivan!
I now also have an extra option 'Configure Vault'
Comment 10 Ivan Čukić 2020-05-05 14:43:34 UTC
@Nate

Nothing else to do here I think. Marking as resolved.

@Justin

No problem, glad to be of help!
Comment 11 Nate Graham 2020-05-05 16:53:18 UTC
If I'm reading that commit correctly, the activity's UUID will be removed from the config file when the activity is deleted, but it will still be there if the system crashes and the config file is restored from backup, right? If so, maybe on launch, it could check to see if the UUID is valid, and if not, automatically remove it?
Comment 12 Ivan Čukić 2020-05-05 17:17:15 UTC
It also does it on startup - just async as it needs to wait for the activities list to be loaded from kamd.
Comment 13 Nate Graham 2020-05-05 18:10:42 UTC
Perfect! Let's call this fixed, then. :)