]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
acl: acl_backend_vfile_has_acl() - Check first if global ACL exists
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 16 Sep 2021 16:22:41 +0000 (19:22 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 17 Sep 2021 16:14:13 +0000 (16:14 +0000)
Global ACL can be checked more efficiently. If it exists, there's no need
anymore to access the local mailbox ro ACL files.

src/plugins/acl/acl-backend-vfile.c

index 16666bd6884ada0754377373a255ad6cf0e26571..24572e5c7eadede2cb1d87aee35dcda522dc910d 100644 (file)
@@ -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;
 }