dovecot-1.2: acl: Fixed crash when rebuilding dovecot-acl-list f...

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 3 01:00:55 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/db0072f7c6b4
changeset: 8896:db0072f7c6b4
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 02 18:00:49 2009 -0400
description:
acl: Fixed crash when rebuilding dovecot-acl-list file.

diffstat:

2 files changed, 15 insertions(+), 3 deletions(-)
src/plugins/acl/acl-backend-vfile-acllist.c |   17 ++++++++++++++---
src/plugins/acl/acl-backend-vfile.h         |    1 +

diffs (81 lines):

diff -r 9b3bb65b808e -r db0072f7c6b4 src/plugins/acl/acl-backend-vfile-acllist.c
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Thu Apr 02 15:59:04 2009 -0400
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Thu Apr 02 18:00:49 2009 -0400
@@ -113,6 +113,8 @@ static int acl_backend_vfile_acllist_rea
 
 void acl_backend_vfile_acllist_refresh(struct acl_backend_vfile *backend)
 {
+	i_assert(!backend->iterating_acllist);
+
 	if (backend->acllist_last_check +
 	    (time_t)backend->cache_secs > ioloop_time)
 		return;
@@ -176,6 +178,8 @@ int acl_backend_vfile_acllist_rebuild(st
 	gid_t gid;
 	int fd, ret;
 
+	i_assert(!backend->rebuilding_acllist);
+
 	rootdir = mailbox_list_get_path(list, NULL,
 					MAILBOX_LIST_PATH_TYPE_DIR);
 	if (rootdir == NULL)
@@ -218,7 +222,6 @@ int acl_backend_vfile_acllist_rebuild(st
 	if (mailbox_list_iter_deinit(&iter) < 0)
 		ret = -1;
 	o_stream_destroy(&output);
-	backend->rebuilding_acllist = FALSE;
 
 	if (ret == 0) {
 		if (fstat(fd, &st) < 0) {
@@ -251,6 +254,7 @@ int acl_backend_vfile_acllist_rebuild(st
 		if (unlink(str_c(path)) < 0 && errno != ENOENT)
 			i_error("unlink(%s) failed: %m", str_c(path));
 	}
+	backend->rebuilding_acllist = FALSE;
 	return ret;
 }
 
@@ -274,10 +278,12 @@ void acl_backend_vfile_acllist_verify(st
 {
 	const struct acl_backend_vfile_acllist *acllist;
 
+	if (backend->rebuilding_acllist || backend->iterating_acllist)
+		return;
+
 	acl_backend_vfile_acllist_refresh(backend);
 	acllist = acl_backend_vfile_acllist_find(backend, name);
-	if (acllist != NULL && acllist->mtime != mtime &&
-	    !backend->rebuilding_acllist)
+	if (acllist != NULL && acllist->mtime != mtime)
 		(void)acl_backend_vfile_acllist_rebuild(backend);
 }
 
@@ -292,6 +298,7 @@ acl_backend_vfile_nonowner_iter_init(str
 
 	ctx = i_new(struct acl_mailbox_list_context_vfile, 1);
 	ctx->ctx.backend = _backend;
+	backend->iterating_acllist = TRUE;
 	return &ctx->ctx;
 }
 
@@ -316,5 +323,9 @@ void
 void
 acl_backend_vfile_nonowner_iter_deinit(struct acl_mailbox_list_context *ctx)
 {
+	struct acl_backend_vfile *backend =
+		(struct acl_backend_vfile *)ctx->backend;
+
+	backend->iterating_acllist = FALSE;
 	i_free(ctx);
 }
diff -r 9b3bb65b808e -r db0072f7c6b4 src/plugins/acl/acl-backend-vfile.h
--- a/src/plugins/acl/acl-backend-vfile.h	Thu Apr 02 15:59:04 2009 -0400
+++ b/src/plugins/acl/acl-backend-vfile.h	Thu Apr 02 18:00:49 2009 -0400
@@ -33,6 +33,7 @@ struct acl_backend_vfile {
 
 	unsigned int cache_secs;
 	unsigned int rebuilding_acllist:1;
+	unsigned int iterating_acllist:1;
 };
 
 void acl_backend_vfile_acllist_refresh(struct acl_backend_vfile *backend);


More information about the dovecot-cvs mailing list