|
Lines 1-596
Link Here
|
| 1 |
diff -u scripts/MakeLinks scripts/MakeLinks |
|
|
| 2 |
--- scripts/MakeLinks Sat Jul 17 11:12:00 2004 |
| 3 |
+++ scripts/MakeLinks Sat Jul 17 11:34:48 2004 |
| 4 |
@@ -187,7 +187,7 @@ |
| 5 |
ln -s ../src/osfunctions.h osfunctions.h |
| 6 |
ln -s ../src/spam.h spam.h |
| 7 |
ln -s ../src/spf.h spf.h |
| 8 |
-ln -s ../src/srs.h srs.h |
| 9 |
+ln -s ../src/srs.h srs.h |
| 10 |
ln -s ../src/store.h store.h |
| 11 |
ln -s ../src/structs.h structs.h |
| 12 |
ln -s ../src/tnef.h tnef.h |
| 13 |
diff -u src/expand.c src/expand.c |
| 14 |
--- src/expand.c Sat Jul 17 11:12:00 2004 |
| 15 |
+++ src/expand.c Sat Jul 17 11:37:42 2004 |
| 16 |
@@ -454,8 +454,6 @@ |
| 17 |
#endif |
| 18 |
{ "spool_directory", vtype_stringptr, &spool_directory }, |
| 19 |
#ifdef SRS |
| 20 |
- { "srs_db_address", vtype_stringptr, &srs_db_address }, |
| 21 |
- { "srs_db_key", vtype_stringptr, &srs_db_key }, |
| 22 |
{ "srs_orig_recipient", vtype_stringptr, &srs_orig_recipient }, |
| 23 |
{ "srs_orig_sender", vtype_stringptr, &srs_orig_sender }, |
| 24 |
{ "srs_recipient", vtype_stringptr, &srs_recipient }, |
| 25 |
diff -u src/globals.c src/globals.c |
| 26 |
--- src/globals.c Sat Jul 17 11:12:00 2004 |
| 27 |
+++ src/globals.c Sat Jul 17 11:38:52 2004 |
| 28 |
@@ -987,9 +987,12 @@ |
| 29 |
uschar *spool_directory = US SPOOL_DIRECTORY |
| 30 |
"\0<--------------Space to patch spool_directory->"; |
| 31 |
#ifdef SRS |
| 32 |
-uschar *srs_config = NULL; |
| 33 |
-uschar *srs_db_address = NULL; |
| 34 |
-uschar *srs_db_key = NULL; |
| 35 |
+BOOL srs_alwaysrewrite = FALSE; |
| 36 |
+int srs_hashlength = -1; |
| 37 |
+int srs_hashmin = -1; |
| 38 |
+int srs_maxage = -1; |
| 39 |
+uschar *srs_secrets = NULL; |
| 40 |
+uschar *srs_separator = NULL; |
| 41 |
uschar *srs_orig_recipient = NULL; |
| 42 |
uschar *srs_orig_sender = NULL; |
| 43 |
uschar *srs_recipient = NULL; |
| 44 |
diff -u src/globals.h src/globals.h |
| 45 |
--- src/globals.h Sat Jul 17 11:12:00 2004 |
| 46 |
+++ src/globals.h Sat Jul 17 11:43:06 2004 |
| 47 |
@@ -596,13 +596,16 @@ |
| 48 |
#endif |
| 49 |
extern uschar *spool_directory; /* Name of spool directory */ |
| 50 |
#ifdef SRS |
| 51 |
-extern uschar *srs_config; /* SRS config secret:max age:hash length:use timestamp:use hash */ |
| 52 |
-extern uschar *srs_db_address; /* SRS db address */ |
| 53 |
-extern uschar *srs_db_key; /* SRS db key */ |
| 54 |
-extern uschar *srs_orig_sender; /* SRS original sender */ |
| 55 |
-extern uschar *srs_orig_recipient; /* SRS original recipient */ |
| 56 |
-extern uschar *srs_recipient; /* SRS recipient */ |
| 57 |
-extern uschar *srs_status; /* SRS staus */ |
| 58 |
+extern BOOL srs_alwaysrewrite; /* Rewrite for all domains */ |
| 59 |
+extern int srs_hashlength; /* Hash length to generate */ |
| 60 |
+extern int srs_hashmin; /* Hash length to check */ |
| 61 |
+extern int srs_maxage; /* Max age for SRS address */ |
| 62 |
+extern uschar *srs_secrets; /* List of SRS secrets */ |
| 63 |
+extern uschar *srs_separator; /* Separator for SRS addresses */ |
| 64 |
+extern uschar *srs_orig_sender; /* SRS original sender */ |
| 65 |
+extern uschar *srs_orig_recipient; /* SRS original recipient */ |
| 66 |
+extern uschar *srs_recipient; /* SRS recipient */ |
| 67 |
+extern uschar *srs_status; /* SRS status */ |
| 68 |
#endif |
| 69 |
extern int string_datestamp_offset;/* After insertion by string_format */ |
| 70 |
extern BOOL strip_excess_angle_brackets; /* Surrounding route-addrs */ |
| 71 |
diff -u src/readconf.c src/readconf.c |
| 72 |
--- src/readconf.c Sat Jul 17 11:12:00 2004 |
| 73 |
+++ src/readconf.c Sat Jul 17 11:44:21 2004 |
| 74 |
@@ -325,7 +325,12 @@ |
| 75 |
{ "split_spool_directory", opt_bool, &split_spool_directory }, |
| 76 |
{ "spool_directory", opt_stringptr, &spool_directory }, |
| 77 |
#ifdef SRS |
| 78 |
- { "srs_config", opt_stringptr, &srs_config }, |
| 79 |
+ { "srs_alwaysrewrite", opt_bool, &srs_alwaysrewrite }, |
| 80 |
+ { "srs_hashlength", opt_int, &srs_hashlength }, |
| 81 |
+ { "srs_hashmin", opt_int, &srs_hashmin }, |
| 82 |
+ { "srs_maxage", opt_int, &srs_maxage }, |
| 83 |
+ { "srs_secrets", opt_stringptr, &srs_secrets }, |
| 84 |
+ { "srs_separator", opt_stringptr, &srs_separator }, |
| 85 |
#endif |
| 86 |
{ "strip_excess_angle_brackets", opt_bool, &strip_excess_angle_brackets }, |
| 87 |
{ "strip_trailing_dot", opt_bool, &strip_trailing_dot }, |
| 88 |
diff -u src/routers/redirect.c src/routers/redirect.c |
| 89 |
--- src/routers/redirect.c Sat Jul 17 11:12:00 2004 |
| 90 |
+++ src/routers/redirect.c Sat Jul 17 12:26:47 2004 |
| 91 |
@@ -98,13 +98,7 @@ |
| 92 |
(void *)offsetof(redirect_router_options_block, skip_syntax_errors) }, |
| 93 |
#ifdef SRS |
| 94 |
{ "srs", opt_stringptr, |
| 95 |
- (void *)offsetof(redirect_router_options_block, srs) }, |
| 96 |
- { "srs_alias", opt_stringptr, |
| 97 |
- (void *)offsetof(redirect_router_options_block, srs_alias) }, |
| 98 |
- { "srs_condition", opt_stringptr, |
| 99 |
- (void *)offsetof(redirect_router_options_block, srs_condition) }, |
| 100 |
- { "srs_db", opt_stringptr, |
| 101 |
- (void *)offsetof(redirect_router_options_block, srs_db) }, |
| 102 |
+ (void *)offsetof(redirect_router_options_block, srs) }, |
| 103 |
#endif |
| 104 |
{ "syntax_errors_text", opt_stringptr, |
| 105 |
(void *)offsetof(redirect_router_options_block, syntax_errors_text) }, |
| 106 |
@@ -141,9 +135,6 @@ |
| 107 |
NULL, /* owngroups */ |
| 108 |
#ifdef SRS |
| 109 |
NULL, /* srs */ |
| 110 |
- NULL, /* srs_condition */ |
| 111 |
- NULL, /* srs_db */ |
| 112 |
- NULL, /* srs_alias */ |
| 113 |
#endif |
| 114 |
022, /* modemask */ |
| 115 |
RDO_REWRITE, /* bit_options */ |
| 116 |
@@ -538,39 +532,33 @@ |
| 117 |
ugid.gid_set = TRUE; |
| 118 |
} |
| 119 |
|
| 120 |
- |
| 121 |
#ifdef SRS |
| 122 |
/* For reverse SRS, fill the srs_recipient expandsion variable, |
| 123 |
on failure, return decline/fail as relevant */ |
| 124 |
|
| 125 |
- if(ob->srs != NULL) |
| 126 |
+if (ob->srs != NULL) |
| 127 |
{ |
| 128 |
- BOOL usesrs = TRUE; |
| 129 |
- |
| 130 |
- if(ob->srs_condition != NULL) |
| 131 |
- usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL); |
| 132 |
- |
| 133 |
- if(usesrs) |
| 134 |
- if(Ustrcmp(ob->srs, "reverse") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) |
| 135 |
- { |
| 136 |
- uschar *res; |
| 137 |
- int n_srs; |
| 138 |
- |
| 139 |
- srs_orig_recipient = addr->address; |
| 140 |
- eximsrs_init(); |
| 141 |
- if(ob->srs_db) |
| 142 |
- eximsrs_db_set(TRUE, ob->srs_db); |
| 143 |
- if((n_srs = eximsrs_reverse(&res, addr->address)) != OK) |
| 144 |
- return n_srs; |
| 145 |
- srs_recipient = res; |
| 146 |
- eximsrs_done(); |
| 147 |
- DEBUG(D_any) |
| 148 |
- debug_printf("SRS: Recipient '%s' rewriteen to '%s'\n", srs_orig_recipient, srs_recipient); |
| 149 |
- } |
| 150 |
+ if (Ustrcmp(ob->srs, "reverse") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) |
| 151 |
+ { |
| 152 |
+ uschar *res; |
| 153 |
+ int ret; |
| 154 |
+ DEBUG(D_route) |
| 155 |
+ debug_printf("SRS: (Forward) \n"); |
| 156 |
+ |
| 157 |
+ srs_orig_recipient = addr->address; |
| 158 |
+ eximsrs_init(); |
| 159 |
+ ret = eximsrs_reverse(&res, addr->address); |
| 160 |
+ if (ret != OK) |
| 161 |
+ return ret; |
| 162 |
+ srs_recipient = res; |
| 163 |
+ eximsrs_done(); |
| 164 |
+ DEBUG(D_route) |
| 165 |
+ debug_printf("SRS: Recipient '%s' rewritten to '%s'\n", |
| 166 |
+ srs_orig_recipient, srs_recipient); |
| 167 |
+ } |
| 168 |
} |
| 169 |
#endif |
| 170 |
|
| 171 |
- |
| 172 |
/* Call the function that interprets redirection data, either inline or from a |
| 173 |
file. This is a separate function so that the system filter can use it. It will |
| 174 |
run the function in a subprocess if necessary. If qualify_preserve_domain is |
| 175 |
@@ -798,33 +789,23 @@ |
| 176 |
#ifdef SRS |
| 177 |
/* On successful redirection, check for SRS forwarding and adjust sender */ |
| 178 |
|
| 179 |
- if(ob->srs != NULL) |
| 180 |
+if (ob->srs != NULL) |
| 181 |
{ |
| 182 |
- BOOL usesrs = TRUE; |
| 183 |
- |
| 184 |
- if(ob->srs_condition != NULL) |
| 185 |
- usesrs = expand_check_condition(ob->srs_condition, "srs_condition expansion failed", NULL); |
| 186 |
- |
| 187 |
- if(usesrs) |
| 188 |
- if((Ustrcmp(ob->srs, "forward") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) && !verify) |
| 189 |
- { |
| 190 |
- uschar *res; |
| 191 |
- uschar *usedomain; |
| 192 |
- int n_srs; |
| 193 |
- |
| 194 |
- srs_orig_sender = sender_address; |
| 195 |
- eximsrs_init(); |
| 196 |
- if(ob->srs_db) |
| 197 |
- eximsrs_db_set(FALSE, ob->srs_db); |
| 198 |
- |
| 199 |
- if(ob->srs_alias != NULL ? (usedomain = expand_string(ob->srs_alias)) == NULL : 1) |
| 200 |
- usedomain = deliver_domain; |
| 201 |
- |
| 202 |
- if((n_srs = eximsrs_forward(&res, sender_address, usedomain)) != OK) |
| 203 |
- return n_srs; |
| 204 |
- sender_address = res; |
| 205 |
- DEBUG(D_any) |
| 206 |
- debug_printf("SRS: Sender '%s' rewritten to '%s'\n", srs_orig_sender, sender_address); |
| 207 |
+ if ((Ustrcmp(ob->srs, "forward") == 0 || Ustrcmp(ob->srs, "reverseandforward") == 0) && !verify ) |
| 208 |
+ { |
| 209 |
+ uschar *res; |
| 210 |
+ int ret; |
| 211 |
+ DEBUG(D_route) |
| 212 |
+ debug_printf("SRS: (Forward) \n"); |
| 213 |
+ srs_orig_sender = sender_address; |
| 214 |
+ eximsrs_init(); |
| 215 |
+ ret = eximsrs_forward(&res, sender_address, deliver_domain); |
| 216 |
+ if (ret != OK) |
| 217 |
+ return ret; |
| 218 |
+ sender_address = res; |
| 219 |
+ DEBUG(D_route) |
| 220 |
+ debug_printf("SRS: Sender '%s' rewritten to '%s'\n", |
| 221 |
+ srs_orig_sender, sender_address); |
| 222 |
} |
| 223 |
} |
| 224 |
#endif |
| 225 |
diff -u src/routers/redirect.h src/routers/redirect.h |
| 226 |
--- src/routers/redirect.h Sat Jul 17 11:12:00 2004 |
| 227 |
+++ src/routers/redirect.h Sat Jul 17 11:55:47 2004 |
| 228 |
@@ -33,9 +33,6 @@ |
| 229 |
|
| 230 |
#ifdef SRS |
| 231 |
uschar *srs; |
| 232 |
- uschar *srs_condition; |
| 233 |
- uschar *srs_db; |
| 234 |
- uschar *srs_alias; |
| 235 |
#endif |
| 236 |
|
| 237 |
int modemask; |
| 238 |
diff -u src/srs.c src/srs.c |
| 239 |
--- src/srs.c Sat Jul 17 11:12:00 2004 |
| 240 |
+++ src/srs.c Sat Jul 17 12:28:31 2004 |
| 241 |
@@ -5,205 +5,127 @@ |
| 242 |
/* This file is an extension to Exim and is not part of the standard |
| 243 |
Exim distribution */ |
| 244 |
|
| 245 |
-/* (c)2004 Miles Wilton <miles@mirtol.com> */ |
| 246 |
+/* (c) 2004 Shevek |
| 247 |
+ * Based on work by Miles Wilton <miles@mirtol.com> |
| 248 |
+ * Updated by Shevek to use libsrs2 |
| 249 |
+ * Sorry Miles, I was in a roaring hurry, but we still need the |
| 250 |
+ * help! |
| 251 |
+ */ |
| 252 |
|
| 253 |
/* License: GPL */ |
| 254 |
|
| 255 |
+#include "exim.h" |
| 256 |
|
| 257 |
#ifdef SRS |
| 258 |
|
| 259 |
-#include <srs_alt.h> |
| 260 |
+#include <srs2.h> |
| 261 |
|
| 262 |
-#include "exim.h" |
| 263 |
#include "srs.h" |
| 264 |
|
| 265 |
-srs_t *srs = NULL; |
| 266 |
-uschar *srs_db_forward = NULL; |
| 267 |
-uschar *srs_db_reverse = NULL; |
| 268 |
+#define SRS_WARN_UNLESS(x) do { \ |
| 269 |
+ int __ret = (x); \ |
| 270 |
+ if (__ret != SRS_SUCCESS) \ |
| 271 |
+ DEBUG(D_any) \ |
| 272 |
+ debug_printf("srs: %s\n", srs_strerror(__ret)); \ |
| 273 |
+ } while(0) |
| 274 |
+ |
| 275 |
+srs_t *srs = NULL; |
| 276 |
+ |
| 277 |
+int |
| 278 |
+eximsrs_init() |
| 279 |
+{ |
| 280 |
+ char sbuf[1024]; |
| 281 |
+ uschar *list; |
| 282 |
+ int co; |
| 283 |
+ |
| 284 |
+ char *secret; |
| 285 |
+ |
| 286 |
+ if (srs == NULL) { |
| 287 |
+ srs = srs_new(); |
| 288 |
+ |
| 289 |
+ if (srs_secrets == NULL) { |
| 290 |
+ log_write(0, LOG_MAIN | LOG_PANIC, |
| 291 |
+ "SRS: No secrets specified"); |
| 292 |
+ return DEFER; |
| 293 |
+ } |
| 294 |
+ |
| 295 |
+ /* Get config */ |
| 296 |
+ list = srs_secrets; |
| 297 |
+ |
| 298 |
+ co = 0; |
| 299 |
+ while ((secret = string_nextinlist(&list, &co, |
| 300 |
+ sbuf, sizeof(sbuf))) != NULL) { |
| 301 |
+ SRS_WARN_UNLESS(srs_add_secret(srs, secret)); |
| 302 |
+ } |
| 303 |
+ |
| 304 |
+ SRS_WARN_UNLESS(srs_set_alwaysrewrite(srs, srs_alwaysrewrite)); |
| 305 |
+ if (srs_hashlength != -1) |
| 306 |
+ SRS_WARN_UNLESS(srs_set_hashlength(srs, srs_hashlength)); |
| 307 |
+ if (srs_hashmin != -1) |
| 308 |
+ SRS_WARN_UNLESS(srs_set_hashmin(srs, srs_hashmin)); |
| 309 |
+ if (srs_maxage != -1) |
| 310 |
+ SRS_WARN_UNLESS(srs_set_maxage(srs, srs_maxage)); |
| 311 |
+ if (srs_separator != NULL) |
| 312 |
+ SRS_WARN_UNLESS(srs_set_separator(srs, srs_separator[0])); |
| 313 |
+ |
| 314 |
+ DEBUG(D_any) |
| 315 |
+ debug_printf("SRS initialised\n"); |
| 316 |
+ } |
| 317 |
+ |
| 318 |
+ return OK; |
| 319 |
+} |
| 320 |
+ |
| 321 |
+int |
| 322 |
+eximsrs_done() |
| 323 |
+{ |
| 324 |
+ if (srs != NULL) |
| 325 |
+ srs_free(srs); |
| 326 |
+ srs = NULL; |
| 327 |
+ return OK; |
| 328 |
+} |
| 329 |
+ |
| 330 |
+int |
| 331 |
+eximsrs_forward(uschar **result, uschar *sender, uschar *domain) |
| 332 |
+{ |
| 333 |
+ char res[1024]; |
| 334 |
+ int ret; |
| 335 |
+ |
| 336 |
+ ret = srs_forward(srs, res, sizeof(res), sender, domain); |
| 337 |
+ if (ret != SRS_SUCCESS) { |
| 338 |
+ DEBUG(D_any) |
| 339 |
+ debug_printf("srs_forward failed (%s, %s): %s\n", |
| 340 |
+ sender, domain, srs_strerror(ret)); |
| 341 |
+ return DEFER; |
| 342 |
+ } |
| 343 |
+ |
| 344 |
+ *result = string_copy(res); |
| 345 |
+ return OK; |
| 346 |
+} |
| 347 |
+ |
| 348 |
+int |
| 349 |
+eximsrs_reverse(uschar **result, uschar *sender) |
| 350 |
+{ |
| 351 |
+ char res[1024]; |
| 352 |
+ int ret; |
| 353 |
+ |
| 354 |
+ ret = srs_reverse(srs, res, sizeof(res), sender); |
| 355 |
+ if (ret != SRS_SUCCESS) { |
| 356 |
+ switch (SRS_ERROR_TYPE(ret)) { |
| 357 |
+ case SRS_ERRTYPE_CONFIG: |
| 358 |
+ /* This should never happen */ |
| 359 |
+ return DEFER; |
| 360 |
+ case SRS_ERRTYPE_INPUT: |
| 361 |
+ /* This should never happen */ |
| 362 |
+ return DEFER; |
| 363 |
+ case SRS_ERRTYPE_SYNTAX: |
| 364 |
+ return DECLINE; |
| 365 |
+ case SRS_ERRTYPE_SRS: |
| 366 |
+ return FAIL; |
| 367 |
+ } |
| 368 |
+ } |
| 369 |
|
| 370 |
+ *result = string_copy(res); |
| 371 |
|
| 372 |
-/* srs_init just initialises libsrs and creates (if necessary) |
| 373 |
- an srs object to use for all srs calls in this instance */ |
| 374 |
- |
| 375 |
-int eximsrs_init() |
| 376 |
-{ |
| 377 |
- int co; |
| 378 |
- uschar *list = srs_config; |
| 379 |
- char secret_buf[SRS_MAX_SECRET_LENGTH]; |
| 380 |
- char *secret; |
| 381 |
- char sbuf[4]; |
| 382 |
- char *sbufp; |
| 383 |
- int hashlen, maxage; |
| 384 |
- |
| 385 |
- |
| 386 |
- if(!srs) |
| 387 |
- { |
| 388 |
- // Check config |
| 389 |
- if(!srs_config) |
| 390 |
- { |
| 391 |
- log_write(0, LOG_MAIN | LOG_PANIC, |
| 392 |
- "SRS Configuration Error"); |
| 393 |
- return DEFER; |
| 394 |
- } |
| 395 |
- |
| 396 |
- // Get config |
| 397 |
- co = 0; |
| 398 |
- if((secret = string_nextinlist(&list, &co, secret_buf, |
| 399 |
- SRS_MAX_SECRET_LENGTH)) == NULL) |
| 400 |
- { |
| 401 |
- log_write(0, LOG_MAIN | LOG_PANIC, |
| 402 |
- "SRS Configuration Error: No secret specified"); |
| 403 |
- return DEFER; |
| 404 |
- } |
| 405 |
- |
| 406 |
- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) == NULL) |
| 407 |
- maxage = 31; |
| 408 |
- else |
| 409 |
- maxage = atoi(sbuf); |
| 410 |
- if(maxage < 0 || maxage > 365) |
| 411 |
- { |
| 412 |
- log_write(0, LOG_MAIN | LOG_PANIC, |
| 413 |
- "SRS Configuration Error: Invalid maximum timestamp age"); |
| 414 |
- return DEFER; |
| 415 |
- } |
| 416 |
- |
| 417 |
- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) == NULL) |
| 418 |
- hashlen = 6; |
| 419 |
- else |
| 420 |
- hashlen = atoi(sbuf); |
| 421 |
- if(hashlen < 1 || hashlen > 20) |
| 422 |
- { |
| 423 |
- log_write(0, LOG_MAIN | LOG_PANIC, |
| 424 |
- "SRS Configuration Error: Invalid hash length"); |
| 425 |
- return DEFER; |
| 426 |
- } |
| 427 |
- |
| 428 |
- |
| 429 |
- if((srs = srs_open(secret, strnlen(secret, SRS_MAX_SECRET_LENGTH), |
| 430 |
- maxage, hashlen, hashlen)) == NULL) |
| 431 |
- { |
| 432 |
- log_write(0, LOG_MAIN | LOG_PANIC, |
| 433 |
- "Failed to allocate SRS memory"); |
| 434 |
- return DEFER; |
| 435 |
- } |
| 436 |
- |
| 437 |
- |
| 438 |
- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) != NULL) |
| 439 |
- srs_set_option(srs, SRS_OPTION_USETIMESTAMP, atoi(sbuf)); |
| 440 |
- |
| 441 |
- if((sbufp = string_nextinlist(&list, &co, sbuf, sizeof(sbuf))) != NULL) |
| 442 |
- srs_set_option(srs, SRS_OPTION_USEHASH, atoi(sbuf)); |
| 443 |
- |
| 444 |
- DEBUG(D_any) |
| 445 |
- debug_printf("SRS initialized\n"); |
| 446 |
- } |
| 447 |
- |
| 448 |
- return OK; |
| 449 |
-} |
| 450 |
- |
| 451 |
- |
| 452 |
-int eximsrs_done() |
| 453 |
-{ |
| 454 |
- if(srs) |
| 455 |
- srs_close(srs); |
| 456 |
- |
| 457 |
- srs = NULL; |
| 458 |
- |
| 459 |
- return OK; |
| 460 |
-} |
| 461 |
- |
| 462 |
- |
| 463 |
-int eximsrs_forward(uschar **result, uschar *orig_sender, uschar *domain) |
| 464 |
-{ |
| 465 |
- char res[512]; |
| 466 |
- int n; |
| 467 |
- |
| 468 |
- if((n = srs_forward(srs, orig_sender, domain, res, sizeof(res))) & SRS_RESULT_FAIL) |
| 469 |
- { |
| 470 |
- DEBUG(D_any) |
| 471 |
- debug_printf("srs_forward failed (%s, %s): %s\n", orig_sender, domain, srs_geterrormsg(n)); |
| 472 |
- return DEFER; |
| 473 |
- } |
| 474 |
- |
| 475 |
- *result = string_copy(res); |
| 476 |
- return OK; |
| 477 |
-} |
| 478 |
- |
| 479 |
- |
| 480 |
-int eximsrs_reverse(uschar **result, uschar *address) |
| 481 |
-{ |
| 482 |
- char res[512]; |
| 483 |
- int n; |
| 484 |
- |
| 485 |
- if((n = srs_reverse(srs, address, res, sizeof(res))) & SRS_RESULT_FAIL) |
| 486 |
- { |
| 487 |
- DEBUG(D_any) |
| 488 |
- debug_printf("srs_reverse failed (%s): %s\n", address, srs_geterrormsg(n)); |
| 489 |
- if(n == SRS_RESULT_NOTSRS || n == SRS_RESULT_BADSRS) |
| 490 |
- return DECLINE; |
| 491 |
- if(n == SRS_RESULT_BADHASH || n == SRS_RESULT_BADTIMESTAMP || n == SRS_RESULT_TIMESTAMPEXPIRED) |
| 492 |
- return FAIL; |
| 493 |
- return DEFER; |
| 494 |
- } |
| 495 |
- |
| 496 |
- *result = string_copy(res); |
| 497 |
- return OK; |
| 498 |
+ return OK; |
| 499 |
} |
| 500 |
- |
| 501 |
- |
| 502 |
-int eximsrs_db_set(BOOL reverse, uschar *srs_db) |
| 503 |
-{ |
| 504 |
- if(reverse) |
| 505 |
- srs_db_reverse = string_copy(srs_db); |
| 506 |
- else |
| 507 |
- srs_db_forward = string_copy(srs_db); |
| 508 |
- |
| 509 |
- if(srs_set_db_functions(srs, eximsrs_db_insert, eximsrs_db_lookup) * SRS_RESULT_FAIL) |
| 510 |
- return DEFER; |
| 511 |
- |
| 512 |
- return OK; |
| 513 |
-} |
| 514 |
- |
| 515 |
- |
| 516 |
-srs_result eximsrs_db_insert(srs_t *srs, char *data, uint data_len, char *result, uint result_len) |
| 517 |
-{ |
| 518 |
- uschar *res; |
| 519 |
- char buf[64]; |
| 520 |
- |
| 521 |
- srs_db_address = string_copyn(data, data_len); |
| 522 |
- if(srs_generate_unique_id(srs, srs_db_address, buf, 64) & SRS_RESULT_FAIL) |
| 523 |
- return DEFER; |
| 524 |
- |
| 525 |
- srs_db_key = string_copyn(buf, 16); |
| 526 |
- |
| 527 |
- if((res = expand_string(srs_db_forward)) == NULL) |
| 528 |
- return SRS_RESULT_DBERROR; |
| 529 |
- |
| 530 |
- if(result_len < 17) |
| 531 |
- return SRS_RESULT_DBERROR; |
| 532 |
- |
| 533 |
- strncpy(result, srs_db_key, result_len); |
| 534 |
- |
| 535 |
- return SRS_RESULT_OK; |
| 536 |
-} |
| 537 |
- |
| 538 |
- |
| 539 |
-srs_result eximsrs_db_lookup(srs_t *srs, char *data, uint data_len, char *result, uint result_len) |
| 540 |
-{ |
| 541 |
- uschar *res; |
| 542 |
- |
| 543 |
- srs_db_key = string_copyn(data, data_len); |
| 544 |
- if((res = expand_string(srs_db_reverse)) == NULL) |
| 545 |
- return SRS_RESULT_DBERROR; |
| 546 |
- |
| 547 |
- if(Ustrlen(res) >= result_len) |
| 548 |
- return SRS_RESULT_ADDRESSTOOLONG; |
| 549 |
- |
| 550 |
- strncpy(result, res, result_len); |
| 551 |
- |
| 552 |
- return SRS_RESULT_OK; |
| 553 |
-} |
| 554 |
- |
| 555 |
- |
| 556 |
#endif |
| 557 |
- |
| 558 |
diff -u src/srs.h src/srs.h |
| 559 |
--- src/srs.h Sat Jul 17 11:12:00 2004 |
| 560 |
+++ src/srs.h Sat Jul 17 11:58:51 2004 |
| 561 |
@@ -5,28 +5,28 @@ |
| 562 |
/* This file is an extension to Exim and is not part of the standard |
| 563 |
Exim distribution */ |
| 564 |
|
| 565 |
-/* ©2004 Miles Wilton <miles@mirtol.com> */ |
| 566 |
+/* (c) 2004 Shevek |
| 567 |
+ * Based on work by Miles Wilton <miles@mirtol.com> |
| 568 |
+ * Updated by Shevek to use libsrs2 |
| 569 |
+ * Sorry Miles, I was in a roaring hurry, but we still need the |
| 570 |
+ * help! |
| 571 |
+ */ |
| 572 |
|
| 573 |
/* License: GPL */ |
| 574 |
|
| 575 |
#ifndef __SRS_H__ |
| 576 |
- |
| 577 |
#define __SRS_H__ 1 |
| 578 |
|
| 579 |
- |
| 580 |
#ifdef SRS |
| 581 |
|
| 582 |
#include "mytypes.h" |
| 583 |
-#include <srs_alt.h> |
| 584 |
+#include <srs2.h> |
| 585 |
|
| 586 |
int eximsrs_init(); |
| 587 |
int eximsrs_done(); |
| 588 |
int eximsrs_forward(uschar **result, uschar *orig_sender, uschar *domain); |
| 589 |
int eximsrs_reverse(uschar **result, uschar *address); |
| 590 |
-int eximsrs_db(BOOL reverse, uschar *srs_db); |
| 591 |
|
| 592 |
-srs_result eximsrs_db_insert(srs_t *srs, char *data, uint data_len, char *result, uint result_len); |
| 593 |
-srs_result eximsrs_db_lookup(srs_t *srs, char *data, uint data_len, char *result, uint result_len); |
| 594 |
|
| 595 |
#endif |
| 596 |
|