Mercurial > dovecot > core-2.2
changeset 10282:7215f4142901 HEAD
Added "time" (interval) setting type, which supports s/m/h/d/w suffixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 09 Nov 2009 18:41:59 -0500 |
parents | 4b663b9e63af |
children | cb7b2901f1f8 |
files | doc/example-config/conf.d/auth.conf doc/example-config/conf.d/imap.conf doc/example-config/conf.d/mail.conf src/auth/auth-settings.c src/config/config-request.c src/imap/imap-settings.c src/lib-settings/settings-parser.c src/lib-settings/settings-parser.h src/lib-storage/index/mbox/mbox-settings.c src/lib-storage/mail-storage-settings.c |
diffstat | 10 files changed, 101 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/example-config/conf.d/auth.conf Mon Nov 09 18:22:37 2009 -0500 +++ b/doc/example-config/conf.d/auth.conf Mon Nov 09 18:41:59 2009 -0500 @@ -5,14 +5,14 @@ # Authentication cache size (e.g. 10M). 0 means it's disabled. Note that # bsdauth, PAM and vpopmail require cache_key to be set for caching to be used. #auth_cache_size = 0 -# Time to live in seconds for cached data. After this many seconds the cached -# record is no longer used, *except* if the main database lookup returns -# internal failure. We also try to handle password changes automatically: If -# user's previous authentication was successful, but this one wasn't, the -# cache isn't used. For now this works only with plaintext authentication. -#auth_cache_ttl = 3600 +# Time to live for cached data. After TTL expires the cached record is no +# longer used, *except* if the main database lookup returns internal failure. +# We also try to handle password changes automatically: If user's previous +# authentication was successful, but this one wasn't, the cache isn't used. +# For now this works only with plaintext authentication. +#auth_cache_ttl = 1 hour # TTL for negative hits (user not found). 0 disables caching them completely. -#auth_cache_negative_ttl = 3600 +#auth_cache_negative_ttl = 1 hour # Space separated list of realms for SASL authentication mechanisms that need # them. You can leave it empty if you don't want to support multiple realms. @@ -72,8 +72,8 @@ # Path for Samba's ntlm_auth helper binary. #auth_winbind_helper_path = /usr/bin/ntlm_auth -# Number of seconds to delay before replying to failed authentications. -#auth_failure_delay = 2 +# Time to delay before replying to failed authentications. +#auth_failure_delay = 2 secs # Require a valid SSL client certificate or the authentication fails. #auth_ssl_require_client_cert = no
--- a/doc/example-config/conf.d/imap.conf Mon Nov 09 18:22:37 2009 -0500 +++ b/doc/example-config/conf.d/imap.conf Mon Nov 09 18:41:59 2009 -0500 @@ -23,9 +23,9 @@ # Override the IMAP CAPABILITY response. #imap_capability = - # How many seconds to wait between "OK Still here" notifications when - # client is IDLEing. - #imap_idle_notify_interval = 120 + # How long to wait between "OK Still here" notifications when client is + # IDLEing. + #imap_idle_notify_interval = 2 mins # ID field names and values to send to clients. Using * as the value makes # Dovecot use the default value. The following fields have default values
--- a/doc/example-config/conf.d/mail.conf Mon Nov 09 18:22:37 2009 -0500 +++ b/doc/example-config/conf.d/mail.conf Mon Nov 09 18:41:59 2009 -0500 @@ -208,9 +208,9 @@ # When IDLE command is running, mailbox is checked once in a while to see if # there are any new mails or other changes. This setting defines the minimum -# time in seconds to wait between those checks. Dovecot can also use dnotify, -# inotify and kqueue to find out immediately when changes occur. -#mailbox_idle_check_interval = 30 +# time to wait between those checks. Dovecot can also use dnotify, inotify and +# kqueue to find out immediately when changes occur. +#mailbox_idle_check_interval = 30 secs # Save mails with CR+LF instead of plain LF. This makes sending those mails # take less CPU, especially with sendfile() syscall with Linux and FreeBSD. @@ -267,12 +267,12 @@ #mbox_read_locks = fcntl #mbox_write_locks = dotlock fcntl -# Maximum time in seconds to wait for lock (all of them) before aborting. -#mbox_lock_timeout = 300 +# Maximum time to wait for lock (all of them) before aborting. +#mbox_lock_timeout = 5 mins # If dotlock exists but the mailbox isn't modified in any way, override the -# lock file after this many seconds. -#mbox_dotlock_change_timeout = 120 +# lock file after this much time. +#mbox_dotlock_change_timeout = 2 mins # When mbox changes unexpectedly we have to fully read it to find out what # changed. If the mbox is large this can take a long time. Since the change
--- a/src/auth/auth-settings.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/auth/auth-settings.c Mon Nov 09 18:41:59 2009 -0500 @@ -152,8 +152,8 @@ DEF(SET_STR, realms), DEF(SET_STR, default_realm), DEF(SET_SIZE, cache_size), - DEF(SET_UINT, cache_ttl), - DEF(SET_UINT, cache_negative_ttl), + DEF(SET_TIME, cache_ttl), + DEF(SET_TIME, cache_negative_ttl), DEF(SET_STR, username_chars), DEF(SET_STR, username_translation), DEF(SET_STR, username_format), @@ -162,7 +162,7 @@ DEF(SET_STR, krb5_keytab), DEF(SET_STR, gssapi_hostname), DEF(SET_STR, winbind_helper_path), - DEF(SET_UINT, failure_delay), + DEF(SET_TIME, failure_delay), DEF(SET_BOOL, verbose), DEF(SET_BOOL, debug), @@ -184,7 +184,7 @@ MEMBER(realms) "", MEMBER(default_realm) "", MEMBER(cache_size) 0, - MEMBER(cache_ttl) 3600, + MEMBER(cache_ttl) 60*60, MEMBER(cache_negative_ttl) 0, MEMBER(username_chars) "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@", MEMBER(username_translation) "",
--- a/src/config/config-request.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/config/config-request.c Mon Nov 09 18:41:59 2009 -0500 @@ -136,7 +136,8 @@ } break; } - case SET_UINT: { + case SET_UINT: + case SET_TIME: { const unsigned int *val = value, *dval = default_value; if (dump_default || dval == NULL || *val != *dval) str_printfa(ctx->value, "%u", *val);
--- a/src/imap/imap-settings.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/imap/imap-settings.c Mon Nov 09 18:41:59 2009 -0500 @@ -63,7 +63,7 @@ DEF(SET_BOOL, verbose_proctitle), DEF(SET_SIZE, imap_max_line_length), - DEF(SET_UINT, imap_idle_notify_interval), + DEF(SET_TIME, imap_idle_notify_interval), DEF(SET_STR, imap_capability), DEF(SET_STR, imap_client_workarounds), DEF(SET_STR, imap_logout_format), @@ -81,7 +81,7 @@ break large message sets to multiple commands, so we're pretty liberal by default. */ MEMBER(imap_max_line_length) 64*1024, - MEMBER(imap_idle_notify_interval) 120, + MEMBER(imap_idle_notify_interval) 2*60, MEMBER(imap_capability) "", MEMBER(imap_client_workarounds) "outlook-idle", MEMBER(imap_logout_format) "bytes=%i/%o",
--- a/src/lib-settings/settings-parser.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/lib-settings/settings-parser.c Mon Nov 09 18:41:59 2009 -0500 @@ -310,6 +310,62 @@ } static int +get_time(struct setting_parser_context *ctx, const char *value, + unsigned int *result_r) +{ + unsigned int num, multiply; + char *p; + + num = strtoull(value, &p, 10); + while (*p == ' ') p++; + switch (i_toupper(*p)) { + case '\0': + multiply = 1; + break; + case 'S': + multiply = 1; + if (strncasecmp(p, "secs", strlen(p)) == 0) + p = ""; + break; + case 'M': + multiply = 60; + if (strncasecmp(p, "mins", strlen(p)) == 0) + p = ""; + break; + case 'H': + multiply = 60*60; + if (strncasecmp(p, "hours", strlen(p)) == 0) + p = ""; + break; + case 'D': + multiply = 60*60*24; + if (strncasecmp(p, "days", strlen(p)) == 0) + p = ""; + break; + case 'W': + multiply = 60*60*24*7; + if (strncasecmp(p, "weeks", strlen(p)) == 0) + p = ""; + break; + } + + if (*p != '\0') { + ctx->error = p_strconcat(ctx->parser_pool, + "Invalid time interval: ", + value, NULL); + return -1; + } + if (num > -1U / multiply) { + ctx->error = p_strconcat(ctx->parser_pool, + "Time interval is too large: ", + value, NULL); + return -1; + } + *result_r = num * multiply; + return 0; +} + +static int get_size(struct setting_parser_context *ctx, const char *value, uoff_t *result_r) { @@ -317,6 +373,7 @@ char *p; num = strtoull(value, &p, 10); + while (*p == ' ') p++; switch (i_toupper(*p)) { case '\0': multiply = 1; @@ -504,6 +561,10 @@ if (get_uint(ctx, value, (unsigned int *)ptr) < 0) return -1; break; + case SET_TIME: + if (get_time(ctx, value, (unsigned int *)ptr) < 0) + return -1; + break; case SET_SIZE: if (get_size(ctx, value, (uoff_t *)ptr) < 0) return -1; @@ -962,6 +1023,7 @@ switch (def->type) { case SET_BOOL: case SET_UINT: + case SET_TIME: case SET_SIZE: case SET_STR: case SET_ENUM: @@ -1032,6 +1094,7 @@ switch (def->type) { case SET_BOOL: case SET_UINT: + case SET_TIME: case SET_SIZE: case SET_STR: case SET_ENUM: @@ -1100,7 +1163,8 @@ *dest_bool = *src_bool; break; } - case SET_UINT: { + case SET_UINT: + case SET_TIME: { const unsigned int *src_uint = src; unsigned int *dest_uint = dest; @@ -1208,6 +1272,7 @@ switch (def->type) { case SET_BOOL: case SET_UINT: + case SET_TIME: case SET_SIZE: case SET_STR_VARS: case SET_STR:
--- a/src/lib-settings/settings-parser.h Mon Nov 09 18:22:37 2009 -0500 +++ b/src/lib-settings/settings-parser.h Mon Nov 09 18:41:59 2009 -0500 @@ -19,6 +19,7 @@ enum setting_type { SET_BOOL, SET_UINT, + SET_TIME, SET_SIZE, SET_STR, SET_STR_VARS, /* string with %variables */ @@ -52,6 +53,10 @@ { SET_SIZE + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \ ((struct struct_name *)0)->name, uoff_t), \ #name, offsetof(struct struct_name, name), NULL } +#define SETTING_DEFINE_STRUCT_TIME(name, struct_name) \ + { SET_TIME + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \ + ((struct struct_name *)0)->name, unsigned int), \ + #name, offsetof(struct struct_name, name), NULL } #define SETTING_DEFINE_STRUCT_STR(name, struct_name) \ { SET_STR + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE( \ ((struct struct_name *)0)->name, const char *), \ @@ -190,7 +195,5 @@ /* Return section name escaped */ const char *settings_section_escape(const char *name); -/* Parse a size string to actual size. */ -int settings_parse_size(const char *str, uoff_t *size_r, const char **error_r); #endif
--- a/src/lib-storage/index/mbox/mbox-settings.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/lib-storage/index/mbox/mbox-settings.c Mon Nov 09 18:41:59 2009 -0500 @@ -14,8 +14,8 @@ static const struct setting_define mbox_setting_defines[] = { DEF(SET_STR, mbox_read_locks), DEF(SET_STR, mbox_write_locks), - DEF(SET_UINT, mbox_lock_timeout), - DEF(SET_UINT, mbox_dotlock_change_timeout), + DEF(SET_TIME, mbox_lock_timeout), + DEF(SET_TIME, mbox_dotlock_change_timeout), DEF(SET_SIZE, mbox_min_index_size), DEF(SET_BOOL, mbox_dirty_syncs), DEF(SET_BOOL, mbox_very_dirty_syncs),
--- a/src/lib-storage/mail-storage-settings.c Mon Nov 09 18:22:37 2009 -0500 +++ b/src/lib-storage/mail-storage-settings.c Mon Nov 09 18:41:59 2009 -0500 @@ -25,7 +25,7 @@ DEF(SET_STR, mail_cache_fields), DEF(SET_STR, mail_never_cache_fields), DEF(SET_UINT, mail_cache_min_mail_count), - DEF(SET_UINT, mailbox_idle_check_interval), + DEF(SET_TIME, mailbox_idle_check_interval), DEF(SET_UINT, mail_max_keyword_length), DEF(SET_BOOL, mail_save_crlf), DEF(SET_BOOL, fsync_disable),