Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5537:ebffd0ccd22a HEAD
Added cache_secs parameter to vfile backend.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 11 Apr 2007 11:56:17 +0300 |
parents | fab24638eee7 |
children | b3dd56440595 |
files | dovecot-example.conf src/plugins/acl/acl-backend-vfile.c |
diffstat | 2 files changed, 28 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Tue Apr 10 17:37:50 2007 +0300 +++ b/dovecot-example.conf Wed Apr 11 11:56:17 2007 +0300 @@ -1055,8 +1055,10 @@ # ACL plugin. vfile backend reads ACLs from "dovecot-acl" file from maildir # directory. You can also optionally give a global ACL directory path where # ACLs are applied to all users' mailboxes. The global ACL directory contains - # one file for each mailbox, eg. INBOX or sub.mailbox. - #acl = vfile:/etc/dovecot-acls + # one file for each mailbox, eg. INBOX or sub.mailbox. cache_secs parameter + # specifies how many seconds to wait between stat()ing dovecot-acl file + # to see if it changed. + #acl = vfile:/etc/dovecot-acls:cache_secs=300 # Convert plugin. If set, specifies the source storage path which is # converted to destination storage (mail_location) when the user logs in.
--- a/src/plugins/acl/acl-backend-vfile.c Tue Apr 10 17:37:50 2007 +0300 +++ b/src/plugins/acl/acl-backend-vfile.c Wed Apr 11 11:56:17 2007 +0300 @@ -9,15 +9,13 @@ #include "acl-cache.h" #include "acl-api-private.h" +#include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> #define ACL_FILENAME "dovecot-acl" -/* Minimum time between stat()ing the ACL file to see if its timestamp has - changed. */ -#define ACL_VALIDITY_SECS 1 /* Time difference to allow between this system's time and file server's time */ #define ACL_SYNC_SECS 1 @@ -38,6 +36,7 @@ struct acl_backend_vfile { struct acl_backend backend; const char *global_dir; + unsigned int cache_secs; }; struct acl_object_vfile { @@ -81,14 +80,30 @@ { struct acl_backend_vfile *backend = (struct acl_backend_vfile *)_backend; + const char *const *tmp; - if (_backend->debug) - i_info("acl vfile: Global ACL directory: %s", data); + t_push(); + tmp = t_strsplit(data, ":"); + backend->global_dir = p_strdup(_backend->pool, *tmp); - backend->global_dir = p_strdup(_backend->pool, data); + while (*++tmp != NULL) { + if (strncmp(*tmp, "cache_secs=", 11) == 0) + backend->cache_secs = atoi(*tmp + 11); + else { + i_error("acl vfile: Unknown parameter: %s", *tmp); + t_pop(); + return -1; + } + } + if (_backend->debug) { + i_info("acl vfile: Global ACL directory: %s", + backend->global_dir); + } + _backend->cache = acl_cache_init(_backend, sizeof(struct acl_backend_vfile_validity)); + t_pop(); return 0; } @@ -388,12 +403,14 @@ acl_backend_vfile_refresh(struct acl_object *aclobj, const char *path, struct acl_vfile_validity *validity) { + struct acl_backend_vfile *backend = + (struct acl_backend_vfile *)aclobj->backend; struct stat st; if (validity == NULL) return 1; if (path == NULL || - validity->last_check + ACL_VALIDITY_SECS > ioloop_time) + validity->last_check + backend->cache_secs > ioloop_time) return 0; validity->last_check = ioloop_time;