Bug 42547 - repeatedly sends email if permission denied
Summary: repeatedly sends email if permission denied
Status: CLOSED FIXED
Alias: None
Product: kmail
Classification: Applications
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: 2002-05-14 00:48 UTC by Russell Miller
Modified: 2007-09-14 12:17 UTC (History)
0 users

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 Russell Miller 2002-05-14 00:37:34 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kmail
Version:           KDE 3.0.0 
Severity:          normal
Installed from:    RedHat RPMs
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Not Specified

I was cleaning out my Mail folder and accidentally set the sent-mail folder to be owned by root.  I then tried to send a message.  It responded with permission denied... then it continued to attempt to send the email and popssed up the same permission denied window 15 times.  So far I've sent 15 copies of the message to the mailing list and it's still going.

It should not send emails repeatedly upon failure should log it maybe write the mail somewhere else and *not try again*...

Thanks.

(Submitted via bugs.kde.org)
Comment 1 Russell Miller 2002-05-16 00:04:04 UTC
--------------Boundary-00=_S6G64D8WOEQ2YUH58EMV
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 8bit

Attached is a patch (context diff) to fix this bug.  It appears to be related 
to insufficient error code checking.

*** kmsender.cpp.origWed May 15 18:58:58 2002
--- kmsender.cppWed May 15 17:08:56 2002
***************
*** 210215 ****
--- 210216 ----
  {
    KMFolder *sentFolder = 0 *imapSentFolder = 0;
    bool someSent = mCurrentMsg;
+   int rc;
    if (someSent) mSentMessages++;
    int percent = (mTotalMessages) ? (100 * mSentMessages / mTotalMessages) : 
0;
    if (percent > 100) percent = 100;
***************
*** 240247 ****
  
      if ( sentFolder == 0 )
        sentFolder = kernel->sentFolder();
!     else
!       sentFolder->open();
  
      // 0==processed ok 1==no filter matched 2==critical error abort!
      int processResult = 
kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);
--- 241253 ----
  
      if ( sentFolder == 0 )
        sentFolder = kernel->sentFolder();
!     else {
!       rc = sentFolder->open();
!       if (rc != 0) {
!         return;
!       }
!     }
! 
  
      // 0==processed ok 1==no filter matched 2==critical error abort!
      int processResult = 
kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);


--Russell

-- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
--------------Boundary-00=_S6G64D8WOEQ2YUH58EMV
Content-Type: text/x-diff;
  charset="us-ascii";
  name="kmail.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmail.patch"

*** kmsender.cpp.origWed May 15 18:58:58 2002
--- kmsender.cppWed May 15 17:08:56 2002
***************
*** 210215 ****
--- 210216 ----
  {
    KMFolder *sentFolder = 0 *imapSentFolder = 0;
    bool someSent = mCurrentMsg;
+   int rc;
    if (someSent) mSentMessages++;
    int percent = (mTotalMessages) ? (100 * mSentMessages / mTotalMessages) : 0;
    if (percent > 100) percent = 100;
***************
*** 240247 ****
  
      if ( sentFolder == 0 )
        sentFolder = kernel->sentFolder();
!     else
!       sentFolder->open();
  
      // 0==processed ok 1==no filter matched 2==critical error abort!
      int processResult = kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);
--- 241253 ----
  
      if ( sentFolder == 0 )
        sentFolder = kernel->sentFolder();
!     else {
!       rc = sentFolder->open();
!       if (rc != 0) {
!         return;
!       }
!     }
! 
  
      // 0==processed ok 1==no filter matched 2==critical error abort!
      int processResult = kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);

--------------Boundary-00=_S6G64D8WOEQ2YUH58EMV--
Comment 2 Volker Augustin 2002-05-16 06:41:13 UTC
> Attached is a patch (context diff) to fix this bug.  It appears to be
> related to insufficient error code checking.

Could you please resend your patch in unified format (diff -u)? Unified patch 
files are much easier to read.

Regards
Volker Augustin
Comment 3 Russell Miller 2002-05-16 06:46:29 UTC
--------------Boundary-00=_HTY6FJ9V1591XGH8URGN
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

It is attached.

