[dovecot-cvs] dovecot/src/plugins/acl acl-api-private.h, 1.3, 1.4 acl-api.c, 1.3, 1.4 acl-backend-vfile.c, 1.11, 1.12 acl-backend.c, 1.4, 1.5 acl-plugin.c, 1.2, 1.3
tss at dovecot.org
tss at dovecot.org
Thu Dec 28 14:47:41 UTC 2006
- Previous message: [dovecot-cvs] dovecot/src/plugins/acl acl-api-private.h, 1.2.2.1, 1.2.2.2 acl-api.c, 1.2.2.1, 1.2.2.2 acl-backend-vfile.c, 1.5.2.3, 1.5.2.4 acl-backend.c, 1.2.2.2, 1.2.2.3 acl-plugin.c, 1.1, 1.1.2.1
- Next message: [dovecot-cvs] dovecot/src/master main.c, 1.80.2.13, 1.80.2.14 master-settings.c, 1.125.2.20, 1.125.2.21 master-settings.h, 1.83.2.6, 1.83.2.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/plugins/acl
In directory talvi:/tmp/cvs-serv29520
Modified Files:
acl-api-private.h acl-api.c acl-backend-vfile.c acl-backend.c
acl-plugin.c
Log Message:
If debug is enabled, log some debugging messages. Also cleaned up the code
bit, and made "acl = vfile" not require ":" after the "vfile".
Index: acl-api-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-api-private.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- acl-api-private.h 4 Aug 2006 16:28:28 -0000 1.3
+++ acl-api-private.h 28 Dec 2006 14:47:38 -0000 1.4
@@ -4,12 +4,12 @@
#include "acl-api.h"
struct acl_backend_vfuncs {
- struct acl_backend *(*init)(const char *data);
+ struct acl_backend *(*alloc)(void);
+ int (*init)(struct acl_backend *backend, const char *data);
void (*deinit)(struct acl_backend *backend);
struct acl_object *(*object_init)(struct acl_backend *backend,
- const char *name,
- const char *control_dir);
+ const char *name);
void (*object_deinit)(struct acl_object *aclobj);
int (*object_refresh_cache)(struct acl_object *aclobj);
@@ -36,6 +36,8 @@
struct acl_mask *default_aclmask;
struct acl_backend_vfuncs v;
+
+ unsigned int debug:1;
};
struct acl_object {
Index: acl-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-api.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- acl-api.c 4 Aug 2006 16:28:28 -0000 1.3
+++ acl-api.c 28 Dec 2006 14:47:38 -0000 1.4
@@ -9,10 +9,7 @@
struct acl_object *acl_object_init_from_name(struct acl_backend *backend,
const char *name)
{
- const char *control_dir =
- mail_storage_get_mailbox_control_dir(backend->storage, name);
-
- return backend->v.object_init(backend, name, control_dir);
+ return backend->v.object_init(backend, name);
}
struct acl_object *acl_object_init_from_mailbox(struct acl_backend *backend,
Index: acl-backend-vfile.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-backend-vfile.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- acl-backend-vfile.c 12 Nov 2006 20:04:55 -0000 1.11
+++ acl-backend-vfile.c 28 Dec 2006 14:47:38 -0000 1.12
@@ -65,33 +65,48 @@
{ '\0', NULL }
};
-static struct acl_backend *acl_backend_vfile_init(const char *data)
+static struct acl_backend *acl_backend_vfile_alloc(void)
{
struct acl_backend_vfile *backend;
pool_t pool;
- pool = pool_alloconly_create("ACL backend", nearest_power(512));
+ pool = pool_alloconly_create("ACL backend", 512);
backend = p_new(pool, struct acl_backend_vfile, 1);
- backend->global_dir = p_strdup(pool, data);
backend->backend.pool = pool;
- backend->backend.cache =
- acl_cache_init(&backend->backend,
- sizeof(struct acl_backend_vfile_validity));
return &backend->backend;
}
+static int
+acl_backend_vfile_init(struct acl_backend *_backend, const char *data)
+{
+ struct acl_backend_vfile *backend =
+ (struct acl_backend_vfile *)_backend;
+
+ if (_backend->debug)
+ i_info("acl vfile: Global ACL directory: %s", data);
+
+ backend->global_dir = p_strdup(_backend->pool, data);
+ _backend->cache =
+ acl_cache_init(_backend,
+ sizeof(struct acl_backend_vfile_validity));
+ return 0;
+}
+
static void acl_backend_vfile_deinit(struct acl_backend *backend)
{
pool_unref(backend->pool);
}
static struct acl_object *
-acl_backend_vfile_object_init(struct acl_backend *_backend,
- const char *name, const char *control_dir)
+acl_backend_vfile_object_init(struct acl_backend *_backend, const char *name)
{
struct acl_backend_vfile *backend =
(struct acl_backend_vfile *)_backend;
struct acl_object_vfile *aclobj;
+ const char *control_dir;
+
+ control_dir =
+ mail_storage_get_mailbox_control_dir(_backend->storage, name);
aclobj = i_new(struct acl_object_vfile, 1);
aclobj->aclobj.backend = _backend;
@@ -241,6 +256,9 @@
fd = nfs_safe_open(path, O_RDONLY);
if (fd == -1) {
if (errno == ENOENT) {
+ if (aclobj->backend->debug)
+ i_info("acl vfile: file %s not found", path);
+
validity->last_size = 0;
validity->last_mtime = 0;
validity->last_read_time = ioloop_time;
@@ -268,6 +286,9 @@
return 0;
}
+ if (aclobj->backend->debug)
+ i_info("acl vfile: reading file %s", path);
+
input = i_stream_create_file(fd, default_pool, 4096, FALSE);
linenum = 1;
@@ -453,6 +474,7 @@
}
struct acl_backend_vfuncs acl_backend_vfile = {
+ acl_backend_vfile_alloc,
acl_backend_vfile_init,
acl_backend_vfile_deinit,
acl_backend_vfile_object_init,
Index: acl-backend.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-backend.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- acl-backend.c 4 Aug 2006 16:28:28 -0000 1.4
+++ acl-backend.c 28 Dec 2006 14:47:38 -0000 1.5
@@ -32,30 +32,35 @@
{
struct acl_backend *backend;
unsigned int i, group_count;
- bool storage_owner;
+ bool storage_owner, debug;
+
+ debug = getenv("DEBUG") != NULL;
+ if (debug) {
+ i_info("acl: initializing backend with data: %s", data);
+ i_info("acl: acl username = %s", acl_username);
+ i_info("acl: owner username = %s",
+ owner_username != NULL ? owner_username : "");
+ }
group_count = strarray_length(groups);
- if (strncmp(data, "vfile:", 6) != 0)
+ if (strncmp(data, "vfile:", 6) == 0)
+ data += 6;
+ else if (strcmp(data, "vfile") == 0)
+ data = "";
+ else
i_fatal("Unknown ACL backend: %s", t_strcut(data, ':'));
- data += 6;
- backend = acl_backend_vfile.init(data);
+ backend = acl_backend_vfile.alloc();
+ backend->debug = debug;
backend->v = acl_backend_vfile;
backend->storage = storage;
backend->username = p_strdup(backend->pool, acl_username);
backend->owner_username = owner_username == NULL ? "" :
p_strdup(backend->pool, owner_username);
- backend->group_count = group_count;
-
- storage_owner = owner_username != NULL &&
- strcmp(acl_username, owner_username) == 0;
- backend->default_aclmask =
- acl_cache_mask_init(backend->cache, backend->pool,
- storage_owner ? owner_mailbox_rights :
- non_owner_mailbox_rights);
if (group_count > 0) {
+ backend->group_count = group_count;
backend->groups =
p_new(backend->pool, const char *, group_count);
for (i = 0; i < group_count; i++)
@@ -64,6 +69,16 @@
strcmp_p);
}
+ if (acl_backend_vfile.init(backend, data) < 0)
+ i_fatal("acl: backend vfile init failed with data: %s", data);
+
+ storage_owner = owner_username != NULL &&
+ strcmp(acl_username, owner_username) == 0;
+ backend->default_aclmask =
+ acl_cache_mask_init(backend->cache, backend->pool,
+ storage_owner ? owner_mailbox_rights :
+ non_owner_mailbox_rights);
+
backend->default_aclobj = acl_object_init_from_name(backend, "");
return backend;
}
Index: acl-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-plugin.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- acl-plugin.c 16 Nov 2006 00:17:14 -0000 1.2
+++ acl-plugin.c 28 Dec 2006 14:47:38 -0000 1.3
@@ -23,6 +23,9 @@
acl_next_hook_mailbox_list_created = hook_mailbox_list_created;
hook_mailbox_list_created = acl_mailbox_list_created;
+ } else {
+ if (getenv("DEBUG") != NULL)
+ i_info("acl: ACL environment not set");
}
}
- Previous message: [dovecot-cvs] dovecot/src/plugins/acl acl-api-private.h, 1.2.2.1, 1.2.2.2 acl-api.c, 1.2.2.1, 1.2.2.2 acl-backend-vfile.c, 1.5.2.3, 1.5.2.4 acl-backend.c, 1.2.2.2, 1.2.2.3 acl-plugin.c, 1.1, 1.1.2.1
- Next message: [dovecot-cvs] dovecot/src/master main.c, 1.80.2.13, 1.80.2.14 master-settings.c, 1.125.2.20, 1.125.2.21 master-settings.h, 1.83.2.6, 1.83.2.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list