]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
ACL: Handle shared namespaces.
authorTimo Sirainen <tss@iki.fi>
Mon, 22 Sep 2008 19:31:33 +0000 (22:31 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 22 Sep 2008 19:31:33 +0000 (22:31 +0300)
--HG--
branch : HEAD

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

index 320846da93bb4438ebed15b84dd6bc2d48a776fa..f14887828789f67cc4b119f8e77d6fe02b256b01 100644 (file)
@@ -51,6 +51,11 @@ static int acl_backend_vfile_acllist_read(struct acl_backend_vfile *backend)
 
        rootdir = mailbox_list_get_path(backend->backend.list, NULL,
                                        MAILBOX_LIST_PATH_TYPE_DIR);
+       if (rootdir == NULL) {
+               /* we're never going to build acllist for this namespace. */
+               i_array_init(&backend->acllist, 1);
+               return 0;
+       }
        path = t_strdup_printf("%s/"ACLLIST_FILENAME, rootdir);
 
        if (backend->acllist_mtime != 0) {
@@ -191,16 +196,18 @@ int acl_backend_vfile_acllist_rebuild(struct acl_backend_vfile *backend)
        gid_t gid;
        int fd, ret;
 
-       mailbox_list_get_permissions(list, &mode, &gid);
-
-       path = t_str_new(256);
        rootdir = mailbox_list_get_path(list, NULL,
                                        MAILBOX_LIST_PATH_TYPE_DIR);
+       if (rootdir == NULL)
+               return 0;
+
+       path = t_str_new(256);
        str_printfa(path, "%s/%s", rootdir, mailbox_list_get_temp_prefix(list));
 
        /* Build it into a temporary file and rename() over. There's no need
           to use locking, because even if multiple processes are rebuilding
           the file at the same time the result should be the same. */
+       mailbox_list_get_permissions(list, &mode, &gid);
        fd = safe_mkstemp(path, mode, (uid_t)-1, gid);
        if (fd == -1) {
                if (errno == EACCES) {
index 7bb35fd5c78419ef0271d550fa5e3c0e6f066c17..4d728aeeb082f314c939a204137018bf1eb9ef89 100644 (file)
@@ -143,7 +143,8 @@ acl_backend_vfile_object_init(struct acl_backend *_backend,
        } else {
                dir = acl_backend_vfile_get_local_dir(storage, name);
        }
-       aclobj->local_path = i_strconcat(dir, "/"ACL_FILENAME, NULL);
+       aclobj->local_path = dir == NULL ? NULL :
+               i_strconcat(dir, "/"ACL_FILENAME, NULL);
        return &aclobj->aclobj;
 }
 
@@ -208,8 +209,9 @@ acl_backend_vfile_has_acl(struct acl_backend *_backend,
           mailbox has no ACL it's equivalent to default ACLs. */
        path = mailbox_list_get_path(storage->list, name,
                                     MAILBOX_LIST_PATH_TYPE_MAILBOX);
-       ret = acl_backend_vfile_exists(backend, path,
-                                      &new_validity.mailbox_validity);
+       ret = path == NULL ? 0 :
+               acl_backend_vfile_exists(backend, path,
+                                        &new_validity.mailbox_validity);
        if (ret == 0) {
                dir = acl_backend_vfile_get_local_dir(storage, name);
                local_path = t_strconcat(dir, "/", name, NULL);