From: Timo Sirainen Date: Mon, 22 Sep 2008 19:31:33 +0000 (+0300) Subject: ACL: Handle shared namespaces. X-Git-Tag: 1.2.alpha2~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9aef7a5fcee899c061d35ed8f2fca6b0b5bee3d5;p=thirdparty%2Fdovecot%2Fcore.git ACL: Handle shared namespaces. --HG-- branch : HEAD --- diff --git a/src/plugins/acl/acl-backend-vfile-acllist.c b/src/plugins/acl/acl-backend-vfile-acllist.c index 320846da93..f148878287 100644 --- a/src/plugins/acl/acl-backend-vfile-acllist.c +++ b/src/plugins/acl/acl-backend-vfile-acllist.c @@ -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) { diff --git a/src/plugins/acl/acl-backend-vfile.c b/src/plugins/acl/acl-backend-vfile.c index 7bb35fd5c7..4d728aeeb0 100644 --- a/src/plugins/acl/acl-backend-vfile.c +++ b/src/plugins/acl/acl-backend-vfile.c @@ -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);