[tpop3d-discuss]Quota exceeded + dotfile locking

Jarek Koszuk heretyk at pld-linux.org
Wed, 24 Nov 2004 22:36:49 +0100


--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi!

I've just encountered the following problem: when user has quota exceeded
(or filesystem, where his mbox mailbox resides is full) it is impossible
for him to get or delete his emails. I know, that the solution for this
problem is to use tpop3d compiled with dotfile-locking disabled. But
in some cases, recompilation is not an option :(

I thought, it would be useful to have an option to turn off using
dotfile-locking.

The attached patch addresses this problem. It introduces configuration
option "mailspool-no-dotfile-locking" that allows disabling dotfile-locking
without the need for recompilation.

Jarek

--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="tpop3d-disable-dotfile-locking.patch"

diff -Naur tpop3d-1.5.3.orig/cfgdirectives.c tpop3d-1.5.3/cfgdirectives.c
--- tpop3d-1.5.3.orig/cfgdirectives.c	2004-11-23 20:56:44.000000000 +0100
+++ tpop3d-1.5.3/cfgdirectives.c	2004-11-24 18:46:58.635749600 +0100
@@ -39,6 +39,10 @@
 #if defined(MBOX_BSD) && defined(MBOX_BSD_SAVE_INDICES)
     "mailspool-index",
 #endif
+
+#if MBOX_BSD
+    "mailspool-no-dotfile-locking",
+#endif
     
 #ifdef USE_TCP_WRAPPERS
     "tcp-wrappers-name",
diff -Naur tpop3d-1.5.3.orig/mailspool.c tpop3d-1.5.3/mailspool.c
--- tpop3d-1.5.3.orig/mailspool.c	2003-11-06 02:19:27.000000000 +0100
+++ tpop3d-1.5.3/mailspool.c	2004-11-24 18:46:58.636749448 +0100
@@ -60,6 +60,10 @@
 int mailspool_load_index(mailbox m);
 #endif /* MBOX_BSD_SAVE_INDICES */
 
+/* Don't try to lock mailbox using dotfile-locking, even though compiled with
+ * support for it */
+int no_dotfile_locking;
+
 /* file_unlock FD FILENAME
  * Unlock a mailspool file using the open FD and given FILENAME. Returns 1 on
  * success or 0 on failure. */
@@ -74,7 +78,9 @@
 #endif
 
 #ifdef WITH_DOTFILE_LOCKING
-    if (name && dotfile_unlock(name) == -1) r = 0;
+    if (!no_dotfile_locking) {
+        if (name && dotfile_unlock(name) == -1) r = 0;
+    }
 #endif
 
     return r;
@@ -97,8 +103,10 @@
     else l_flock = 1;
 #endif
 #ifdef WITH_DOTFILE_LOCKING
-    if (dotfile_lock(name) == -1) goto fail;
-    else l_dotfile = 1;
+    if (!no_dotfile_locking) {
+	if (dotfile_lock(name) == -1) goto fail;
+	else l_dotfile = 1;
+    }
 #endif
 #ifdef WITH_CCLIENT_LOCKING
     if (cclient_steal_lock(fd) == -1) goto fail;
@@ -114,7 +122,9 @@
     if (l_flock) flock_unlock(fd);
 #endif
 #ifdef WITH_DOTFILE_LOCKING
-    if (l_dotfile) dotfile_unlock(name);
+    if (!no_dotfile_locking) {
+        if (l_dotfile) dotfile_unlock(name);
+    }
 #endif
     
     return 0;
diff -Naur tpop3d-1.5.3.orig/main.c tpop3d-1.5.3/main.c
--- tpop3d-1.5.3.orig/main.c	2003-11-24 20:58:28.000000000 +0100
+++ tpop3d-1.5.3/main.c	2004-11-24 18:48:32.837428768 +0100
@@ -340,6 +340,10 @@
 extern int mailspool_save_indices;  /* in mailspool.c */
 #endif
 
+#if MBOX_BSD
+extern int no_dotfile_locking;      /* in mailspool.c */
+#endif
+
 int main(int argc, char **argv, char **envp) {
     int nodaemon = 0;
     char *configfile = CONFIG_DIR"/tpop3d.conf", *s;
@@ -426,6 +430,12 @@
         log_print(LOG_INFO, _("experimental BSD mailbox metadata cache enabled"));
     }
 #endif
+    
+    /* Should we skip dotfile-locking? */
+#if MBOX_BSD
+    if (config_get_bool("mailspool-no-dotfile-locking"))
+	no_dotfile_locking = 1;
+#endif
 
     /* We may have been compiled with TCP wrappers support. */
 #ifdef USE_TCP_WRAPPERS
diff -Naur tpop3d-1.5.3.orig/tpop3d.conf.5 tpop3d-1.5.3/tpop3d.conf.5
--- tpop3d-1.5.3.orig/tpop3d.conf.5	2004-11-23 20:56:44.000000000 +0100
+++ tpop3d-1.5.3/tpop3d.conf.5	2004-11-24 18:46:58.637749296 +0100
@@ -240,6 +240,13 @@
 that the mailspool index files be stored in a directory to which users would
 not customarily have access, for instance /var/spool/tpop3d.
 .TP
+\fBmailspool-no-dotfile-locking\fP: (\fByes\fP|\fBtrue\fP)
+This option tells \fBtpop3d\fP that it should not attempt to use
+dotfile-locking, even though it was compiled with support for this.
+
+It solves the problem, when users are not able to get or delete their emails,
+because filesystem with mailspool is full (or they have exceeded disk quota).
+.TP
 \fBmaildir-exclusive-lock\fP: (\fByes\fP|\fBtrue\fP)
 Indicates that \fBtpop3d\fP should attempt to lock maildir mailboxes for
 exclusive access, so that it more closely follows the behaviour described in

--/9DWx/yDrRhgMJTb--