On Thursday 16 May 2002 01:41 am Volker Augustin wrote:
> > Attached is a patch (context diff) to fix this bug.  It appears to be
> > related to insufficient error code checking.
>
> Could you please resend your patch in unified format (diff -u)? Unified
> patch files are much easier to read.
>
> Regards
> Volker Augustin

-- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
--------------Boundary-00=_HTY6FJ9V1591XGH8URGN
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmail.udiff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmail.udiff"

--- kmsender.cpp.origWed May 15 18:58:58 2002
+++ kmsender.cppWed May 15 17:08:56 2002
@@ -2106 +2107 @@
 {
   KMFolder *sentFolder = 0 *imapSentFolder = 0;
   bool someSent = mCurrentMsg;
+  int rc;
   if (someSent) mSentMessages++;
   int percent = (mTotalMessages) ? (100 * mSentMessages / mTotalMessages) : 0;
   if (percent > 100) percent = 100;
@@ -2408 +24113 @@
 
     if ( sentFolder == 0 )
       sentFolder = kernel->sentFolder();
-    else
-      sentFolder->open();
+    else {
+      rc = sentFolder->open();
+      if (rc != 0) {
+        return;
+      }
+    }
+
 
     // 0==processed ok 1==no filter matched 2==critical error abort!
     int processResult = kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);

--------------Boundary-00=_HTY6FJ9V1591XGH8URGN--
Comment 4 Michael H 2002-05-16 19:40:53 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

On Thursday 16 May 2002 08:46 Russell Miller wrote:
> It is attached.

Thanks for the patch. It solves the mail bombing problem but the KMail
process does not exit if the user tries to close KMail.

Regards
Michael Häckel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE85AtFe9KEPyN2R8URAi98AJ93iYsMWKFUk/5XJwEJ0dLZ0tn6+gCfUQle
clAgsENZ4FcZdCyh16VI9oA=
=2jOd
-----END PGP SIGNATURE-----
Comment 5 Russell Miller 2002-05-17 12:25:20 UTC
ok I'll give it some more thought.  I did test it but on the CVS release 
and it kept crashing before I could try to quit it.

--Russell

On Thursday 16 May 2002 02:40 pm Michael Häckel wrote:
> Hi
>
> On Thursday 16 May 2002 08:46 Russell Miller wrote:
> > It is attached.
>
> Thanks for the patch. It solves the mail bombing problem but the KMail
> process does not exit if the user tries to close KMail.
>
> Regards
> Michael Häckel

-- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
Comment 6 Russell Miller 2002-05-17 23:12:08 UTC
--------------Boundary-00=_843AHXVNG8NU3LLCI1ZZ
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Attached is a patched patch.  Adding a cleanup() call before return; seems to 
fix that problem.

--Russell

On Thursday 16 May 2002 02:40 pm Michael Häckel wrote:
> Hi
>
> On Thursday 16 May 2002 08:46 Russell Miller wrote:
> > It is attached.
>
> Thanks for the patch. It solves the mail bombing problem but the KMail
> process does not exit if the user tries to close KMail.
>
> Regards
> Michael Häckel

-- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
--------------Boundary-00=_843AHXVNG8NU3LLCI1ZZ
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmail.patch2"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmail.patch2"

--- kmsender.cpp.origWed May 15 18:58:58 2002
+++ kmsender.cppFri May 17 18:01:38 2002
@@ -2106 +2107 @@
 {
   KMFolder *sentFolder = 0 *imapSentFolder = 0;
   bool someSent = mCurrentMsg;
+  int rc;
   if (someSent) mSentMessages++;
   int percent = (mTotalMessages) ? (100 * mSentMessages / mTotalMessages) : 0;
   if (percent > 100) percent = 100;
@@ -2408 +24114 @@
 
     if ( sentFolder == 0 )
       sentFolder = kernel->sentFolder();
-    else
-      sentFolder->open();
+    else {
+      rc = sentFolder->open();
+      if (rc != 0) {
+cleanup();
+        return;
+      }
+    }
+
 
     // 0==processed ok 1==no filter matched 2==critical error abort!
     int processResult = kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);

--------------Boundary-00=_843AHXVNG8NU3LLCI1ZZ--
Comment 7 Michael H 2002-05-18 07:51:12 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 18 May 2002 01:12 Russell Miller wrote:
> Attached is a patched patch.  Adding a cleanup() call before return; seems
> to fix that problem.

