Bug 104363

Summary: Incorrect "lockfile" util usage
Product: [Unmaintained] kmail Reporter: Peter 'Luna' Runestig <peter>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: bjoern
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Peter 'Luna' Runestig 2005-04-22 11:37:58 UTC
Version:            (using KDE KDE 3.3.1)
Installed from:    RedHat RPMs
OS:                Linux

When running Kmail with "local mail" and "Procmail lockfile", you get a lot of:
lockfile: Try praying, giving up on "/var/spool/mail/luna.lock"
AFAICS, Kmail doesn't use the "lockfile" utility (that comes with procmail) as intended. lockfile is installed setgid "mail", and when you run it with the -ml/-mu switches, it creates/removes .lock files in /var/spool/mail for the user running it, even when the user don't have write permissions in the /var/spool/mail directory (which is the default). However, Kmail runs lockfile with a named .lock file on the command line, and in that case, lockfile drops it's setgid privs before trying to create the .lock file, and thus failes. My suggestion for Kmail is to use the intended -ml/-mu switches instead of a named .lock file. Here's my hack to do that:

diff -u kdepim-3.3.1.orig/kmail/kmfoldermbox.cpp kdepim-3.3.1/kmail/kmfoldermbox.cpp
--- kdepim-3.3.1.orig/kmail/kmfoldermbox.cpp	2004-08-05 21:26:53.000000000 +0200
+++ kdepim-3.3.1/kmail/kmfoldermbox.cpp	2005-04-22 08:02:54.000000000 +0200
@@ -337,12 +337,13 @@
       break;
 
     case procmail_lockfile:
-      cmd_str = "lockfile -l20 -r5 ";
+      cmd_str = "lockfile -l20 -r5 -ml";
+      /*
       if (!mProcmailLockFileName.isEmpty())
         cmd_str += QFile::encodeName(KProcess::quote(mProcmailLockFileName));
       else
         cmd_str += QFile::encodeName(KProcess::quote(location() + ".lock"));
-
+      */
       rc = system( cmd_str.data() );
       if( rc != 0 )
       {
@@ -466,11 +467,13 @@
       break;
 
     case procmail_lockfile:
-      cmd_str = "rm -f ";
+      cmd_str = "lockfile -mu";
+      /*
       if (!mProcmailLockFileName.isEmpty())
         cmd_str += QFile::encodeName(KProcess::quote(mProcmailLockFileName));
       else
         cmd_str += QFile::encodeName(KProcess::quote(location() + ".lock"));
+      */
 
       rc = system( cmd_str.data() );
       if( mIndexStream )
Comment 1 Till Adam 2005-05-16 23:57:08 UTC
Thanks for the patch, it seems fine and sensible to me. Ingo, ok to commit?
Comment 2 Ingo Klöcker 2005-05-22 00:07:29 UTC
AFAIU the documentation of lockfile the -ml/-mu command line option works exclusively with the system mailbox. But KMail can fetch mail from any mailbox file and for locking those files the -ml/-mu options are useless. So we can only use -ml/-mu if the file we are fetching mail from equals $MAIL.