acl-cache.c revision 2e37d45867d081db150ab78dad303b9077aea24f
/* Copyright (c) 2006-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "acl-cache.h"
#include "acl-api-private.h"
/* Give more than enough so that the arrays should never have to be grown.
IMAP ACLs define only 10 standard rights and 10 user-defined rights. */
#define DEFAULT_ACL_RIGHTS_COUNT 64
#define ACL_GLOBAL_COUNT 2
struct acl_object_cache {
char *name;
struct acl_mask *my_current_rights;
};
struct acl_cache {
struct acl_backend *backend;
/* Right names mapping is used for faster rights checking. Note that
acl_mask bitmask relies on the order to never change, so only new
rights can be added to the mapping. */
/* idx => right name. */
ARRAY_DEFINE(right_idx_name_map, const char *);
/* name => idx */
struct hash_table *right_name_idx_map;
};
static struct acl_mask negative_cache_entry;
{
return cache;
}
{
}
{
}
static struct acl_mask *
const char *const *rights)
{
unsigned int rights_count, i, idx;
unsigned char *p;
for (i = 0; i < rights_count; i++) {
}
/* @UNSAFE */
return mask;
}
const char *const *rights)
{
T_BEGIN {
} T_END;
return mask;
}
static struct acl_mask *
{
return mask;
}
{
}
{
unsigned int idx;
void *idx_p;
char *name;
const char *const_name;
/* use +1 for right_name_idx_map values because we can't add NULL
values. */
/* new right name, add it */
} else {
}
return idx;
}
{
struct acl_object_cache *obj_cache;
}
}
{
struct hash_iterate_context *iter;
}
}
static void
struct acl_object_cache *obj_cache,
enum acl_modify_mode modify_mode,
const char *const *rights,
{
unsigned int i, size;
switch (modify_mode) {
case ACL_MODIFY_MODE_ADD:
break;
}
if (change_mask == NULL) {
/* no changes */
break;
}
/* merge the masks */
/* keep using the old mask */
for (i = 0; i < change_mask->size; i++)
} else {
/* use the new mask, put old changes into it */
}
break;
case ACL_MODIFY_MODE_REMOVE:
break;
}
/* remove changed bits from old mask */
for (i = 0; i < size; i++)
break;
case ACL_MODIFY_MODE_REPLACE:
break;
case ACL_MODIFY_MODE_CLEAR:
i_unreached();
}
}
/* current rights need to be recalculated */
else
}
}
static struct acl_object_cache *
bool *created_r)
{
struct acl_object_cache *obj_cache;
} else {
}
return obj_cache;
}
const struct acl_rights_update *update)
{
struct acl_object_cache *obj_cache;
bool created;
/* since the rights aren't being replaced, start with our
default rights */
}
}
const void *validity)
{
struct acl_object_cache *obj_cache;
bool created;
/* @UNSAFE: validity is stored after the cache record */
if (created) {
/* negative cache entry */
}
}
{
struct acl_object_cache *obj_cache;
}
unsigned int *count_r)
{
}
static void
{
unsigned int i, size;
/* @UNSAFE */
/* apply the positive rights */
/* apply the negative rights. they override positive rights. */
for (i = 0; i < size; i++)
}
}
const struct acl_mask *
{
struct acl_object_cache *obj_cache;
return NULL;
T_BEGIN {
} T_END;
}
return obj_cache->my_current_rights;
}
{
unsigned int mask_idx;
}