Seems to work well for mbox folders now thanks. However I just noticed that
for a maildir format sent-mail folder the problem persists.

Regards
Michael Häckel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE85gfwe9KEPyN2R8URAjGhAJ9y7i+zbWglhp+6hdW/8nvbFWxF9QCdEIYZ
MZT1OUI8xGHNQb8b01PpYEY=
=85Yd
-----END PGP SIGNATURE-----
Comment 8 Russell Miller 2002-05-18 08:38:06 UTC
I've just taken a closer look at the code - it appears that the open() method 
is very different in kmfoldermaildir.cpp from kmfolder.cpp.  Specifically 
there do not appear to be any permission checks at all.  This will probably 
lead to a cascade with similar results to not checking the error code upon 
return - open() will succeed with no return code because although it cannot 
write to the folder it can read and verify it.

The mbox open() method by contrast makes this check and returns a suitable 
error code if it fails.

I think the appropriate behavior here is to check the sent_mail directory for 
write access pop up a message box and return E_PERM if it fails similar to 
what the mbox open() method does.  Then the doSendMsg modifications that I 
sent the patch for will work on both formats.  Thoughts?

There appear to be quite a few places where the return code from open() is not 
tested.  Is this by design or is it something that needs to be fixed?

Of course I could be way out there as this is only my third day with this 
code...

--Russell

On Saturday 18 May 2002 02:51 am Michael Häckel wrote:
> On Saturday 18 May 2002 01:12 Russell Miller wrote:
> > Attached is a patched patch.  Adding a cleanup() call before return;
> > seems to fix that problem.
>
> Seems to work well for mbox folders now thanks. However I just noticed
> that for a maildir format sent-mail folder the problem persists.
>
> Regards
> Michael Häckel
Comment 9 Michael H 2002-05-18 16:35:42 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 18 May 2002 10:38 Russell Miller wrote:
>
> I think the appropriate behavior here is to check the sent_mail directory
> for write access pop up a message box and return E_PERM if it fails

That should probably be done.

> similar to what the mbox open() method does.  Then the doSendMsg
> modifications that I sent the patch for will work on both formats. 

Independant of that it still can happen that adding the message to the folder 
fails even if it is read/write because of for example lack of disk space. In 
this case however we currently exit KMail immediately.

> There appear to be quite a few places where the return code from open() is
> not tested.  Is this by design or is it something that needs to be fixed?

A message box appears and the folder content is simply not displayed. This 
should be enough in most other cases.

Additionally it would be probably best if the permissions of the folders would 
already be checked on startup when the folders are listed and KMail would 
simply refuse to start if they are not correct. Currently it can happen that 
the user is presented with a whole bunch of error messages one for every 
folder. The current checks are however still necessary because the 
permissions can change while KMail is running.

Regards
Michael Häckel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD4DBQE85oLhe9KEPyN2R8URAj5AAJ9E/NJ842giSjvTek9nQ/2Xv8rUvgCY0WtS
ubTvR6It6SdDGuAT9tbuHQ==
=t4Ub
-----END PGP SIGNATURE-----
Comment 10 Russell Miller 2002-05-19 02:52:41 UTC
OK how about this:  We create another method in each folder class - access().  
It's sole purpose is to test whether we can read and write the folder and 
returns true if you can false if you can't.  Then we can easily run an 
access test before open()ing each folder on startup without having to worry 
about the error message it might spit out.  Also I don't think we should 
have to attempt to open() the folder to find out if we can access it - that 
makes things pretty messy on startup.

Also this lets us abstract it in case we need to run different types of 
access checks on different platforms.

I'll volunteer to implement this if you think it's a good idea.

--Russell

