diff options
author | krion <krion@FreeBSD.org> | 2005-04-29 18:11:53 +0800 |
---|---|---|
committer | krion <krion@FreeBSD.org> | 2005-04-29 18:11:53 +0800 |
commit | b99cd52b97a2599d39c84a25d8a6219036873cdf (patch) | |
tree | 0f6d49ea1bf7b81ceab28b04da1d2fb3ab4d37c6 /mail/exim | |
parent | 791c5f67611c40fbecbd3dc732140cfff9d6cc3c (diff) | |
download | freebsd-ports-gnome-b99cd52b97a2599d39c84a25d8a6219036873cdf.tar.gz freebsd-ports-gnome-b99cd52b97a2599d39c84a25d8a6219036873cdf.tar.zst freebsd-ports-gnome-b99cd52b97a2599d39c84a25d8a6219036873cdf.zip |
Add patches to fix build with mail/libsrs2 support.
Requested by: sheldonh
Diffstat (limited to 'mail/exim')
-rw-r--r-- | mail/exim/files/patch-src_expand.c | 14 | ||||
-rw-r--r-- | mail/exim/files/patch-src_globals.c | 21 | ||||
-rw-r--r-- | mail/exim/files/patch-src_globals.h | 26 | ||||
-rw-r--r-- | mail/exim/files/patch-src_readconf.c | 19 | ||||
-rw-r--r-- | mail/exim/files/patch-src_routers_redirect.c | 127 | ||||
-rw-r--r-- | mail/exim/files/patch-src_routers_redirect.h | 15 | ||||
-rw-r--r-- | mail/exim/files/patch-src_srs.c | 283 | ||||
-rw-r--r-- | mail/exim/files/patch-src_srs.h | 29 |
8 files changed, 534 insertions, 0 deletions
diff --git a/mail/exim/files/patch-src_expand.c b/mail/exim/files/patch-src_expand.c new file mode 100644 index 000000000000..2f8b28e43d1d --- /dev/null +++ b/mail/exim/files/patch-src_expand.c @@ -0,0 +1,14 @@ + +$FreeBSD$ + +--- src/expand.c.orig ++++ src/expand.c +@@ -479,8 +479,6 @@ + { "spool_inodes", vtype_pinodes, (void *)TRUE }, + { "spool_space", vtype_pspace, (void *)TRUE }, + #ifdef EXPERIMENTAL_SRS +- { "srs_db_address", vtype_stringptr, &srs_db_address }, +- { "srs_db_key", vtype_stringptr, &srs_db_key }, + { "srs_orig_recipient", vtype_stringptr, &srs_orig_recipient }, + { "srs_orig_sender", vtype_stringptr, &srs_orig_sender }, + { "srs_recipient", vtype_stringptr, &srs_recipient }, diff --git a/mail/exim/files/patch-src_globals.c b/mail/exim/files/patch-src_globals.c new file mode 100644 index 000000000000..914e28e718c2 --- /dev/null +++ b/mail/exim/files/patch-src_globals.c @@ -0,0 +1,21 @@ + +$FreeBSD$ + +--- src/globals.c.orig ++++ src/globals.c +@@ -1028,9 +1028,12 @@ + uschar *spool_directory = US SPOOL_DIRECTORY + "\0<--------------Space to patch spool_directory->"; + #ifdef EXPERIMENTAL_SRS +-uschar *srs_config = NULL; +-uschar *srs_db_address = NULL; +-uschar *srs_db_key = NULL; ++BOOL srs_alwaysrewrite = FALSE; ++int srs_hashlength = -1; ++int srs_hashmin = -1; ++int srs_maxage = -1; ++uschar *srs_secrets = NULL; ++uschar *srs_separator = NULL; + uschar *srs_orig_recipient = NULL; + uschar *srs_orig_sender = NULL; + uschar *srs_recipient = NULL; diff --git a/mail/exim/files/patch-src_globals.h b/mail/exim/files/patch-src_globals.h new file mode 100644 index 000000000000..76519037157b --- /dev/null +++ b/mail/exim/files/patch-src_globals.h @@ -0,0 +1,26 @@ + +$FreeBSD$ + +--- src/globals.h.orig ++++ src/globals.h +@@ -631,13 +631,16 @@ + extern BOOL split_spool_directory; /* TRUE to use multiple subdirs */ + extern uschar *spool_directory; /* Name of spool directory */ + #ifdef EXPERIMENTAL_SRS +-extern uschar *srs_config; /* SRS config secret:max age:hash length:use timestamp:use hash */ +-extern uschar *srs_db_address; /* SRS db address */ +-extern uschar *srs_db_key; /* SRS db key */ ++extern BOOL srs_alwaysrewrite; /* Rewrite for all domains */ ++extern int srs_hashlength; /* Hash length to generate */ ++extern int srs_hashmin; /* Hash length to check */ ++extern int srs_maxage; /* Max age for SRS address */ ++extern uschar *srs_secrets; /* List of SRS secrets */ ++extern uschar *srs_separator; /* Separator for SRS addresses */ + extern uschar *srs_orig_sender; /* SRS original sender */ + extern uschar *srs_orig_recipient; /* SRS original recipient */ + extern uschar *srs_recipient; /* SRS recipient */ +-extern uschar *srs_status; /* SRS staus */ ++extern uschar *srs_status; /* SRS status */ + #endif + extern int string_datestamp_offset;/* After insertion by string_format */ + extern BOOL strip_excess_angle_brackets; /* Surrounding route-addrs */ diff --git a/mail/exim/files/patch-src_readconf.c b/mail/exim/files/patch-src_readconf.c new file mode 100644 index 000000000000..ae494ae8d8bc --- /dev/null +++ b/mail/exim/files/patch-src_readconf.c @@ -0,0 +1,19 @@ + +$FreeBSD$ + +--- src/readconf.c.orig ++++ src/readconf.c +@@ -333,7 +333,12 @@ + { "split_spool_directory", opt_bool, &split_spool_directory }, + { "spool_directory", opt_stringptr, &spool_directory }, + #ifdef EXPERIMENTAL_SRS +- { "srs_config", opt_stringptr, &srs_config }, ++ { "srs_alwaysrewrite", opt_bool, &srs_alwaysrewrite }, ++ { "srs_hashlength", opt_int, &srs_hashlength }, ++ { "srs_hashmin", opt_int, &srs_hashmin }, ++ { "srs_maxage", opt_int, &srs_maxage }, ++ { "srs_secrets", opt_stringptr, &srs_secrets }, ++ { "srs_separator", opt_stringptr, &srs_separator }, + #endif + { "strip_excess_angle_brackets", opt_bool, &strip_excess_angle_brackets }, + { "strip_trailing_dot", opt_bool, &strip_trailing_dot }, diff --git a/mail/exim/files/patch-src_routers_redirect.c b/mail/exim/files/patch-src_routers_redirect.c new file mode 100644 index 000000000000..8013f2929410 --- /dev/null +++ b/mail/exim/files/patch-src_routers_redirect.c @@ -0,0 +1,127 @@ + +$FreeBSD$ + +--- src/routers/redirect.c.orig ++++ src/routers/redirect.c +@@ -104,12 +104,6 @@ + #ifdef EXPERIMENTAL_SRS + { "srs", opt_stringptr, + (void *)offsetof(redirect_router_options_block, srs) }, +- { "srs_alias", opt_stringptr, +- (void *)offsetof(redirect_router_options_block, srs_alias) }, +- { "srs_condition", opt_stringptr, +- (void *)offsetof(redirect_router_options_block, srs_condition) }, +- { "srs_db", opt_stringptr, +- (void *)offsetof(redirect_router_options_block, srs_db) }, + #endif + { "syntax_errors_text", opt_stringptr, + (void *)offsetof(redirect_router_options_block, syntax_errors_text) }, +@@ -146,9 +140,6 @@ + NULL, /* owngroups */ + #ifdef EXPERIMENTAL_SRS + NULL, /* srs */ +- NULL, /* srs_condition */ +- NULL, /* srs_db */ +- NULL, /* srs_alias */ + #endif + 022, /* modemask */ + RDO_REWRITE, /* bit_options */ +@@ -545,30 +536,26 @@ + #ifdef EXPERIMENTAL_SRS + /* For reverse SRS, fill the srs_recipient expandsion variable, + on failure, return decline/fail as relevant */ +- if(ob->srs != NULL) ++if(ob->srs != NULL) + { +- BOOL usesrs = TRUE; +- +- if(ob->srs_condition != NULL) +- usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL); +- +- if(usesrs) +- if(Ustrcmp(ob->srs, "reverse") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) +- { +- uschar *res; +- int n_srs; ++ if (Ustrcmp(ob->srs, "reverse") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) ++ { ++ uschar *res; ++ int ret; ++ DEBUG(D_route) ++ debug_printf("SRS: (Forward) \n"); + +- srs_orig_recipient = addr->address; +- eximsrs_init(); +- if(ob->srs_db) +- eximsrs_db_set(TRUE, ob->srs_db); +- if((n_srs = eximsrs_reverse(&res, addr->address)) != OK) +- return n_srs; +- srs_recipient = res; +- eximsrs_done(); +- DEBUG(D_any) +- debug_printf("SRS: Recipient '%s' rewritten to '%s'\n", srs_orig_recipient, srs_recipient); +- } ++ srs_orig_recipient = addr->address; ++ eximsrs_init(); ++ ret = eximsrs_reverse(&res, addr->address); ++ if (ret != OK) ++ return ret; ++ srs_recipient = res; ++ eximsrs_done(); ++ DEBUG(D_route) ++ debug_printf("SRS: Recipient '%s' rewritten to '%s'\n", ++ srs_orig_recipient, srs_recipient); ++ } + } + #endif + +@@ -797,33 +784,23 @@ + + #ifdef EXPERIMENTAL_SRS + /* On successful redirection, check for SRS forwarding and adjust sender */ +- if(ob->srs != NULL) ++if(ob->srs != NULL) + { +- BOOL usesrs = TRUE; +- +- if(ob->srs_condition != NULL) +- usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL); +- +- if(usesrs) +- if((Ustrcmp(ob->srs, "forward") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) && !verify) +- { +- uschar *res; +- uschar *usedomain; +- int n_srs; +- +- srs_orig_sender = sender_address; +- eximsrs_init(); +- if(ob->srs_db) +- eximsrs_db_set(FALSE, ob->srs_db); +- +- if(ob->srs_alias != NULL ? (usedomain = expand_string(ob->srs_alias)) == NULL : 1) +- usedomain = deliver_domain; +- +- if((n_srs = eximsrs_forward(&res, sender_address, usedomain)) != OK) +- return n_srs; +- sender_address = res; +- DEBUG(D_any) +- debug_printf("SRS: Sender '%s' rewritten to '%s'\n", srs_orig_sender, sender_address); ++ if ((Ustrcmp(ob->srs, "forward") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) && !verify ) ++ { ++ uschar *res; ++ int ret; ++ DEBUG(D_route) ++ debug_printf("SRS: (Forward) \n"); ++ srs_orig_sender = sender_address; ++ eximsrs_init(); ++ ret = eximsrs_forward(&res, sender_address, deliver_domain); ++ if (ret != OK) ++ return ret; ++ sender_address = res; ++ DEBUG(D_route) ++ debug_printf("SRS: Sender '%s' rewritten to '%s'\n", ++ srs_orig_sender, sender_address); + } + } + #endif diff --git a/mail/exim/files/patch-src_routers_redirect.h b/mail/exim/files/patch-src_routers_redirect.h new file mode 100644 index 000000000000..38c653a5803f --- /dev/null +++ b/mail/exim/files/patch-src_routers_redirect.h @@ -0,0 +1,15 @@ + +$FreeBSD$ + +--- src/routers/redirect.h.orig ++++ src/routers/redirect.h +@@ -35,9 +35,6 @@ + + #ifdef EXPERIMENTAL_SRS + uschar *srs; +- uschar *srs_condition; +- uschar *srs_db; +- uschar *srs_alias; + #endif + + int modemask; diff --git a/mail/exim/files/patch-src_srs.c b/mail/exim/files/patch-src_srs.c new file mode 100644 index 000000000000..34d92e4c897f --- /dev/null +++ b/mail/exim/files/patch-src_srs.c @@ -0,0 +1,283 @@ + +$FreeBSD$ + +--- src/srs.c.orig ++++ src/srs.c +@@ -11,196 +11,116 @@ + #include "exim.h" + #ifdef EXPERIMENTAL_SRS + +-#include <srs_alt.h> ++#include <srs2.h> + #include "srs.h" + +-srs_t *srs = NULL; +-uschar *srs_db_forward = NULL; +-uschar *srs_db_reverse = NULL; ++#define SRS_WARN_UNLESS(x) do { \ ++ int __ret = (x); \ ++ if (__ret != SRS_SUCCESS) \ ++ DEBUG(D_any) \ ++ debug_printf("srs: %s\n", srs_strerror(__ret)); \ ++ } while(0) + ++srs_t *srs = NULL; + + /* srs_init just initialises libsrs and creates (if necessary) + an srs object to use for all srs calls in this instance */ + +-int eximsrs_init() +-{ +- int co; +- uschar *list = srs_config; +- char secret_buf[SRS_MAX_SECRET_LENGTH]; +- char *secret; +- char sbuf[4]; +- char *sbufp; +- int hashlen, maxage; +- +- +- if(!srs) +- { +- /* Check config */ +- if(!srs_config) +- { +- log_write(0, LOG_MAIN | LOG_PANIC, +- "SRS Configuration Error"); +- return DEFER; +- } +- +- /* Get config */ +- co = 0; +- if((secret = string_nextinlist(&list, &co, secret_buf, +- SRS_MAX_SECRET_LENGTH)) == NULL) +- { +- log_write(0, LOG_MAIN | LOG_PANIC, +- "SRS Configuration Error: No secret specified"); +- return DEFER; +- } +- +- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) == NULL) +- maxage = 31; +- else +- maxage = atoi(sbuf); +- if(maxage < 0 || maxage > 365) +- { +- log_write(0, LOG_MAIN | LOG_PANIC, +- "SRS Configuration Error: Invalid maximum timestamp age"); +- return DEFER; +- } +- +- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) == NULL) +- hashlen = 6; +- else +- hashlen = atoi(sbuf); +- if(hashlen < 1 || hashlen > 20) +- { +- log_write(0, LOG_MAIN | LOG_PANIC, +- "SRS Configuration Error: Invalid hash length"); +- return DEFER; +- } +- +- +- if((srs = srs_open(secret, strnlen(secret, SRS_MAX_SECRET_LENGTH), +- maxage, hashlen, hashlen)) == NULL) +- { +- log_write(0, LOG_MAIN | LOG_PANIC, +- "Failed to allocate SRS memory"); +- return DEFER; +- } +- +- +- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) != NULL) +- srs_set_option(srs, SRS_OPTION_USETIMESTAMP, atoi(sbuf)); +- +- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) != NULL) +- srs_set_option(srs, SRS_OPTION_USEHASH, atoi(sbuf)); +- +- DEBUG(D_any) +- debug_printf("SRS initialized\n"); +- } +- +- return OK; +-} +- +- +-int eximsrs_done() ++int ++eximsrs_init() + { +- if(srs) +- srs_close(srs); +- +- srs = NULL; +- +- return OK; +-} ++ char sbuf[1024]; ++ uschar *list; ++ int co; + ++ char *secret; + +-int eximsrs_forward(uschar **result, uschar *orig_sender, uschar *domain) +-{ +- char res[512]; +- int n; ++ if (srs == NULL) { ++ srs = srs_new(); + +- if((n = srs_forward(srs, orig_sender, domain, res, sizeof(res))) & SRS_RESULT_FAIL) +- { +- DEBUG(D_any) +- debug_printf("srs_forward failed (%s, %s): %s\n", orig_sender, domain, srs_geterrormsg(n)); +- return DEFER; +- } ++ if (srs_secrets == NULL) { ++ log_write(0, LOG_MAIN | LOG_PANIC, ++ "SRS: No secrets specified"); ++ return DEFER; ++ } + +- *result = string_copy(res); +- return OK; +-} ++ /* Get config */ ++ list = srs_secrets; + ++ co = 0; ++ while ((secret = string_nextinlist(&list, &co, ++ sbuf, sizeof(sbuf))) != NULL) { ++ SRS_WARN_UNLESS(srs_add_secret(srs, secret)); ++ } + +-int eximsrs_reverse(uschar **result, uschar *address) +-{ +- char res[512]; +- int n; ++ SRS_WARN_UNLESS(srs_set_alwaysrewrite(srs, srs_alwaysrewrite)); ++ if (srs_hashlength != -1) ++ SRS_WARN_UNLESS(srs_set_hashlength(srs, srs_hashlength)); ++ if (srs_hashmin != -1) ++ SRS_WARN_UNLESS(srs_set_hashmin(srs, srs_hashmin)); ++ if (srs_maxage != -1) ++ SRS_WARN_UNLESS(srs_set_maxage(srs, srs_maxage)); ++ if (srs_separator != NULL) ++ SRS_WARN_UNLESS(srs_set_separator(srs, srs_separator[0])); + +- if((n = srs_reverse(srs, address, res, sizeof(res))) & SRS_RESULT_FAIL) +- { +- DEBUG(D_any) +- debug_printf("srs_reverse failed (%s): %s\n", address, srs_geterrormsg(n)); +- if(n == SRS_RESULT_NOTSRS || n == SRS_RESULT_BADSRS) +- return DECLINE; +- if(n == SRS_RESULT_BADHASH || n == SRS_RESULT_BADTIMESTAMP || n == SRS_RESULT_TIMESTAMPEXPIRED) +- return FAIL; +- return DEFER; +- } ++ DEBUG(D_any) ++ debug_printf("SRS initialised\n"); ++ } + +- *result = string_copy(res); +- return OK; ++ return OK; + } + +- +-int eximsrs_db_set(BOOL reverse, uschar *srs_db) ++int ++eximsrs_done() + { +- if(reverse) +- srs_db_reverse = string_copy(srs_db); +- else +- srs_db_forward = string_copy(srs_db); +- +- if(srs_set_db_functions(srs, eximsrs_db_insert, eximsrs_db_lookup) * SRS_RESULT_FAIL) +- return DEFER; +- +- return OK; ++ if (srs != NULL) ++ srs_free(srs); ++ srs = NULL; ++ return OK; + } + +- +-srs_result eximsrs_db_insert(srs_t *srs, char *data, uint data_len, char *result, uint result_len) ++int ++eximsrs_forward(uschar **result, uschar *sender, uschar *domain) + { +- uschar *res; +- char buf[64]; +- +- srs_db_address = string_copyn(data, data_len); +- if(srs_generate_unique_id(srs, srs_db_address, buf, 64) & SRS_RESULT_FAIL) +- return DEFER; +- +- srs_db_key = string_copyn(buf, 16); +- +- if((res = expand_string(srs_db_forward)) == NULL) +- return SRS_RESULT_DBERROR; +- +- if(result_len < 17) +- return SRS_RESULT_DBERROR; ++ char res[1024]; ++ int ret; + +- strncpy(result, srs_db_key, result_len); ++ ret = srs_forward(srs, res, sizeof(res), sender, domain); ++ if (ret != SRS_SUCCESS) { ++ DEBUG(D_any) ++ debug_printf("srs_forward failed (%s, %s): s\n", ++ sender, domain, srs_strerror(ret)); ++ return DEFER; ++ } + +- return SRS_RESULT_OK; ++ *result = string_copy(res); ++ return OK; + } + +- +-srs_result eximsrs_db_lookup(srs_t *srs, char *data, uint data_len, char *result, uint result_len) ++int ++eximsrs_reverse(uschar **result, uschar *sender) + { +- uschar *res; +- +- srs_db_key = string_copyn(data, data_len); +- if((res = expand_string(srs_db_reverse)) == NULL) +- return SRS_RESULT_DBERROR; ++ char res[1024]; ++ int ret; + +- if(Ustrlen(res) >= result_len) +- return SRS_RESULT_ADDRESSTOOLONG; ++ ret = srs_reverse(srs, res, sizeof(res), sender); ++ if (ret != SRS_SUCCESS) { ++ switch (SRS_ERROR_TYPE(ret)) { ++ case SRS_ERRTYPE_CONFIG: ++ /* This should never happen */ ++ return DEFER; ++ case SRS_ERRTYPE_INPUT: ++ /* This should never happen */ ++ return DEFER; ++ case SRS_ERRTYPE_SYNTAX: ++ return DECLINE; ++ case SRS_ERRTYPE_SRS: ++ return FAIL; ++ } ++ } + +- strncpy(result, res, result_len); ++ *result = string_copy(res); + +- return SRS_RESULT_OK; ++ return OK; + } +- +- + #endif +- diff --git a/mail/exim/files/patch-src_srs.h b/mail/exim/files/patch-src_srs.h new file mode 100644 index 000000000000..890cfc7c5edf --- /dev/null +++ b/mail/exim/files/patch-src_srs.h @@ -0,0 +1,29 @@ + +$FreeBSD$ + +--- src/srs.h.orig ++++ src/srs.h +@@ -9,22 +9,17 @@ + License: GPL */ + + #ifndef __SRS_H__ +- + #define __SRS_H__ 1 + + #ifdef EXPERIMENTAL_SRS + + #include "mytypes.h" +-#include <srs_alt.h> ++#include <srs2.h> + + int eximsrs_init(); + int eximsrs_done(); + int eximsrs_forward(uschar **result, uschar *orig_sender, uschar *domain); + int eximsrs_reverse(uschar **result, uschar *address); +-int eximsrs_db(BOOL reverse, uschar *srs_db); +- +-srs_result eximsrs_db_insert(srs_t *srs, char *data, uint data_len, char *result, uint result_len); +-srs_result eximsrs_db_lookup(srs_t *srs, char *data, uint data_len, char *result, uint result_len); + + #endif + |