This is a discussion on [courier-users] Quota warning code within the Courier-Imap forums, part of the Mail Servers and Related category; While troubleshooting a local problem, I had the opportunity to examine the quota warning code in courier/maildir/. I noticed ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
While troubleshooting a local problem, I had the opportunity to examine the
quota warning code in courier/maildir/. I noticed that if the stat() on Maildir/quotawarn fails, the quota warning is still delivered. Since everything else seems to fail fast, I've modified the check to behave similarly if the stat() fails and errno != ENOENT. Also, the check on open() wasn't catching failure, since open(2) returns -1 on failure, and !(-1) is false. john Index: maildirquota.c ================================================== ================= RCS file: /cvsroot/courier/libs/maildir/maildirquota.c,v retrieving revision 1.26 diff -u -r1.26 maildirquota.c --- maildirquota.c 12 Feb 2005 22:15:50 -0000 1.26 +++ maildirquota.c 2 Dec 2005 19:17:51 -0000 @@ -978,7 +978,7 @@ static void do_deliver_warning(const char *msgfile, const char *dir) { -int fdin, fd; +int fdin, fd, ret; FILE *fpout; time_t t; size_t l, msg_len; @@ -1004,7 +1004,9 @@ strcat(strcpy(qname, dir), "/quotawarn"); time(&t); - if (stat(qname, &sb) == 0 && ((sb.st_mtime + 86400) > t)) + ret = stat(qname, &sb); + if ((ret == -1 && errno != ENOENT) || + (ret == 0 && (sb.st_mtime + 86400) > t)) { free(qname); close(fdin); @@ -1013,7 +1015,7 @@ fd = open(qname, O_WRONLY|O_CREAT|O_TRUNC, 0644); free(qname); - if (!fd) + if (fd == -1) { close(fdin); return; john -- John Morrissey _o /\ ---- __o jwm@horde.net _-< \_ / \ ---- < \, www.horde.net/ __(_)/_(_)________/ \_______(_) /_(_)__ ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ courier-users mailing list courier-users@lists.sourceforge.net Unsubscribe: https://lists.sourceforge.net/lists/.../courier-users |