[dovecot-cvs] dovecot/src/master mail-process.c, 1.89, 1.90 master-settings.c, 1.122, 1.123 master-settings.h, 1.81, 1.82

cras at dovecot.org cras at dovecot.org
Fri Apr 14 13:52:58 EEST 2006


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv1344

Modified Files:
	mail-process.c master-settings.c master-settings.h 
Log Message:
Unless nfs_check=no or mmap_disable=yes, check for the first login if the
user's index directory exists in NFS mount. If so, refuse to run. This is
done only on first login to avoid constant extra overhead.



Index: mail-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/mail-process.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- mail-process.c	13 Apr 2006 00:56:22 -0000	1.89
+++ mail-process.c	14 Apr 2006 10:52:55 -0000	1.90
@@ -6,6 +6,7 @@
 #include "env-util.h"
 #include "str.h"
 #include "network.h"
+#include "mountpoint.h"
 #include "restrict-access.h"
 #include "restrict-process-size.h"
 #include "var-expand.h"
@@ -334,6 +335,43 @@
 		       set->mail_executable);
 }
 
+static void nfs_warn_if_found(const char *mail, const char *home)
+{
+	struct mountpoint point;
+	const char *path;
+
+	if (mail == NULL)
+		path = home;
+	else {
+		path = strstr(mail, ":INDEX=");
+		if (path != NULL) {
+			/* indexes set separately */
+			path += 7;
+			if (strncmp(path, "MEMORY", 6) == 0)
+				return;
+		} else {
+			path = strchr(mail, ':');
+			if (path == NULL) {
+				/* autodetection for path */
+			} else {
+				/* format:path */
+				path++;
+			}
+		}
+		path = t_strcut(path, ':');
+	}
+
+	if (mountpoint_get(path, pool_datastack_create(), &point) <= 0)
+		return;
+
+	if (point.type == NULL || strcasecmp(point.type, "NFS") != 0)
+		return;
+
+	i_fatal("Mailbox indexes in %s are in NFS mount. "
+		"You must set mmap_disable=yes to avoid index corruptions. "
+		"If you're sure this check was wrong, set nfs_check=no.", path);
+}
+
 bool create_mail_process(struct login_group *group, int socket,
 			 const struct ip_addr *local_ip,
 			 const struct ip_addr *remote_ip,
@@ -530,6 +568,12 @@
 		}
 	}
 
+	if (set->nfs_check && !set->mmap_disable) {
+		/* do this only once */
+		nfs_warn_if_found(getenv("MAIL"), home_dir);
+		set->nfs_check = FALSE;
+	}
+
 	env_put("LOGGED_IN=1");
 	env_put(t_strconcat("HOME=", home_dir, NULL));
 	env_put(t_strconcat("USER=", user, NULL));

Index: master-settings.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/master-settings.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- master-settings.c	12 Apr 2006 14:37:05 -0000	1.122
+++ master-settings.c	14 Apr 2006 10:52:55 -0000	1.123
@@ -72,6 +72,7 @@
 	DEF(SET_BOOL, disable_plaintext_auth),
 	DEF(SET_BOOL, verbose_ssl),
 	DEF(SET_BOOL, shutdown_clients),
+	DEF(SET_BOOL, nfs_check),
 
 	/* login */
 	DEF(SET_STR, login_dir),
@@ -277,6 +278,7 @@
 	MEMBER(disable_plaintext_auth) TRUE,
 	MEMBER(verbose_ssl) FALSE,
 	MEMBER(shutdown_clients) TRUE,
+	MEMBER(nfs_check) TRUE,
 
 	/* login */
 	MEMBER(login_dir) "login",

Index: master-settings.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/master-settings.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- master-settings.h	12 Apr 2006 14:37:05 -0000	1.81
+++ master-settings.h	14 Apr 2006 10:52:55 -0000	1.82
@@ -37,6 +37,7 @@
 	bool disable_plaintext_auth;
 	bool verbose_ssl;
 	bool shutdown_clients;
+	bool nfs_check;
 
 	/* login */
 	const char *login_dir;



More information about the dovecot-cvs mailing list