From f656d13573661ac5a0d4fc49b932a3c961ee3eca Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 3 May 2005 10:02:27 +0000 Subject: [PATCH] Patch from Sieve maintainer for latest vacation updates. --- doc/doc-txt/ChangeLog | 6 ++- doc/doc-txt/README.SIEVE | 33 ++++++++-------- src/src/sieve.c | 82 +++++++++++++++++++++++++++++++--------- 3 files changed, 87 insertions(+), 34 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 20f21b043..f462b6b76 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.130 2005/05/03 08:38:13 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.131 2005/05/03 10:02:27 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -266,6 +266,10 @@ PH/42 Exim no longer gives details of delivery errors for specific addresses in PH/43 $value is now also set for the "else" part of a ${run expansion. +PH/44 Applied patch from the Sieve maintainer: "The vacation draft is still + being worked on, but at least Exim now implements the latest version to + play with." + A note about Exim versions 4.44 and 4.50 ---------------------------------------- diff --git a/doc/doc-txt/README.SIEVE b/doc/doc-txt/README.SIEVE index 53d5b01ed..04383f6e5 100644 --- a/doc/doc-txt/README.SIEVE +++ b/doc/doc-txt/README.SIEVE @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/README.SIEVE,v 1.3 2005/03/29 15:21:57 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/README.SIEVE,v 1.4 2005/05/03 10:02:27 ph10 Exp $ Notes on the Sieve implementation for Exim @@ -22,7 +22,7 @@ Exim Implementation The Exim Sieve implementation offers the core as defined by RFC 3028, the "envelope" (RFC 3028), the "fileinto" (RFC 3028), the "copy" (RFC 3894) -and the "vacation" (draft-showalter-sieve-vacation-05.txt) extension, +and the "vacation" (draft-ietf-sieve-vacation-01.txt) extension, the "i;ascii-numeric" comparator, but not the "reject" extension. Exim does not support MDMs, so adding it just to the sieve filter makes little sense. @@ -338,22 +338,23 @@ extension. vacation-command = "vacation" { vacation-options } vacation-options = [":days" number] - [":addresses" string-list] [":subject" string] + [":from" string] + [":addresses" string-list] [":mime"] + [":handle" string] command =/ vacation-command Semantics Of ":mime" -RFC 3028 does not specify how strings using MIME parts are used to compose -messages. The vacation draft refers to RFC 3028 and does not specify it -either. As a result, different implementations generate different mails. -The Exim Sieve implementation splits the reason into header and body. -It adds the header to the mail header and uses the body as mail body. -Be aware, that other imlementations compose a multipart structure with -the reason as only part. Both conform to the specification (or lack -thereof). +The draft does not specify how strings using MIME entities are used +to compose messages. As a result, different implementations generate +different mails. The Exim Sieve implementation splits the reason into +header and body. It adds the header to the mail header and uses the body +as mail body. Be aware, that other imlementations compose a multipart +structure with the reason as only part. Both conform to the specification +(or lack thereof). Semantics Of Not Using ":mime" @@ -378,15 +379,15 @@ to subscribe a third party to any mailing list, either to annoy the user or to declare spam as legitimate mail by proving to use opt-in. The draft specifies to use "Re: " in front of the subject, but this implementation uses "Auto: ", as suggested in -the current draft concerning automatic mail responses. +RFC 3834, section 3.1.5. Rate Limiting Responses -This implementation hashes the reason, specified subject, ":mime" -option and ":addresses" option and uses the hex string representation -as filename within the "sieve_vacation_directory" to store the recipient -addresses for this vacation parameter set. +In absence of a handle, this implementation hashes the reason, +":subject" option, ":mime" option and ":from" option and uses the hex +string representation as filename within the "sieve_vacation_directory" +to store the recipient addresses for this vacation parameter set. The draft specifies that sites may define a minimum ":days" value than 1. This implementation uses 1. The maximum value MUST greater than 7, diff --git a/src/src/sieve.c b/src/src/sieve.c index cf87dfb1c..2a680e175 100644 --- a/src/src/sieve.c +++ b/src/src/sieve.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/sieve.c,v 1.10 2005/04/07 10:02:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/sieve.c,v 1.11 2005/05/03 10:02:27 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2364,17 +2364,21 @@ while (*filter->pc) /* vacation-command = "vacation" { vacation-options } ";" vacation-options = [":days" number] - [":addresses" string-list] [":subject" string] + [":from" string] + [":addresses" string-list] [":mime"] + [":handle" string] */ int m; unsigned long days; - struct String *addresses; struct String subject; + struct String from; + struct String *addresses; int reason_is_mime; string_item *aliases; + struct String handle; struct String reason; if (!filter->require_vacation) @@ -2392,11 +2396,15 @@ while (*filter->pc) filter->vacation_ran=1; } days=VACATION_MIN_DAYS>7 ? VACATION_MIN_DAYS : 7; - addresses=(struct String*)0; subject.character=(uschar*)0; subject.length=-1; + from.character=(uschar*)0; + from.length=-1; + addresses=(struct String*)0; aliases=NULL; reason_is_mime=0; + handle.character=(uschar*)0; + handle.length=-1; for (;;) { if (parse_white(filter)==-1) return -1; @@ -2407,6 +2415,43 @@ while (*filter->pc) if (daysVACATION_MAX_DAYS) days=VACATION_MAX_DAYS; } + else if (parse_identifier(filter,CUS ":subject")==1) + { + if (parse_white(filter)==-1) return -1; + if ((m=parse_string(filter,&subject))!=1) + { + if (m==0) filter->errmsg=CUS "subject string expected"; + return -1; + } + } + else if (parse_identifier(filter,CUS ":from")==1) + { + int start, end, domain; + uschar *error,*ss; + + if (parse_white(filter)==-1) return -1; + if ((m=parse_string(filter,&from))!=1) + { + if (m==0) filter->errmsg=CUS "from string expected"; + return -1; + } + if (from.length>0) + { + ss = parse_extract_address(from.character, &error, &start, &end, &domain, + FALSE); + if (ss == NULL) + { + filter->errmsg=string_sprintf("malformed address \"%s\" in " + "Sieve filter: %s", from.character, error); + return -1; + } + } + else + { + filter->errmsg=CUS "empty :from address in Sieve filter"; + return -1; + } + } else if (parse_identifier(filter,CUS ":addresses")==1) { struct String *a; @@ -2429,17 +2474,17 @@ while (*filter->pc) aliases=new; } } - else if (parse_identifier(filter,CUS ":subject")==1) + else if (parse_identifier(filter,CUS ":mime")==1) + reason_is_mime=1; + else if (parse_identifier(filter,CUS ":handle")==1) { if (parse_white(filter)==-1) return -1; - if ((m=parse_string(filter,&subject))!=1) + if ((m=parse_string(filter,&from))!=1) { - if (m==0) filter->errmsg=CUS "subject string expected"; + if (m==0) filter->errmsg=CUS "handle string expected"; return -1; } } - else if (parse_identifier(filter,CUS ":mime")==1) - reason_is_mime=1; else break; } if (parse_white(filter)==-1) return -1; @@ -2457,7 +2502,6 @@ while (*filter->pc) uschar *buffer; int buffer_capacity; struct String key; - struct String *a; md5 base; uschar digest[16]; uschar hexdigest[33]; @@ -2477,14 +2521,15 @@ while (*filter->pc) key.character=(uschar*)0; key.length=0; capacity=0; - if (subject.length!=-1) key.character=string_cat(key.character,&capacity,&key.length,subject.character,subject.length); - key.character=string_cat(key.character,&capacity,&key.length,reason_is_mime?US"1":US"0",1); - key.character=string_cat(key.character,&capacity,&key.length,reason.character,reason.length); - if (addresses!=(struct String*)0) for (a=addresses; a->length!=-1; ++a) + if (handle.length==-1) { - key.character=string_cat(key.character,&capacity,&key.length,US":",1); - key.character=string_cat(key.character,&capacity,&key.length,a->character,a->length); + if (subject.length!=-1) key.character=string_cat(key.character,&capacity,&key.length,subject.character,subject.length); + if (from.length!=-1) key.character=string_cat(key.character,&capacity,&key.length,from.character,from.length); + key.character=string_cat(key.character,&capacity,&key.length,reason_is_mime?US"1":US"0",1); + key.character=string_cat(key.character,&capacity,&key.length,reason.character,reason.length); } + else + key=handle; md5_start(&base); md5_end(&base, key.character, key.length, digest); for (i = 0; i < 16; i++) sprintf(CS (hexdigest+2*i), "%02X", digest[i]); @@ -2526,7 +2571,10 @@ while (*filter->pc) addr->reply = store_get(sizeof(reply_item)); memset(addr->reply,0,sizeof(reply_item)); /* XXX */ addr->reply->to = string_copy(sender_address); - addr->reply->from = expand_string(US"$local_part@$domain"); + if (from.length==-1) + addr->reply->from = expand_string(US"$local_part@$domain"); + else + addr->reply->from = from.character; /* Allocation is larger than neccessary, but enough even for split MIME words */ buffer_capacity=16+4*subject.length; buffer=store_get(buffer_capacity); -- 2.25.1