dovecot-1.2: acl: If dovecot-acl-list writing fails, delete it s...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 22 07:43:05 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/8206c38856ff
changeset: 9154:8206c38856ff
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 22 00:42:56 2009 -0400
description:
acl: If dovecot-acl-list writing fails, delete it so it gets rebuilt later.

diffstat:

1 file changed, 23 insertions(+), 1 deletion(-)
src/plugins/acl/acl-backend-vfile-acllist.c |   24 +++++++++++++++++++++++-

diffs (48 lines):

diff -r f2426d980426 -r 8206c38856ff src/plugins/acl/acl-backend-vfile-acllist.c
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Mon Jun 22 00:29:13 2009 -0400
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Mon Jun 22 00:42:56 2009 -0400
@@ -164,7 +164,8 @@ acllist_append(struct acl_backend_vfile 
 	return ret < 0 ? -1 : 0;
 }
 
-int acl_backend_vfile_acllist_rebuild(struct acl_backend_vfile *backend)
+static int
+acl_backend_vfile_acllist_try_rebuild(struct acl_backend_vfile *backend)
 {
 	struct mailbox_list *list = backend->backend.list;
 	struct mail_namespace *ns;
@@ -224,6 +225,10 @@ int acl_backend_vfile_acllist_rebuild(st
 		}
 	}
 
+	if (output->stream_errno != 0) {
+		i_error("write(%s) failed: %m", str_c(path));
+		ret = -1;
+	}
 	if (mailbox_list_iter_deinit(&iter) < 0)
 		ret = -1;
 	o_stream_destroy(&output);
@@ -263,6 +268,23 @@ int acl_backend_vfile_acllist_rebuild(st
 	return ret;
 }
 
+int acl_backend_vfile_acllist_rebuild(struct acl_backend_vfile *backend)
+{
+	const char *rootdir, *acllist_path;
+
+	if (acl_backend_vfile_acllist_try_rebuild(backend) == 0)
+		return 0;
+	else {
+		/* delete it to make sure it gets rebuilt later */
+		rootdir = mailbox_list_get_path(backend->backend.list, NULL,
+						MAILBOX_LIST_PATH_TYPE_DIR);
+		acllist_path = t_strdup_printf("%s/"ACLLIST_FILENAME, rootdir);
+		if (unlink(acllist_path) < 0 && errno != ENOENT)
+			i_error("unlink(%s) failed: %m", acllist_path);
+		return -1;
+	}
+}
+
 static const struct acl_backend_vfile_acllist *
 acl_backend_vfile_acllist_find(struct acl_backend_vfile *backend,
 			       const char *name)


More information about the dovecot-cvs mailing list