Bug 169166 - KMail loses email accounts and their settings at KDE logout
Summary: KMail loses email accounts and their settings at KDE logout
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: 1.10.0
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 117790 170812 170904 171043 172637 178598 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-15 11:35 UTC by Nico Kruber
Modified: 2009-01-20 17:59 UTC (History)
12 users (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 Nico Kruber 2008-08-15 11:35:55 UTC
Version:           1.10.0 (using KDE 4.1.0)
Installed from:    SuSE RPMs
Compiler:          gcc 4.3.1 
OS:                Linux

Occasionally KMail forgot all my accounts (but one) including all email stored in it (here: the one left over was pop3 and the lost ones all dimap accounts) when logging into KDE again after having logged out or restarted.

I had a closer look at what happened when I logged out of KDE, so I think, I can explain why this is happening:
When kmail closes it seems to want to save its config file (maybe only after changes to the configuration?). But for this to happen it needs an open wallet if passwords are stored.
Now at KDE logout it might happen that KWalletManager/kwalletd gets closed before KMail (or the wallet is closed anyway). In that case a window with the password request to open the wallet appears. Since KDE is already shutting down, you'll probably not unlock the wallet, and kmail will get killed (by the logout process I guess - there is a window stating that kmail crashed but both windows (password request and crash report) close immediately).
The first account was still in the config file, the rest wasn't - and KMail seems to clean up its caches at program start which is when they actually get lost.

Possible solutions / fixes:
- make config file (~/.kde4/share/config/kmailrc) saving independent from access to kwalletd
- make KMail save its config file on changes only - and immediately!
- don't overwrite the config file with an incomplete version
- don't clean up email caches if the config file seems to be incomplete (if detectable) or do so in general
Comment 1 Nico Kruber 2008-08-15 11:41:02 UTC
I should add that KMail seems to stop writing the config file the moment it tries to access the (inaccessible) KWallet. So not necessarily is the first account the only one left intact.
Comment 2 Martin Droessler 2008-09-30 19:54:59 UTC
I have exactly the same problem using Kubuntu. So its not a problem with the suse-packages.
Comment 3 Techwolf 2008-11-13 21:21:34 UTC
I have the same problem on my gentoo system. kmail just up and drop all accounts for no reason. I still haven't figure what is causing it and its a real pita to put back in all the accounts one at a time in kmail. Pasting the accounts back into the kmailrc file does not work.
Comment 4 Techwolf 2008-11-13 21:22:01 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Nico Kruber 2008-12-19 10:19:05 UTC
(In reply to comment #3)
> I still haven't figure what is causing it

I did some testing and you can simulate the behaviour with the following:

- start kontact (actually the bug does not appear with KMail! (i just found out))
- open "configure KMail"
- change something in your mail account settings for receiving mails (doesn't have to be the password), e.g. "include in manual mail check"
- click ok and ok again (closes configurations dialog)
- close the kwallet
- close KMail - it will ask for your KWallet password - don't enter it, hit "cancel"
- kill KMail when it asks you whether to store passwords
-> the result will be the broken config file ~/.kde4/share/config/kmailrc.

So far account data hasn't been lost (~/.kde4/share/apps/kmail/) but when KMail is started again, it will delete all data it doesn't find accounts for.

> its a real pita to put back in all the accounts one at a time in kmail. 
> Pasting the accounts back into the kmailrc file does not work.

If you have a copy of your old configs (~/.kde4/share/config/kmailrc*), replacing it should work. Also restore a backup of the application's data directory (~/.kde4/share/apps/kmail/) and everything should be as it was.

This Bug is still in KDE 4.1.3!!
(I'll test whether this is also the case for KDE 4.2 beta2...)
Comment 6 Rainer Merz 2009-01-04 13:59:36 UTC
I have the same problem since I use KDE4 on Mandriva 2009. Kmail waits some time for opening kwallet then it asks for all passwords all the time when Kmail is looking for new mails. Then after restarting kde to get the passworddialog for kwallet again and Kmail still is waiting for access I type the password for kwallet but all accounts are deleted. Only possiblitiy to solve the problem is restoring kmailrc from a backup. The problem would be not as bad if kmail would wait infinit for getting access to kwallet. I have the problem everytime i have to leave after starting the notebook and When I'm back I want to read mails and not to restart Kmail and save kmailrc from a backup. 
Comment 7 David Weenink 2009-01-12 13:29:51 UTC
I just upgraded to kmail 1.10.4 (kde4.1.4) and my distributed IMAP settings and mails were lost as well as the settings for my pop-account. The loss of settings has occurred several times in the last year. I have not figured out under what circumstances this happens. The messages at logout as refered by the first bug report author also happened to me. Very confusing. Losing email settings is intolearble. A suggestion would be to split the insanely long kmailrc into two parts. One with stable configuration info like accounts and one other?   
Comment 8 Nico Kruber 2009-01-14 12:30:56 UTC
as already suggested ("don't overwrite the config file with an incomplete version") I would propose the following quick fix:

- when saving the config file, save it to a temporary file
-> if that succeeds, copy the temporary file over the real config file

that way we would only lose config file changes, not emails and email account settings - I know it wouldn't solve the problem but at least the bug would not be that severe!
Comment 9 Sam 2009-01-16 01:10:05 UTC
Same problem here, even with kde 4.2. 
Every couple of weeks kmail loses all settings for my e-mail account.
I think that it just happens when kwallet is not available bacause you don't type in the password within a certain time. But I'm not shure
Comment 10 Thomas McGuire 2009-01-19 20:34:50 UTC
*** Bug 170904 has been marked as a duplicate of this bug. ***
Comment 11 Thomas McGuire 2009-01-19 20:34:55 UTC
*** Bug 178598 has been marked as a duplicate of this bug. ***
Comment 12 Thomas McGuire 2009-01-19 20:35:04 UTC
*** Bug 171043 has been marked as a duplicate of this bug. ***
Comment 13 Rainer Merz 2009-01-20 08:59:34 UTC
(In reply to comment #9)
> Same problem here, even with kde 4.2. 
> Every couple of weeks kmail loses all settings for my e-mail account.
> I think that it just happens when kwallet is not available bacause you don't
> type in the password within a certain time. But I'm not shure
> 

I agree with Sam, I only have the problem when I'm too late to type my password for kwallet. The most easy quick fix would be to remove any timeout for kwallet password typing. 
Comment 14 Jonas Diemer 2009-01-20 09:12:27 UTC
I have the feeling that this bug has not come to the attention of KMail developers yet. Severity should be CRITICAL. This bug is a showstopper for any serious work with KDE 4.x (in fact one of the reasons why I am sticking with KUbuntu 8.04).
Comment 15 Nico Kruber 2009-01-20 09:51:25 UTC
(In reply to comment #13)
> The most easy quick fix would be to remove any timeout for kwallet
> password typing. 

that wouldn't solve the problem when logging out (or using kshutdown to logout automatically)
Comment 16 Thomas McGuire 2009-01-20 12:15:29 UTC
SVN commit 913992 by tmcguire:

Fix the bug that causes KMail to loose receiving accounts when
KMail is exiting and wants to open the wallet, but is killed during
that time (happens during logout).

Now, the account config groups are saved after writing out the existing
accounts, so this can't happen anymore.

I also removed the feature to disable accounts, it was only a
hidden feature and caused trouble with this.

BUG: 169166


 M  +40 -59    accountmanager.cpp  
 M  +6 -10     accountmanager.h  
 M  +1 -2      kmkernel.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=913992
Comment 17 Thomas McGuire 2009-01-20 12:34:32 UTC
SVN commit 913998 by tmcguire:

Backport r913992 by tmcguire from trunk to the 4.2 branch:

Fix the bug that causes KMail to loose receiving accounts when
KMail is exiting and wants to open the wallet, but is killed during
that time (happens during logout).

Now, the account config groups are saved after writing out the existing
accounts, so this can't happen anymore.

I also removed the feature to disable accounts, it was only a
hidden feature and caused trouble with this.

CCBUG: 169166
CCMAIL: winter@kde.org



 M  +40 -59    accountmanager.cpp  
 M  +6 -10     accountmanager.h  
 M  +1 -2      kmkernel.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=913998
Comment 18 Thomas McGuire 2009-01-20 13:12:00 UTC
SVN commit 914005 by tmcguire:

Backport r913992 by tmcguire from trunk to the 4.1 branch:

Fix the bug that causes KMail to loose receiving accounts when
KMail is exiting and wants to open the wallet, but is killed during
that time (happens during logout).

Now, the account config groups are saved after writing out the existing
accounts, so this can't happen anymore.

I also removed the feature to disable accounts, it was only a
hidden feature and caused trouble with this.

CCBUG: 169166



 M  +40 -60    accountmanager.cpp  
 M  +6 -10     accountmanager.h  
 M  +1 -2      kmkernel.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=914005
Comment 19 Thomas McGuire 2009-01-20 15:19:10 UTC
*** Bug 172637 has been marked as a duplicate of this bug. ***
Comment 20 Thomas McGuire 2009-01-20 15:20:08 UTC
*** Bug 170812 has been marked as a duplicate of this bug. ***
Comment 21 Thomas McGuire 2009-01-20 15:22:55 UTC
*** Bug 117790 has been marked as a duplicate of this bug. ***
Comment 22 S. Burmeister 2009-01-20 17:59:37 UTC
Thanks a lot for fixing this bug!