On Saturday 18 May 2002 11:35 am Michael Häckel wrote:
> On Saturday 18 May 2002 10:38 Russell Miller wrote:
> > I think the appropriate behavior here is to check the sent_mail directory
> > for write access pop up a message box and return E_PERM if it fails
>
> That should probably be done.
>
> > similar to what the mbox open() method does.  Then the doSendMsg
> > modifications that I sent the patch for will work on both formats.
>
> Independant of that it still can happen that adding the message to the
> folder fails even if it is read/write because of for example lack of disk
> space. In this case however we currently exit KMail immediately.
>
> > There appear to be quite a few places where the return code from open()
> > is not tested.  Is this by design or is it something that needs to be
> > fixed?
>
> A message box appears and the folder content is simply not displayed. This
> should be enough in most other cases.
>
> Additionally it would be probably best if the permissions of the folders
> would already be checked on startup when the folders are listed and KMail
> would simply refuse to start if they are not correct. Currently it can
> happen that the user is presented with a whole bunch of error messages
> one for every folder. The current checks are however still necessary
> because the permissions can change while KMail is running.
>
> Regards
> Michael Häckel
Comment 11 Russell Miller 2002-05-22 21:19:44 UTC
--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

OK here are diff files to implement this patch.  I've tested it on mbox files 
not on maildir cuz I don't have a test setup for that yet.

It will exit hard if you can't read or write any of the five critical 
mailboxes on opening.  A new canAccess class is implemented that lets each 
different type check to make sure it's accessible.  Otherwise the checks to 
fix this bug on both mbox and maildir formatted mailboxes are also included.

If I missed any file or it doesn't compile (it compiles and works just fine as 
far as I've tested) let me know and I'll get you what you need.

- --Russell

On Saturday 18 May 2002 09:52 pm Russell Miller wrote:
> OK how about this:  We create another method in each folder class -
> access(). It's sole purpose is to test whether we can read and write the
> folder and returns true if you can false if you can't.  Then we can
> easily run an access test before open()ing each folder on startup without
> having to worry about the error message it might spit out.  Also I don't
> think we should have to attempt to open() the folder to find out if we can
> access it - that makes things pretty messy on startup.
>
> Also this lets us abstract it in case we need to run different types of
> access checks on different platforms.
>
> I'll volunteer to implement this if you think it's a good idea.
>
> --Russell
>
> On Saturday 18 May 2002 11:35 am Michael Häckel wrote:
> > On Saturday 18 May 2002 10:38 Russell Miller wrote:
> > > I think the appropriate behavior here is to check the sent_mail
> > > directory for write access pop up a message box and return E_PERM if
> > > it fails
> >
> > That should probably be done.
> >
> > > similar to what the mbox open() method does.  Then the doSendMsg
> > > modifications that I sent the patch for will work on both formats.
> >
> > Independant of that it still can happen that adding the message to the
> > folder fails even if it is read/write because of for example lack of disk
> > space. In this case however we currently exit KMail immediately.
> >
> > > There appear to be quite a few places where the return code from open()
> > > is not tested.  Is this by design or is it something that needs to be
> > > fixed?
> >
> > A message box appears and the folder content is simply not displayed.
> > This should be enough in most other cases.
> >
> > Additionally it would be probably best if the permissions of the folders
> > would already be checked on startup when the folders are listed and KMail
> > would simply refuse to start if they are not correct. Currently it can
> > happen that the user is presented with a whole bunch of error messages
> > one for every folder. The current checks are however still necessary
> > because the permissions can change while KMail is running.
> >
> > Regards
> > Michael Häckel

- -- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE87At0URTA4VCI9OARAmvAAJ9IjYz4GCkeIt2Dn7HJoVUTKhxjwQCfSsg3
L/t00Bfc6+7l7OihjyitZKc=
=3eg9
-----END PGP SIGNATURE-----

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmfolder.h.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmfolder.h.diff"

--- kmfolder.h.origWed May 22 16:13:17 2002
+++ kmfolder.hWed May 22 13:45:32 2002
@@ -1806 +18010 @@
     fopen call otherwise (errno). */
   virtual int open() = 0;
 
+  /** Check folder for permissions
+    Returns zero if readable and writable. */
+  virtual int canAccess() = 0;
+
   /** Close folder. If force is TRUE the files are closed even if
     others still use it (e.g. other mail reader windows). */
   virtual void close(bool force=FALSE) = 0;

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmfoldermbox.h.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmfoldermbox.h.diff"

--- kmfoldermbox.h.origWed May 22 00:11:48 2002
+++ kmfoldermbox.hWed May 22 13:45:45 2002
@@ -556 +558 @@
     others still use it (e.g. other mail reader windows). */
   virtual void close(bool force=FALSE);
 
