Migration of kwallet failed

Martin Steigerwald martin at lichtvoll.de
Tue Apr 3 09:03:51 BST 2018


Michael Schwartzkopff - 03.04.18, 07:19:
> Am 02.04.2018 um 10:11 schrieb Martin Steigerwald:
[…]
> > Michael Schwartzkopff - 02.04.18, 07:44:
> >> I did an upgrade of ubuntu 14.04 to 16.04 and now my kwallet is empty.
> >> 
> >> 
> >> The version of kwalletmanager on the old system was 4:4.13.2.
> >> 
> >> The version on the new system is 4:15.12.3-0ubuntu1.
> >> 
> >> 
> >> The new kwalletmanager just says: "Error -9".
> >> 
> >> Now I installed an other machine with the old ubuntu 14.04 to open the
> >> kwallet there and export it to XML. But opening the kdewallet.kwl there
> >> also fails with "Error 42".
> > 
> > This should work.
> > 
> > Which one did you use? You need to use the old one in ~/.kde/share/apps/
> > kwalletd, not the new one in ~/.config/kwalletd.
> > 
> >> Any idea how I can retrieve my passwords? It really would be urgent.
> > 
> > You can retry the migration:
> > 
> > Set alreadyMigrated to false again:
> > 
> > %> cat .config/kwalletrc
> > [Migration]
> > alreadyMigrated=true
> > 
> > Restart kwalletd. One way is to log out and log in. There is another way
> > which works during a session, but I am not sure how it worked. Maybe you
> > can just quit kwalletd5 process and start it again.
> > 
> > Also see:
> > 
> > https://wiki.gentoo.org/wiki/KDE/
> > Troubleshooting#Recover_KWallet_passwords_after_failed_migration
[…]
> thanks for your hint. But setting Migration flag to false did not help.
> Since I did set up an old ubuntu version already I have little hope that
> an old gentoo would help.
> 
> 
> But it seems a last hope if nothing elase works.

No, I was not suggesting you setup a Gentoo. I don´t think it matters whether 
its kwallet(d|manager) 4 from Ubuntu or Gentoo.

> Any other ideas to recover my passwords? Since I know my master password
> and I have the salt and the kwl files, is there a cli tool just to
> decrypt the contents and dump it? Or is there a description of the data
> format of the kwl file, so I could write it myself?

There was a tool. Oh and it appears there still is: At least Debian still has 
the package kwalletcli. It depends on KF5 stuff already, so I am not sure 
whether it would be able to read old files. But AFAIR there has been a KDE SC 
4 version as well. Unfortunately it can only access specified entries and not 
dump the whole contents of it. But well, you may ask its author Thorsten 
Glaser for help to recover your kwallet, as I think he may know quite a bit 
more about it than me. You can find mail address with apt-cache show 
kwalletcli. There are also language bindings¹ including a Python example, so 
maybe something is scriptable. kwalletcli itself can only read the standard 
wallet.

[1] https://www.mirbsd.org/kwalletcli.htm

In addition to that there is also a kwallet-query tool². It can also list 
entries. And you give it the name of the wallet to use. It is from one of the 
maintainers of it Valentin Rusu. And its part of kwallet distribution since 
some time. Listing my standard wallet works like this:

kwallet-query -l kdewallet

But just gives a list of entries, without passwords. You then need a script 
which reads password of every item.

[2] (was not able to access it, timeout, but maybe you can, or archive.org can 
help) https://barlog.rusu.info/valentin/blog/?p=386

Well as I bet you can speak German you can also skim through my article from 
2011 about password managers³. Maybe some of them or one of their successors 
(latest keepass(2|x) for example) can *import* kwallet files. Hmmm, does not 
seem like keepass2 can directly import them[4].

[3] http://www.linux-community.de/Internal/Artikel/Print-Artikel/LinuxUser/
2011/01/Passwortmanager-im-Vergleich

[4] https://keepass.info/help/base/importexport.html

Also in case you still have that old Ubuntu: At least with Debian for some 
release there have been kwalletd4 and kwalletd from KF5 running in parallel, 
but only one kwalletmanager, the one of KF5. So in case you can get any KDE SC 
4 based CLI tool or kwalletmanager from KDE SC 4 for work, you should be able 
to access your old wallet, but well, haven´t you already been able to access 
the old contents as XML or so?

> Now I installed an other machine with the old ubuntu 14.04 to open the
> kwallet there and export it to XML. But opening the kdewallet.kwl there
> also fails with "Error 42". 

Ok, nope. I however don´t get why. The old kwalletd should be able to open 
those. Maybe you need to go back another Ubuntu release for so, to have both 
old kwalletd and kwalletmanager from KDE SC 4. As the kwalletmanager5 will 
only access kwalletd5. And you need to make sure that you use the KDE SC 4 
wallets in ~/.kde/share/apps/kwallet, not the new ones in ~/.config/kwallet.


Another crazy idea of mine: I remember loosely that I may have done something 
unconventional back then in order to migrate the wallets. I am still not sure 
whether there is any significant difference between old and new files. So 
maybe if you just move the old files over manually to .local/share/kwalletd 
restart your session and just access them manually. Beware: This may or may 
not work. I am not sure anymore what I did back then, but I know I got 
everything migrated. So maybe this idea is completely off-track. On one of my 
user accounts it was quite a journey on another one it migration worked out of 
the box.

On any account the CLI tools just access the standard directory for wallets, 
thus .local/share/kwalletd or for KDE SC 4 ~/.kde/share/apps/kwallet, that 
folder option of them is to specify folder inside the wallet, … so moving 
files around can help with them also. kwallet-query is from around 2015, I do 
not know whether its available as KDE SC 4 version. But kwalletcli is 
available since a long time.

Before you try anything like that, make sure you have backups of everything :)

Also check in ~/.xsession-errors or user.log for messages on why it fails, 
probably enabling the necessary kdebugdialog(5) categories (or all of them).

I am sorry none of this is a ready-made solution that is guaranteed to work, 
however in case you are desperate enough to get back your passwords, some of 
the hints may be useful in order to find a way to do just that. I am pretty 
sure that they *can* be recovered.

I heard of many issues with migrating KWallet from 4 to 5, so at least you are 
not alone with it.

I will be traveling today. I hope any of this helps. In case you dig out a 
solution, please, pretty please at least post it here so that others can know.

Thanks,
-- 
Martin


More information about the kde mailing list