Hi all,

I noticed yesterday that qmail-ldap does not count trashed mail as part
of the quota. This correctly meets the maildir++ design, however it is
my opinion that the maildir++ specification is flawed in this regard,
as it allows users to be able to keep more mail than their quota allows
by trashing mail without expunging it. Given the number of users that
will be on the system I'm building, for them to be able to run over
quota in such a fashion would cause a huge problem.

I've attached a very simple patch to qmail-ldap 20020701 which provides a 
compile time option to include trashed mail in the quotas. It is disabled by 
default, and is enabled by uncommenting the "QUOTAFLAGS=-DTRASHQUOTA" in
the Makefile.

I have also placed this patch on the web at:

http://leapster.org/qmail/

Cheers,

Paul

-- 
Paul Dwerryhouse

"Why not just have the arresting officer execute you on the spot? If you turn 
 out to be innocent, they can cancel the invoice for the bullet." -- sharkey
diff -uN qmail-1.03/Makefile qmail-1.03-trashquota/Makefile
--- qmail-1.03/Makefile Thu Jul 18 11:55:35 2002
+++ qmail-1.03-trashquota/Makefile      Thu Jul 18 11:54:25 2002
@@ -64,6 +64,11 @@
 #INCTAI=../libtai-0.60
 #LIBTAI=../libtai-0.60
 
+# Uncomment this if you want trashed mail to be taken into account when
+# the quota is calculated.
+
+#QUOTAFLAGS=-DTRASHQUOTA
+
 # Just for me, make from time to time a backup
 BACKUPPATH=/backup/qmail-backup/qmail-ldap.`date "+%Y%m%d-%H%M"`.tar
 # STOP editing HERE !!!
@@ -1013,7 +1018,7 @@
 compile maildir++.c maildir++.h readwrite.h stralloc.h error.h str.h \
 open.h substdio.h getln.h error.h strerr.h fmt.h scan.h now.h seek.h \
 sig.h direntry.h
-       ./compile maildir++.c
+       ./compile maildir++.c $(QUOTAFLAGS)
 
 maildir2mbox: \
 load maildir2mbox.o maildir.o prioq.o now.o myctime.o gfrom.o lock.a \
diff -uN qmail-1.03/maildir++.c qmail-1.03-trashquota/maildir++.c
--- qmail-1.03/maildir++.c      Thu Jul 18 11:55:35 2002
+++ qmail-1.03-trashquota/maildir++.c   Thu Jul 18 12:29:41 2002
@@ -342,7 +342,11 @@
        dirp = opendir(path.s);
        while ( dirp && (dp = readdir(dirp)) != 0) {
                if ( dp->d_name[0] == '.' && dp->d_name[1] != '\0' && 
-                               dp->d_name[1] != '.' && str_diff( ".Trash", 
dp->d_name) ) {
+                               dp->d_name[1] != '.' 
+#ifndef TRASHQUOTA
+                               && str_diff( ".Trash", dp->d_name) 
+#endif
+                               ) {
                        path.len = slen;
                        if ( ! stralloc_cats(&path, dp->d_name) ) temp_nomem();
        
@@ -465,7 +469,11 @@
        
        while ( dirp && (dp = readdir(dirp)) != 0) {
                if ( dp->d_name[0] == '.' && dp->d_name[1] != '\0' && 
-                          dp->d_name[1] != '.' && str_diff( ".Trash", dp->d_name) ) {
+                          dp->d_name[1] != '.' 
+#ifndef TRASHQUOTA
+                          && str_diff( ".Trash", dp->d_name) 
+#endif
+                          ) {
                        path.len = slen;
                        if ( ! stralloc_cats(&path, dp->d_name) ) temp_nomem();
                        if ( ! stralloc_cats(&path, "/cur") ) temp_nomem();
@@ -564,11 +572,18 @@
                                f++;
                        } else {
                                f += 3;
+#ifndef TRASHQUOTA
                                while( *f >= 'A' && *f <= 'Z' && *f != 'T' ) f++;
+#else
+                               while( *f >= 'A' && *f <= 'Z' ) f++;
+#endif
                                break;
                        }
                }
+#ifndef TRASHQUOTA
                if ( *f == 'T' ) continue;
+#endif
+
                /* get the file size */
                if( get_file_size(dp->d_name, &filest) == 0 ) {
                        q->count++;
@@ -593,11 +608,17 @@
                                f++;
                        } else {
                                f += 3;
+#ifndef TRASHQUOTA
                                while( *f >= 'A' && *f <= 'Z' && *f != 'T' ) f++;
+#else
+                               while( *f >= 'A' && *f <= 'Z' ) f++;
+#endif
                                break;
                        }
                }
+#ifndef TRASHQUOTA
                if ( *f == 'T' ) continue;
+#endif
 
                if( get_file_size(dp->d_name, &filest) == 0 ) {
                        q->count++;

Reply via email to