+  virtual int canAccess();
+
   /** fsync buffers to disk */
   virtual void sync();
 

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmfoldermaildir.h.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmfoldermaildir.h.diff"

--- kmfoldermaildir.h.origWed May 22 00:14:17 2002
+++ kmfoldermaildir.hWed May 22 13:46:03 2002
@@ -456 +458 @@
     fopen call otherwise (errno). */
   virtual int open();
 
+  virtual int canAccess();
+
   /** fsync buffers to disk */
   virtual void sync();
 

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmkernel.cpp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmkernel.cpp.diff"

--- kmkernel.cpp.origWed May 22 14:59:07 2002
+++ kmkernel.cppWed May 22 15:29:08 2002
@@ -51225 +51248 @@
   if (name.isEmpty()) name = "inbox";
 
   the_inboxFolder  = (KMFolder*)the_folderMgr->findOrCreate(name);
+
+  if (the_inboxFolder->canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("You do not have read/write permission to your inbox folder.") );
+    exit(1);
+  }
+
   the_inboxFolder->setSystemFolder(TRUE);
   // inboxFolder->open();
 
   the_outboxFolder = the_folderMgr->findOrCreate(cfg->readEntry("outboxFolder" "outbox"));
+  if (the_outboxFolder->canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("You do not have read/write permission to your outbox folder.") );
+    exit(1);
+  }
+
   the_outboxFolder->setType("Out");
   the_outboxFolder->setSystemFolder(TRUE);
   the_outboxFolder->open();
 
   the_sentFolder = the_folderMgr->findOrCreate(cfg->readEntry("sentFolder" "sent-mail"));
+  if (the_sentFolder->canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("You do not have read/write permission to your sent-mail folder.") );
+    exit(1);
+  }
   the_sentFolder->setType("St");
   the_sentFolder->setSystemFolder(TRUE);
   the_sentFolder->open();
 
   the_trashFolder  = the_folderMgr->findOrCreate(cfg->readEntry("trashFolder" "trash"));
+  if (the_trashFolder->canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("You do not have read/write permission to your trash folder.") );
+    exit(1);
+  }
   the_trashFolder->setType("Tr");
   the_trashFolder->setSystemFolder(TRUE);
   the_trashFolder->open();
 
   the_draftsFolder = the_folderMgr->findOrCreate(cfg->readEntry("draftsFolder" "drafts"));
+  if (the_draftsFolder->canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("You do not have read/write permission to your drafts folder.") );
+    exit(1);
+  }
   the_draftsFolder->setType("Df");
   the_draftsFolder->setSystemFolder(TRUE);
   the_draftsFolder->open();

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmfoldermaildir.cpp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmfoldermaildir.cpp.diff"

--- kmfoldermaildir.cpp.origTue May 21 23:38:15 2002
+++ kmfoldermaildir.cppWed May 22 15:44:19 2002
@@ -546 +5427 @@
 }
 
 //-----------------------------------------------------------------------------
