dovecot-2.2: Removed mountpoint checking and updating code.

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 20 11:28:11 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/ef1a64509d68
changeset: 18376:ef1a64509d68
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 20 13:27:00 2015 +0200
description:
Removed mountpoint checking and updating code.
After a few years it seems like it has just caused more problems than it has
actually fixed. The only thing it's been used for is to make sure that
Dovecot can't create empty user directories when the user's mail filesystem
isn't mounted. But that's supposed to be normally prevented already if the
mount root directory permissions are only writable by root.

For now the mountpoint listing code and doveadm mount code still exists just
in case people have some scripts using those. Those could be removed in v2.3.

If we somehow figured out which mountpoints existed (not so easy because
they could be only visible in userdb lookups for different users), we could
maybe create some kind of a script that checks the permissions at startup.
This would work with Linux at least:

mkdir test
mount / -o bind test
ls -ld test/var/mail # assuming /var/mail mountpoint
umount test

diffstat:

 src/lib-storage/mail-user.c    |  35 -----------------------------------
 src/lib-storage/mail-user.h    |   7 -------
 src/lib-storage/mailbox-list.c |   8 ++------
 src/master/main.c              |  36 ------------------------------------
 4 files changed, 2 insertions(+), 84 deletions(-)

diffs (171 lines):

diff -r cf74e2179dce -r ef1a64509d68 src/lib-storage/mail-user.c
--- a/src/lib-storage/mail-user.c	Thu Mar 19 10:01:18 2015 +0200
+++ b/src/lib-storage/mail-user.c	Fri Mar 20 13:27:00 2015 +0200
@@ -15,7 +15,6 @@
 #include "fs-api.h"
 #include "auth-master.h"
 #include "master-service.h"
-#include "mountpoint-list.h"
 #include "dict.h"
 #include "mail-storage-settings.h"
 #include "mail-storage-private.h"
@@ -36,8 +35,6 @@
 		dict_deinit(&user->_attr_dict);
 	}
 	mail_namespaces_deinit(&user->namespaces);
-	if (user->mountpoints != NULL)
-		mountpoint_list_deinit(&user->mountpoints);
 }
 
 static void mail_user_stats_fill_base(struct mail_user *user ATTR_UNUSED,
@@ -440,38 +437,6 @@
 			   str_tabescape(user->username), NULL);
 }
 
