I recently did a cutover from qmail-pop3d to courier's pop3d.  During
this cutover, I noticed an issue where some MUAs would throw an error
retrieving their mail.  I tracked this down to there being a broken
symlink in the affected user's cur directory.  Removing the broken
symlink fixed the issue.  Admittedly, the symlink was there because of
the questionable practices of former co-workers at my previous place of
employment.

That being said, I think it would be prudent to simply stat() the files
in the scancur() function and ignore those that error on the stat().
This small patch does exactly that for the pop3dserver.c:

------------------------
--- imap/pop3dserver.c  2010-07-13 18:12:53.000000000 -0500
+++ imap/pop3dserver.c  2011-03-16 14:24:12.037088246 -0500
@@ -337,6 +337,7 @@
 DIR    *dirp;
 struct dirent *de;
 struct msglist *m;
+struct stat st;

        if ((dirp=opendir("cur")) == 0)
        {
@@ -360,6 +361,12 @@
                        exit(1);
                }
                strcat(strcpy(m->filename, "cur/"), de->d_name);
+               if (stat(m->filename , &st) == -1) {
+                       // File does actually exist (most likely a broken 
symlink),
+                       // ignore it
+                       free( (char *)m);
+                       continue;
+               }
                m->isdeleted=0;
                m->next=msglist_l;
                msglist_l=m;
------------------------

I haven't looked at the IMAP side of things since we only use pop3, but
I'm guessing the same problem exists there.

-- 
Jay Deiman
\033:wq!

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Courier-imap mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap

Reply via email to