From: Timo Sirainen Date: Thu, 16 Sep 2021 16:22:41 +0000 (+0300) Subject: acl: acl_backend_vfile_has_acl() - Check first if global ACL exists X-Git-Tag: 2.3.17~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f8fb686c00fac2ca0d486daa303faeed69f0d13;p=thirdparty%2Fdovecot%2Fcore.git acl: acl_backend_vfile_has_acl() - Check first if global ACL exists Global ACL can be checked more efficiently. If it exists, there's no need anymore to access the local mailbox ro ACL files. --- diff --git a/src/plugins/acl/acl-backend-vfile.c b/src/plugins/acl/acl-backend-vfile.c index 16666bd688..24572e5c7e 100644 --- a/src/plugins/acl/acl-backend-vfile.c +++ b/src/plugins/acl/acl-backend-vfile.c @@ -247,6 +247,22 @@ acl_backend_vfile_has_acl(struct acl_backend *_backend, const char *name) &path) <= 0) ret = -1; else { + ret = 0; + } + + if (ret == 0 && backend->global_path != NULL) { + if (_backend->global_file != NULL) { + ret = acl_global_file_refresh(_backend->global_file); + if (ret == 0 && acl_global_file_have_any(_backend->global_file, vname)) + ret = 1; + } else { + global_path = t_strconcat(backend->global_path, "/", name, NULL); + ret = acl_backend_vfile_exists(backend, global_path, + &new_validity.global_validity); + } + } + + if (ret == 0) { ret = acl_backend_vfile_exists(backend, path, &new_validity.mailbox_validity); } @@ -262,17 +278,6 @@ acl_backend_vfile_has_acl(struct acl_backend *_backend, const char *name) } } - if (ret == 0 && backend->global_path != NULL) { - if (_backend->global_file != NULL) { - ret = acl_global_file_refresh(_backend->global_file); - if (ret == 0 && acl_global_file_have_any(_backend->global_file, vname)) - ret = 1; - } else { - global_path = t_strconcat(backend->global_path, "/", name, NULL); - ret = acl_backend_vfile_exists(backend, global_path, - &new_validity.global_validity); - } - } acl_cache_set_validity(_backend->cache, name, &new_validity); return ret > 0; }