-bool mail_user_is_path_mounted(struct mail_user *user, const char *path,
-			       const char **error_r)
-{
-	struct mountpoint_list_rec *rec;
-	const char *mounts_path;
-
-	*error_r = NULL;
-
-	if (user->mountpoints == NULL) {
-		mounts_path = t_strdup_printf("%s/"MOUNTPOINT_LIST_FNAME,
-					      user->set->base_dir);
-		user->mountpoints = mountpoint_list_init_readonly(mounts_path);
-	} else {
-		(void)mountpoint_list_refresh(user->mountpoints);
-	}
-	rec = mountpoint_list_find(user->mountpoints, path);
-	if (rec == NULL || strcmp(rec->state, MOUNTPOINT_STATE_IGNORE) == 0) {
-		/* we don't have any knowledge of this path's mountpoint.
-		   assume it's fine. */
-		return TRUE;
-	}
-	/* record exists for this mountpoint. see if it's mounted */
-	if (mountpoint_list_update_mounted(user->mountpoints) == 0 &&
-	    !rec->mounted) {
-		*error_r = t_strdup_printf("Mountpoint %s isn't mounted. "
-			"Mount it or remove it with doveadm mount remove",
-			rec->mount_path);
-		return FALSE;
-	}
-	return TRUE;
-}
-
 static void
 mail_user_try_load_class_plugin(struct mail_user *user, const char *name)
 {
diff -r cf74e2179dce -r ef1a64509d68 src/lib-storage/mail-user.h
--- a/src/lib-storage/mail-user.h	Thu Mar 19 10:01:18 2015 +0200
+++ b/src/lib-storage/mail-user.h	Fri Mar 20 13:27:00 2015 +0200
@@ -47,7 +47,6 @@
 	struct mail_storage *storages;
 	ARRAY(const struct mail_storage_hooks *) hooks;
 
-	struct mountpoint_list *mountpoints;
 	normalizer_func_t *default_normalizer;
 	/* Filled lazily by mailbox_attribute_*() when accessing attributes. */
 	struct dict *_attr_dict;
@@ -151,12 +150,6 @@
 int mail_user_try_home_expand(struct mail_user *user, const char **path);
 /* Returns unique user+ip identifier for anvil. */
 const char *mail_user_get_anvil_userip_ident(struct mail_user *user);
-/* Returns FALSE if path is in a mountpoint that should be mounted,
-   but isn't mounted. In such a situation it's better to fail than to attempt
-   any kind of automatic file/dir creations. error_r gives an error about which
-   mountpoint should be mounted. */
-bool mail_user_is_path_mounted(struct mail_user *user, const char *path,
-			       const char **error_r);
 
 /* Basically the same as mail_storage_find_class(), except automatically load
    storage plugins when needed. */
diff -r cf74e2179dce -r ef1a64509d68 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Thu Mar 19 10:01:18 2015 +0200
+++ b/src/lib-storage/mailbox-list.c	Fri Mar 20 13:27:00 2015 +0200
@@ -1109,7 +1109,7 @@
 				enum mailbox_list_path_type type,
 				const char **error_r)
 {
-	const char *root_dir, *error;
+	const char *root_dir;
 	struct stat st;
 	struct mailbox_permissions perm;
 
@@ -1127,14 +1127,10 @@
 	if (strcmp(root_dir, path) != 0 && stat(root_dir, &st) == 0) {
 		/* creating a subdirectory under an already existing root dir.
 		   use the root's permissions */
-	} else if (mail_user_is_path_mounted(list->ns->user, path, &error)) {
+	} else {
 		if (mailbox_list_try_mkdir_root_parent(list, type,
 						       &perm, error_r) < 0)
 			return -1;
-	} else {
-		*error_r = t_strdup_printf(
-			"Can't create mailbox root dir %s: %s", path, error);
-		return -1;
 	}
 
 	/* the rest of the directories exist only for one user. create them
diff -r cf74e2179dce -r ef1a64509d68 src/master/main.c
--- a/src/master/main.c	Thu Mar 19 10:01:18 2015 +0200
+++ b/src/master/main.c	Fri Mar 20 13:27:00 2015 +0200
@@ -12,7 +12,6 @@
 #include "ipwd.h"
 #include "str.h"
 #include "execv-const.h"
-#include "mountpoint-list.h"
 #include "restrict-process-size.h"
 #include "master-instance.h"
 #include "master-service.h"
@@ -295,40 +294,6 @@
 	}
 }
 
-static void mountpoints_warn_missing(struct mountpoint_list *mountpoints)
-{
-	struct mountpoint_list_iter *iter;
-	struct mountpoint_list_rec *rec;
-
-	/* warn about mountpoints that no longer exist */
-	iter = mountpoint_list_iter_init(mountpoints);
-	while ((rec = mountpoint_list_iter_next(iter)) != NULL) {
-		if (MOUNTPOINT_WRONGLY_NOT_MOUNTED(rec)) {
-			i_warning("%s is no longer mounted. "
-				  "See http://wiki2.dovecot.org/Mountpoints",
-				  rec->mount_path);
-		}
-	}
-	mountpoint_list_iter_deinit(&iter);
-}
-
-static void mountpoints_update(const struct master_settings *set)
-{
-	struct mountpoint_list *mountpoints;
-	const char *perm_path, *state_path;
-
-	perm_path = t_strconcat(set->state_dir, "/"MOUNTPOINT_LIST_FNAME, NULL);
-	state_path = t_strconcat(set->base_dir, "/"MOUNTPOINT_LIST_FNAME, NULL);
-	mountpoints = mountpoint_list_init(perm_path, state_path);
-
-	if (mountpoint_list_add_missing(mountpoints, MOUNTPOINT_STATE_DEFAULT,
-				mountpoint_list_default_ignore_prefixes,
-				mountpoint_list_default_ignore_types) == 0)
-		mountpoints_warn_missing(mountpoints);
-	(void)mountpoint_list_save(mountpoints);
-	mountpoint_list_deinit(&mountpoints);
-}
-
 static void instance_update_now(struct master_instance_list *list)
 {
 	int ret;
@@ -557,7 +522,6 @@
 
 	create_pid_file(pidfile_path);
 	create_config_symlink(set);
-	mountpoints_update(set);
 	instance_update(set);
 
 	services_monitor_start(services);


More information about the dovecot-cvs mailing list