"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/plugins/acl/acl-backend-vfile.c" between
dovecot-2.3.16.tar.gz and dovecot-2.3.17.tar.gz

About: Dovecot is an IMAP and POP3 server, written with security primarily in mind.

acl-backend-vfile.c  (dovecot-2.3.16):acl-backend-vfile.c  (dovecot-2.3.17)
skipping to change at line 125 skipping to change at line 125
if (backend->globals_only) if (backend->globals_only)
return NULL; return NULL;
/* ACL files are very important. try to keep them among the main /* ACL files are very important. try to keep them among the main
mail files. that's not possible though with a) if the mailbox is mail files. that's not possible though with a) if the mailbox is
a file or b) if the mailbox path doesn't point to filesystem. */ a file or b) if the mailbox path doesn't point to filesystem. */
if (mailbox_list_get_storage(&list, vname, &storage) < 0) if (mailbox_list_get_storage(&list, vname, &storage) < 0)
return NULL; return NULL;
i_assert(list == ns->list); i_assert(list == ns->list);
type = mail_storage_is_mailbox_file(storage) || type = mail_storage_get_acl_list_path_type(storage);
(storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NO_ROOT) != 0 ?
MAILBOX_LIST_PATH_TYPE_CONTROL : MAILBOX_LIST_PATH_TYPE_MAILBOX;
if (name == NULL) { if (name == NULL) {
if (!mailbox_list_get_root_path(list, type, &dir)) if (!mailbox_list_get_root_path(list, type, &dir))
return NULL; return NULL;
} else { } else {
if (mailbox_list_get_path(list, name, type, &dir) <= 0) if (mailbox_list_get_path(list, name, type, &dir) <= 0)
return NULL; return NULL;
} }
/* verify that the directory isn't same as INBOX's directory. /* verify that the directory isn't same as INBOX's directory.
this is mainly for Maildir. */ this is mainly for Maildir. */
skipping to change at line 227 skipping to change at line 225
validity->last_size = st.st_size; validity->last_size = st.st_size;
return 1; return 1;
} }
static bool static bool
acl_backend_vfile_has_acl(struct acl_backend *_backend, const char *name) acl_backend_vfile_has_acl(struct acl_backend *_backend, const char *name)
{ {
struct acl_backend_vfile *backend = struct acl_backend_vfile *backend =
(struct acl_backend_vfile *)_backend; (struct acl_backend_vfile *)_backend;
struct acl_backend_vfile_validity *old_validity, new_validity; struct acl_backend_vfile_validity *old_validity, new_validity;
const char *path, *local_path, *global_path, *dir, *vname = ""; const char *global_path, *vname;
const char *error;
int ret; int ret;
old_validity = acl_cache_get_validity(_backend->cache, name); old_validity = acl_cache_get_validity(_backend->cache, name);
if (old_validity != NULL) if (old_validity != NULL)
new_validity = *old_validity; new_validity = *old_validity;
else else
i_zero(&new_validity); i_zero(&new_validity);
/* See if the mailbox exists. If we wanted recursive lookups we could /* The caller wants to stop whenever a parent mailbox exists, even if
skip this, but at least for now we assume that if an existing it has no ACL file. Also, if a mailbox doesn't exist then it can't
mailbox has no ACL it's equivalent to default ACLs. */ have a local ACL file. First check if there's a matching global ACL.
if (mailbox_list_get_path(_backend->list, name, If not, check if the mailbox exists. */
MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) <= 0) vname = *name == '\0' ? "" :
ret = -1; mailbox_list_get_vname(_backend->list, name);
else { struct mailbox *box =
ret = acl_backend_vfile_exists(backend, path, mailbox_alloc(_backend->list, vname,
&new_validity.mailbox_validity); MAILBOX_FLAG_READONLY | MAILBOX_FLAG_IGNORE_ACLS);
} if (backend->global_path == NULL) {
/* global ACLs disabled */
if (ret == 0 && ret = 0;
(*name == '\0' || } else if (_backend->global_file != NULL) {
mailbox_list_is_valid_name(_backend->list, name, &error))) { /* check global ACL file */
vname = *name == '\0' ? "" : ret = acl_global_file_refresh(_backend->global_file);
mailbox_list_get_vname(_backend->list, name); if (ret == 0 && acl_global_file_have_any(_backend->global_file, b
dir = acl_backend_vfile_get_local_dir(_backend, name, vname); ox->vname))
if (dir != NULL) { ret = 1;
local_path = t_strconcat(dir, "/", name, NULL); } else {
ret = acl_backend_vfile_exists(backend, local_path, /* check global ACL directory */
&new_validity.local_validi global_path = t_strconcat(backend->global_path, "/", name, NULL);
ty); ret = acl_backend_vfile_exists(backend, global_path,
} &new_validity.global_validity);
} }
if (ret == 0 && backend->global_path != NULL) { if (ret != 0) {
if (_backend->global_file != NULL) { /* error / global ACL found */
ret = acl_global_file_refresh(_backend->global_file); } else if (mailbox_open(box) == 0) {
if (ret == 0 && acl_global_file_have_any(_backend->global /* mailbox exists */
_file, vname)) ret = 1;
ret = 1; } else {
} else { enum mail_error error;
global_path = t_strconcat(backend->global_path, "/", name const char *errstr =
, NULL); mailbox_get_last_internal_error(box, &error);
ret = acl_backend_vfile_exists(backend, global_path, if (error == MAIL_ERROR_NOTFOUND)
&new_validity.global_valid ret = 0;
ity); else {
e_error(box->event, "acl: Failed to open mailbox: %s",
errstr);
ret = -1;
} }
} }
acl_cache_set_validity(_backend->cache, name, &new_validity); acl_cache_set_validity(_backend->cache, name, &new_validity);
mailbox_free(&box);
return ret > 0; return ret > 0;
} }
static struct acl_object * static struct acl_object *
acl_backend_vfile_object_init_parent(struct acl_backend *backend, acl_backend_vfile_object_init_parent(struct acl_backend *backend,
const char *child_name) const char *child_name)
{ {
const char *parent; const char *parent;
/* stop at the first parent that /* stop at the first parent that
 End of changes. 6 change blocks. 
40 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)