Skip to content

Commit

Permalink
lib-sieve: Made the retention period for redirect duplicate identifie…
Browse files Browse the repository at this point in the history
…rs configurable.

For accounts that perform many redirects, the lda-dupes database could grow to impractical sizes.
Changed the default retention period from 24 to 12 hours.
  • Loading branch information
stephanbosch committed Jun 20, 2017
1 parent 82563e9 commit de4248b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
10 changes: 10 additions & 0 deletions INSTALL
Expand Up @@ -271,6 +271,16 @@ plugin section of the config file (default values are shown if applicable):
the envelope sender of the redirected message is also always "<>",
irrespective of what is configured for this setting.

sieve_redirect_duplicate_period = 12h
In an effort to halt potential mail loops, the Sieve redirect action records
identifying information for messages it has forwarded. If a duplicate message
is seen, it is not redirected and the message is discarded; i.e., the
implicit keep is canceled. This setting configures the period during which
the identifying information is recorded. If an account forwards many
messages, it may be necessary to lower this setting to prevent the
~/.dovecot.lda-dupes database file (in which these are recorded) from growing
to an impractical size.

For example:

plugin {
Expand Down
9 changes: 2 additions & 7 deletions src/lib-sieve/cmd-redirect.c
Expand Up @@ -29,12 +29,6 @@

#include <stdio.h>

/*
* Configuration
*/

#define CMD_REDIRECT_DUPLICATE_KEEP (3600 * 24)

/*
* Redirect command
*
Expand Down Expand Up @@ -422,6 +416,7 @@ static int act_redirect_commit
const struct sieve_action_exec_env *aenv, void *tr_context ATTR_UNUSED,
bool *keep)
{
struct sieve_instance *svinst = aenv->svinst;
struct act_redirect_context *ctx =
(struct act_redirect_context *) action->context;
struct sieve_message_context *msgctx = aenv->msgctx;
Expand Down Expand Up @@ -501,7 +496,7 @@ static int act_redirect_commit

/* Mark this message id as forwarded to the specified destination */
sieve_action_duplicate_mark(senv, dupeid, strlen(dupeid),
ioloop_time + CMD_REDIRECT_DUPLICATE_KEEP);
ioloop_time + svinst->redirect_duplicate_period);

sieve_result_global_log(aenv, "forwarded to <%s>",
str_sanitize(ctx->to_address, 128));
Expand Down
1 change: 1 addition & 0 deletions src/lib-sieve/sieve-common.h
Expand Up @@ -203,6 +203,7 @@ struct sieve_instance {
unsigned int max_redirects;
const struct sieve_address *user_email;
struct sieve_address_source redirect_from;
unsigned int redirect_duplicate_period;
};

/*
Expand Down
2 changes: 2 additions & 0 deletions src/lib-sieve/sieve-config.h
Expand Up @@ -14,4 +14,6 @@

#define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON"

#define DEFAULT_REDIRECT_DUPLICATE_PERIOD (3600 * 12)

#endif
10 changes: 10 additions & 0 deletions src/lib-sieve/sieve-settings.c
Expand Up @@ -206,6 +206,7 @@ void sieve_settings_load
const char *str_setting;
unsigned long long int uint_setting;
size_t size_setting;
sieve_number_t period;

svinst->max_script_size = SIEVE_DEFAULT_MAX_SCRIPT_SIZE;
if ( sieve_setting_get_size_value
Expand All @@ -229,6 +230,15 @@ void sieve_settings_load
svinst->pool, "sieve_redirect_envelope_from",
&svinst->redirect_from);

svinst->redirect_duplicate_period = DEFAULT_REDIRECT_DUPLICATE_PERIOD;
if ( sieve_setting_get_duration_value
(svinst, "sieve_redirect_duplicate_period", &period) ) {
if (period > UINT_MAX)
svinst->redirect_duplicate_period = UINT_MAX;
else
svinst->redirect_duplicate_period = (unsigned int)period;
}

str_setting = sieve_setting_get(svinst, "sieve_user_email");
if ( str_setting != NULL && *str_setting != '\0' ) {
svinst->user_email =
Expand Down

0 comments on commit de4248b

Please sign in to comment.