+int KMFolderMaildir::canAccess()
+{
+  
+  assert(name() != "");
+
+  if (access(QFile::encodeName(location()) R_OK | W_OK) != 0)
+    return 1;
+
+  if (access(QFile::encodeName(location() + "/new") R_OK | W_OK) != 0)
+    return 1;
+
+  if (access(QFile::encodeName(location() + "/cur") R_OK | W_OK) != 0)
+    return 1;
+  
+  if (access(QFile::encodeName(location() + "/tmp") R_OK | W_OK) != 0)
+    return 1;
+
+  return 0;
+}
+  
+//-----------------------------------------------------------------------------
 int KMFolderMaildir::open()
 {
   int rc = 0;
@@ -636 +8412 @@
 
   assert(name() != "");
 
+  if (canAccess() != 0) {
+    KMessageBox::sorry(0 i18n("Error opening %1 (or a component thereof):"
+"Permission denied").arg(name()) );
+    return EPERM;
+  }
+
   if (!path().isEmpty())
   {
     if (isIndexOutdated()) // test if contents file has changed

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmfoldermbox.cpp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmfoldermbox.cpp.diff"

--- kmfoldermbox.cpp.origTue May 21 23:28:34 2002
+++ kmfoldermbox.cppWed May 22 15:57:59 2002
@@ -1226 +12219 @@
   return rc;
 }
 
+//----------------------------------------------------------------------------
+int KMFolderMbox::canAccess()
+{
+  int rc;
+
+  assert(name() != "");
+
+  if (access(location().local8Bit() R_OK | W_OK) != 0) {
+    kdDebug(5006) << "KMFolderMbox::access call to access function failed" << endl;
+      return 1;
+  }
+  return 0;
+} 
 
 //-----------------------------------------------------------------------------
 int KMFolderMbox::create(bool imap)

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kmsender.cpp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kmsender.cpp.diff"

--- kmsender.cpp.origWed May 15 18:58:58 2002
+++ kmsender.cppFri May 17 18:01:38 2002
@@ -2106 +2107 @@
 {
   KMFolder *sentFolder = 0 *imapSentFolder = 0;
   bool someSent = mCurrentMsg;
+  int rc;
   if (someSent) mSentMessages++;
   int percent = (mTotalMessages) ? (100 * mSentMessages / mTotalMessages) : 0;
   if (percent > 100) percent = 100;
@@ -2408 +24114 @@
 
     if ( sentFolder == 0 )
       sentFolder = kernel->sentFolder();
-    else
-      sentFolder->open();
+    else {
+      rc = sentFolder->open();
+      if (rc != 0) {
+cleanup();
+        return;
+      }
+    }
+
 
     // 0==processed ok 1==no filter matched 2==critical error abort!
     int processResult = kernel->filterMgr()->process(mCurrentMsgKMFilterMgr::Outbound);

--------------Boundary-00=_W87JALLY4JB2LKZX0LHO--
Comment 12 Russell Miller 2002-05-22 22:46:15 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I should probably add - it could be that open() in kmfoldermaildir could 
require a cleanup() call similar to that in kmfoldermbox::open().  If the 
process doesn't die after exiting kmail that's why.

- --Russell

On Wednesday 22 May 2002 04:19 pm Russell Miller wrote:
> OK here are diff files to implement this patch.  I've tested it on mbox
> files not on maildir cuz I don't have a test setup for that yet.
>
> It will exit hard if you can't read or write any of the five critical
> mailboxes on opening.  A new canAccess class is implemented that lets each
> different type check to make sure it's accessible.  Otherwise the checks
> to fix this bug on both mbox and maildir formatted mailboxes are also
> included.
>
> If I missed any file or it doesn't compile (it compiles and works just fine
> as far as I've tested) let me know and I'll get you what you need.
>
> --Russell
- -- 
Russell Miller
rmiller@duskglow.com
Somewhere in Northwestern Iowa
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE87B+7URTA4VCI9OARAgliAJ9o0IafxTtXJppURJ82KqeT+NGuowCfdysV
x7AX6EhAj34JLTmESrz0GNY=
=hBCd
-----END PGP SIGNATURE-----
Comment 13 Michael H 2002-05-25 10:24:14 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

<quote>
I should probably add - it could be that open() in kmfoldermaildir could 
require a cleanup() call similar to that in kmfoldermbox::open().  If the 
process doesn't die after exiting kmail that's why.

- - --Russell

On Wednesday 22 May 2002 04:19 pm Russell Miller wrote:
> OK here are diff files to implement this patch.  I've tested it on mbox
> files not on maildir cuz I don't have a test setup for that yet.
>
> It will exit hard if you can't read or write any of the five critical
> mailboxes on opening.  A new canAccess class is implemented that lets each
> different type check to make sure it's accessible.  Otherwise the checks
> to fix this bug on both mbox and maildir formatted mailboxes are also
> included.
>
> If I missed any file or it doesn't compile (it compiles and works just fine
> as far as I've tested) let me know and I'll get you what you need.
</quote>

For maildir folders also the permission to change into the directories is 
required.
Also in the case the permission is lost while KMail is running the mail is 
still sent continuesly with your patch.

I fixed these issues and committed your patch.

BTW: You can simply cat patches to different files together into a single 
file or just use "cvs diff" if you are using anoncvs.

Regards
Michael Häckel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE872ZSe9KEPyN2R8URAvr/AJ96sZHdRm2WyWfzafdaKX43H3Sg8wCfQ2vY
crDYYMWtuwzGEWJ6geX6FUg=
=ALTg
-----END PGP SIGNATURE-----