Bug 104363 - Incorrect "lockfile" util usage
Summary: Incorrect "lockfile" util usage
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-22 11:37 UTC by Peter 'Luna' Runestig
Modified: 2009-12-21 01:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.