

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in net.sourceforge.lists.courier-maildropRe: [maildropl] Maildrop quota patch| From | Sent On | Attachments |
|---|---|---|
| Divyank Turakhia | Dec 26, 2002 12:07 am | |
| Aleksey Perov | Dec 27, 2002 12:04 am | .patch, .patch, .patch |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [maildropl] Maildrop quota patch | Actions... |
|---|---|---|
| From: | Aleksey Perov (alga...@sura.ru) | |
| Date: | Dec 27, 2002 12:04:40 am | |
| List: | net.sourceforge.lists.courier-maildrop | |
| Attachments: | ||
Divyank Turakhia wrote:
Hi,
I am using qmail + maildrop. I want to implement system level quotas.
I believe maildrop would treat a quota exceeded error as a temporary error and leave the mail in the queue and keep ret-trying to write the file to disk, just like the original qmail-local binary. There is a patch ( http://www.qmail.org/qmail-1.03-quotas-1.1.patch ) that makes qmail-local treat quota exceeded errors as a permanent error so that the mail is bounced back to the sender.
Is there a similar patch for maildrop that would: (1) treat quota exceeded errors as permanent errors thus bouncing the email (2) allow the bounce message to be customized
Divyank
Well, I've recently created such patches for myself, see attachments.
The file maildrop-nouser.patch makes several things. Firstly, it changes the behavior of maildrop so that it always exits with permanent failure in case of unsuccessful delivery to the default mailbox. Secondly, it forces maildrop to exit with permanent code in case of nonexistent recipient user (e.g., if there's no user "john_doe" on my system, it is unlikely that it will appear in the near future, isn't it? ;-) Finally, it makes the errexit variable from main.C nonstatic and visible in maildrop.C, so that maildrop returns errexit in case of any exceptions with char* parameter. (Anyway, this variable is never used, it is only assigned an EX_TEMPFAIL value - what is this for? Am I missing something?)
The file maildrop-quota.patch makes maildrop produce more informative output, that is, it says "mailbox quota exceeded" or "error writing to mailbox: blah".
The file maildrop-mio.patch changes the behavior of Mio::write() function so that in case of unsuccessful write it returns (-1) instead of the number of successfully written bytes. This is needed to make it indicate the failure immediately, because under some circumstances the errno variable gets lost somehow, and previously mentioned patch does not work properly. Mr. Sam, if you are reading this, I'd be thankful for your comments on this.
Maildrop with these patches works in testing mode on my system for several days. Please let me know if you have any issues regarding them.
-- Aleksey Perov Postmaster JSC Volgatelecom, Penza Region, Russia phone: +7 8412 520215
--- maildrop/mio.C.orig Mon Aug 2 09:02:26 1999 +++ maildrop/mio.C Wed Dec 25 10:51:36 2002 @@ -173,10 +173,7 @@ int l;
if (writecnt == 0 && flush() < 0) - { - if (done == 0) done= -1; - break; - } + return -1;
if (writeptr > buf || cnt <= writecnt) { @@ -191,10 +188,7 @@ { l=mwrite(fd_, cp, cnt); if (l <= 0) - { - if (done == 0) done= -1; - break; - } + return -1; }
cp += l;
--- maildrop/main.C.orig Wed Dec 25 11:26:06 2002 +++ maildrop/main.C Wed Dec 25 16:19:02 2002 @@ -55,7 +55,7 @@
static Message m1, m2; extern char **environ; -static int errexit=EX_TEMPFAIL; +int errexit=EX_TEMPFAIL; static const char *defaults_vars[]={"LOCKEXT","LOCKSLEEP","LOCKTIMEOUT", "LOCKREFRESH", "PATH", "SENDMAIL", "MAILDIRQUOTA"}; @@ -90,7 +90,7 @@
static void nouser() { - errexit=EX_TEMPFAIL; + errexit=EX_CANTCREAT; throw "Invalid user specified."; }
@@ -1015,7 +1015,7 @@ value=v; value += '\0'; if (delivery((const char *)value) < 0) - return (EX_TEMPFAIL); + return (EX_CANTCREAT); }
value="EXITCODE"; --- maildrop/maildrop.C.orig Sun Dec 31 09:04:00 2000 +++ maildrop/maildrop.C Fri Dec 27 10:08:48 2002 @@ -14,6 +14,7 @@
extern void killprocgroup();
+extern int errexit;
static const char rcsid[]="$Id: maildrop.C,v 1.6 2000/12/16 20:55:35 mrsam Exp
$";
int Maildrop::sigfpe; @@ -76,22 +77,22 @@ } catch (const char *p) { - merr << argv[0] << ": " << p << "\n"; + merr << "maildrop: " << p << "\n"; #if SYSLOG_LOGGING syslog(LOG_INFO, p); #endif cleanup(); - return (EX_TEMPFAIL); + return (errexit); } #if NEED_NONCONST_EXCEPTIONS catch (char *p) { - merr << argv[0] << ": " << p << "\n"; + merr << "maildrop: " << p << "\n"; #if SYSLOG_LOGGING syslog(LOG_INFO, p); #endif cleanup(); - return (EX_TEMPFAIL); + return (errexit); } #endif catch (int n) @@ -101,7 +102,7 @@ } catch (...) { - merr << argv[0] << ": Internal error.\n"; + merr << "maildrop: Internal error.\n"; #if SYSLOG_LOGGING syslog(LOG_INFO, "Internal error."); #endif
--- maildrop/formatmbox.C.orig Mon Apr 8 19:11:02 2002 +++ maildrop/formatmbox.C Wed Dec 25 09:33:12 2002 @@ -134,13 +134,18 @@ int FormatMbox::DeliverTo(class Mio &mio) { Buffer *bufptr; +int saved_errno=0;
while ((bufptr=NextLine()) != NULL)
{
if (mio.write((const char *)*bufptr, bufptr->Length()) < 0)
{
write_error:
- merr << "maildrop: error writing to mailbox.\n";
+ saved_errno = errno;
+ if(saved_errno == EDQUOT)
+ merr << "maildrop: mailbox quota exceeded\n";
+ else
+ merr << "maildrop: error writing to mailbox: " << strerror(saved_errno) <<
"\n";
mio.Close();
return (-1);
}








.patch, .patch, .patch