Bug 117909 - kwallet/kwalletmanager not consistently writing changes to the filesystem.
Summary: kwallet/kwalletmanager not consistently writing changes to the filesystem.
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kwallet (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-08 03:21 UTC by Greg Fortune
Modified: 2008-10-28 12:33 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 Greg Fortune 2005-12-08 03:21:18 UTC
Version:           KDE 3.4.3 (using KDE KDE 3.4.3)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8) Configured with: /var/tmp/portage/gcc-3.3.6/work/gcc-3.3.6/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3.6 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/info --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libgcj --enable-languages=c,c++,objc,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
OS:                Linux

Changes made through kwalletmanager are not saved to disk when the Save button is pressed. In my recent testing, closing the wallet caused the changes to be written to disk, but a developer on #kde reported that a wallet opened and closed many times since May did not show changes to the files on the filesystem since May. Mine lost passwords since mid October (the date of my last restart of X).

Repro:
1) Check the timestamp on the wallet/wallets in  ~/.kde/share/apps/kwallet/
2) Alt-F2
3) kwalletmanager
4) Click on a wallet
5) Enter password
6) Make a change somewhere in the wallet
7) Wait at least 1 minute if the timestamp in 1) was very recent
8) Click [Save]
9) Wait some period of time (5 minutes ought to be plenty, eh?)
10) Check timestamp on the file again (It probably will match that of #1)
11) Close the wallet.
12) Check the timestamp again. For me, this updated the file.  For the other guy, it had no effect.
13) Exit kwalletmanager entirely and check timestamp again. For the developer on #kde, even this didn't write the wallet out to disk in the location expected.

Of course, I probably don't understand how this is *supposed* to work, but I do know that I lost roughly two months of randomly generated system passwords that are going to be a pain to reset.  Granted, my system was powered off (power supply problem), but I don't understand why it would lose two months worth of data even after I clicked the Save button each time I made a change.

"Some time" ago, this all worked perfectly so it may be a regression. My fuzzy memory says it started occuring at least 4 months ago but I figured I was making some kind of mistake.  I'd guess it started in 3.2 or maybe 3.3.

In addition, http://bugs.kde.org/show_bug.cgi?id=97716 seems to address a similar issue.  I can confirm that KDED gets to fire a signal for closing the wallet even when X is killed with Ctrl-Alt-Backspace. However, this would never occur during a hard shutdown of the system.

Please feel free to contact me for any additional info I might be able to provide.
Comment 1 Thiago Macieira 2005-12-08 11:39:00 UTC
I was the one you talked to on #kde.

I must point out that, while I could not find out how kwallet was saving anything, it was saving. I confirmed that by doing a modification and closing kwalletmanager & kded. The file remained unchanged, but the change was saved when I restarted them.

So the conclusion is simple: either kwalletd manages to save without modifying the MD5, timestamp and file size, or I was looking at the wrong file.

Hypothesis #2 proved to be the one: I've found another .kwl file in ~/.kde/share/apps/kwallet, aside from the visible one in ~/kwallet.

In your case, however, you told me you did not manage to successfully reproduce data loss. You said it only happened once and it was connected to a system crash and power down.

I've retaken last night's tests and confirmed that kwalletd saves the changes when the wallet is closed.
Comment 2 Greg Fortune 2005-12-08 17:45:30 UTC
Yes, it did indeed occured because of a system crash and has occured several times before but it had never been 2 months since my last save so I didn't lose enough to be certain I had clicked Save, etc.  This time, I'm quite sure that I saved properly.

I will add steps for causing permenant loss later today or tomorrow morning as my work schedule allows me to nuke my box :)  I presume that punching the power button will cause me the same problems.

In addition, it would be helpful to know where it's really saving so we users know which files we need to backup.  Obviously, my backups didn't do me much good :)
Comment 3 Thiago Macieira 2006-05-18 19:24:36 UTC
kwallet is writing data consistently for me. Can you still reproduce the original problem?
Comment 4 Greg Fortune 2006-05-19 00:20:29 UTC
I haven't had anything occur that would have caused it to repro and I've haven't had an opportunity to investigate further. Current timestamps on the files I mentioned are 

-rw-r--r-- 1 gfortune gfortune 5.6K Mar 16 06:17 Passwords.kwl
-rw------- 1 gfortune gfortune  28K Apr  6 15:17 kdewallet.kwl

As you stated, it's possible these are not the actual files storing the data and there may be some kind of temp cache file.

After closing the wallet just a few seconds ago as described in step #11, the timestamps appear as follows

gfortune@gfortune ~ $ ls -lh ~/.kde/share/apps/kwallet/
total 36K
-rw-r--r-- 1 gfortune gfortune 6.0K May 18 14:58 Passwords.kwl
-rw------- 1 gfortune gfortune  28K Apr  6 15:17 kdewallet.kwl


So, it's certainly not saving out to these files without an explicit close of the wallet. In the event of a power loss, I can't imagine how the data could possibly get saved :(  Further, I suspect a crash of KDE could cause data loss.  I was able to repro my steps from the first contact on 3.5.0 as well.

Is your kwallet really getting saved when you click on the save button? Are the file timestamps changing?  If the timestamp is not changing, I suspect a crash of KDE or a power loss would result in lost data. If it *is* actually saving for you, update here and I'll down my system causing data loss and respond back.

And thanks for the poke :) I'd forgotten about this.
Comment 5 GML 2006-08-05 09:11:46 UTC
Yes, I think you have detect a problem, I have the same impression when for example I'm on a web page, I store a login/password, and if the computer crashes, Kwallet forget the password.
Comment 6 Greg Fortune 2006-08-15 18:39:44 UTC
This still occurs under 3.5.2.  Also, I've noted when I ask KDE to shutdown while kwalletmanager is running, kwalletmanager crashes.  A proper shutdown of KDE now loses passwords as well.  Manually quiting kwalletmanager before exiting KDE still appears to save the new/changed passwords properly.
Comment 7 Thomas Nichols 2006-10-07 12:56:22 UTC
I just duplicated this bug on a Gentoo box, KDE 3.5.2 / KDEWalletManager 1.1. Clicking Save does not update the timestamp on ~/.kde/share/apps/kwallet/kdewallet.kwl, closing the wallet causes changes to be flushed and timestamp updated. I found this when a system crash (!) caused all changes since last restart (~2 weeks, FWIW) to be lost.
Workaround for now: I'll close and reopen the wallet every time I manually add a password.
Comment 8 morhekil 2007-05-16 20:32:15 UTC
Got the same problem as described in comment #7 on my Gentoo, KDE 3.5.6, KWalletManager 1.1. Wallet's data is saved only when the wallet is explicitly closed. If I just end the session or shutdown computer - all passwords entered during the session are lost. If I delete a wallet and create it again - KWalletManager creates the empty wallet (with the size of 60 bytes), but doesn't update it again unless I explicitly close the wallet after entering any new data.
Comment 9 Michael Leupold 2008-10-28 12:33:52 UTC
It's true, in 3.5 and 4.0 kwalletd only synced the changes back on closing the wallet. This has already been fixed with KDE 4.1. By then a timer was introduced that syncs the changes back to disk a few seconds after the change is made (I think it was either 5 or 10 seconds). Closing this.