bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] IMAP read-only still expunges on close


From: Sergey Poznyakoff
Subject: Re: [bug-mailutils] IMAP read-only still expunges on close
Date: Wed, 22 Jun 2005 19:40:33 +0300

Dan Born <address@hidden> wrote:

> I have attached a C program which demonstrates the problem.  It opens
> the mailbox in read-only mode, scans the mailbox looking at message
> attributes, and then closes the mailbox.  The close triggers an expunge.

I see now, thank you. Please, apply the attached patch, it should fix
the bug. Please inform me if it works for you.

Regards,
Sergey

Index: mailbox/imap/mbox.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/mailbox/imap/mbox.c,v
retrieving revision 1.75
diff -p -u -r1.75 mbox.c
--- mailbox/imap/mbox.c 17 May 2005 13:13:37 -0000      1.75
+++ mailbox/imap/mbox.c 22 Jun 2005 16:36:28 -0000
@@ -119,6 +119,8 @@ static int  flags_to_string       __P ((
 static int  delete_to_string      __P ((m_imap_t, char **));
 static int  is_same_folder        __P ((mailbox_t, message_t));
 
+#define MBX_WRITABLE(mbx) ((mbx)->flags & 
(MU_STREAM_WRITE|MU_STREAM_RDWR|MU_STREAM_CREAT))
+
 /* Initialize the concrete object mailbox_t by overloading the function of the
    structure.  */
 int
@@ -672,8 +674,10 @@ imap_messages_count (mailbox_t mailbox, 
   switch (f_imap->state)
     {
     case IMAP_NO_STATE:
-      status = imap_writeline (f_imap, "g%d SELECT %s\r\n",
-                              f_imap->seq++, m_imap->name);
+      status = imap_writeline (f_imap, "g%d %s %s\r\n",
+                              f_imap->seq++, 
+                               MBX_WRITABLE(mailbox) ? "SELECT" : "EXAMINE",
+                               m_imap->name);
       CHECK_ERROR (f_imap, status);
       MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
       f_imap->state = IMAP_SELECT;
@@ -845,6 +849,9 @@ imap_expunge (mailbox_t mailbox)
   m_imap_t m_imap = mailbox->data;
   f_imap_t f_imap = m_imap->f_imap;
 
+  if (!MBX_WRITABLE(mailbox))
+    return EACCES;
+       
   /* Select first.  */
   status = imap_messages_count (mailbox, NULL);
   if (status != 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]