Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8896:db0072f7c6b4 HEAD
acl: Fixed crash when rebuilding dovecot-acl-list file.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 02 Apr 2009 18:00:49 -0400 |
parents | 9b3bb65b808e |
children | 23ee853569e6 |
files | src/plugins/acl/acl-backend-vfile-acllist.c src/plugins/acl/acl-backend-vfile.h |
diffstat | 2 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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 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); }
--- 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 @@ 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);