Option -M none disables creating the mailer.
Showing
1 changed file
with
40 additions
and
30 deletions
... | @@ -49,7 +49,7 @@ sieve script interpreter. | ... | @@ -49,7 +49,7 @@ sieve script interpreter. |
49 | #include <mailutils/registrar.h> | 49 | #include <mailutils/registrar.h> |
50 | #include <mailutils/stream.h> | 50 | #include <mailutils/stream.h> |
51 | 51 | ||
52 | void mutil_register_all_mbox_formats(void); | 52 | void mutil_register_all_mbox_formats (void); |
53 | 53 | ||
54 | const char *argp_program_version = "sieve (" PACKAGE_STRING ")"; | 54 | const char *argp_program_version = "sieve (" PACKAGE_STRING ")"; |
55 | 55 | ||
... | @@ -63,8 +63,7 @@ static char doc[] = | ... | @@ -63,8 +63,7 @@ static char doc[] = |
63 | " P - network protocols (MU_DEBUG_PROT)\n" | 63 | " P - network protocols (MU_DEBUG_PROT)\n" |
64 | " t - sieve trace (SV_DEBUG_TRACE)\n" | 64 | " t - sieve trace (SV_DEBUG_TRACE)\n" |
65 | " h - sieve header filling (SV_DEBUG_HDR_FILL)\n" | 65 | " h - sieve header filling (SV_DEBUG_HDR_FILL)\n" |
66 | " q - sieve message queries (SV_DEBUG_MSG_QUERY)\n" | 66 | " q - sieve message queries (SV_DEBUG_MSG_QUERY)\n"; |
67 | ; | ||
68 | 67 | ||
69 | #define D_DEFAULT "TPt" | 68 | #define D_DEFAULT "TPt" |
70 | 69 | ||
... | @@ -85,7 +84,7 @@ static struct argp_option options[] = { | ... | @@ -85,7 +84,7 @@ static struct argp_option options[] = { |
85 | "Ticket file for mailbox authentication", 0}, | 84 | "Ticket file for mailbox authentication", 0}, |
86 | 85 | ||
87 | {"mailer-url", 'M', "MAILER", 0, | 86 | {"mailer-url", 'M', "MAILER", 0, |
88 | "Mailer URL (defaults to \"sendmail:\")", 0}, | 87 | "Mailer URL (defaults to \"sendmail:\"). Use `--mailer-url none' to disable creating the mailer (it will disable reject and redirect actions as well)", 0}, |
89 | 88 | ||
90 | {"debug", 'd', "FLAGS", OPTION_ARG_OPTIONAL, | 89 | {"debug", 'd', "FLAGS", OPTION_ARG_OPTIONAL, |
91 | "Debug flags (defaults to \"" D_DEFAULT "\")", 0}, | 90 | "Debug flags (defaults to \"" D_DEFAULT "\")", 0}, |
... | @@ -215,17 +214,17 @@ static const char *sieve_argp_capa[] = { | ... | @@ -215,17 +214,17 @@ static const char *sieve_argp_capa[] = { |
215 | }; | 214 | }; |
216 | 215 | ||
217 | char *sieve_license_text = | 216 | char *sieve_license_text = |
218 | " Copyright 1999 by Carnegie Mellon University\n" | 217 | " Copyright 1999 by Carnegie Mellon University\n" |
219 | " Copyright 1999,2001,2002 by Free Software Foundation\n" | 218 | " Copyright 1999,2001,2002 by Free Software Foundation\n" |
220 | "\n" | 219 | "\n" |
221 | " Permission to use, copy, modify, and distribute this software and its\n" | 220 | " Permission to use, copy, modify, and distribute this software and its\n" |
222 | " documentation for any purpose and without fee is hereby granted,\n" | 221 | " documentation for any purpose and without fee is hereby granted,\n" |
223 | " provided that the above copyright notice appear in all copies and that\n" | 222 | " provided that the above copyright notice appear in all copies and that\n" |
224 | " both that copyright notice and this permission notice appear in\n" | 223 | " both that copyright notice and this permission notice appear in\n" |
225 | " supporting documentation, and that the name of Carnegie Mellon\n" | 224 | " supporting documentation, and that the name of Carnegie Mellon\n" |
226 | " University not be used in advertising or publicity pertaining to\n" | 225 | " University not be used in advertising or publicity pertaining to\n" |
227 | " distribution of the software without specific, written prior\n" | 226 | " distribution of the software without specific, written prior\n" |
228 | " permission.\n"; | 227 | " permission.\n"; |
229 | 228 | ||
230 | 229 | ||
231 | static void | 230 | static void |
... | @@ -292,10 +291,11 @@ main (int argc, char *argv[]) | ... | @@ -292,10 +291,11 @@ main (int argc, char *argv[]) |
292 | 291 | ||
293 | /* Override license text: */ | 292 | /* Override license text: */ |
294 | mu_license_text = sieve_license_text; | 293 | mu_license_text = sieve_license_text; |
295 | rc = mu_argp_parse(&argp, &argc, &argv, ARGP_IN_ORDER, sieve_argp_capa, | 294 | rc = mu_argp_parse (&argp, &argc, &argv, ARGP_IN_ORDER, sieve_argp_capa, |
296 | 0, &opts); | 295 | 0, &opts); |
297 | 296 | ||
298 | if (rc) { | 297 | if (rc) |
298 | { | ||
299 | fprintf (stderr, "arg parsing failed: %s\n", sv_strerror (rc)); | 299 | fprintf (stderr, "arg parsing failed: %s\n", sv_strerror (rc)); |
300 | return 1; | 300 | return 1; |
301 | } | 301 | } |
... | @@ -353,18 +353,22 @@ main (int argc, char *argv[]) | ... | @@ -353,18 +353,22 @@ main (int argc, char *argv[]) |
353 | } | 353 | } |
354 | if ((rc = mu_debug_set_level (debug, opts.debug_level))) | 354 | if ((rc = mu_debug_set_level (debug, opts.debug_level))) |
355 | { | 355 | { |
356 | fprintf (stderr, "mu_debug_set_level failed: %s\n", mu_errstring (rc)); | 356 | fprintf (stderr, "mu_debug_set_level failed: %s\n", |
357 | mu_errstring (rc)); | ||
357 | goto cleanup; | 358 | goto cleanup; |
358 | } | 359 | } |
359 | if ((rc = mu_debug_set_print (debug, debug_print, interp))) | 360 | if ((rc = mu_debug_set_print (debug, debug_print, interp))) |
360 | { | 361 | { |
361 | fprintf (stderr, "mu_debug_set_print failed: %s\n", mu_errstring (rc)); | 362 | fprintf (stderr, "mu_debug_set_print failed: %s\n", |
363 | mu_errstring (rc)); | ||
362 | goto cleanup; | 364 | goto cleanup; |
363 | } | 365 | } |
364 | } | 366 | } |
365 | 367 | ||
366 | /* Create a mailer. */ | 368 | /* Create a mailer. */ |
367 | if ((rc = mailer_create(&mailer, opts.mailer))) | 369 | if (strcmp (opts.mailer, "none")) |
370 | { | ||
371 | if ((rc = mailer_create (&mailer, opts.mailer))) | ||
368 | { | 372 | { |
369 | fprintf (stderr, "mailer create <%s> failed: %s\n", | 373 | fprintf (stderr, "mailer create <%s> failed: %s\n", |
370 | opts.mailer, mu_errstring (rc)); | 374 | opts.mailer, mu_errstring (rc)); |
... | @@ -372,10 +376,11 @@ main (int argc, char *argv[]) | ... | @@ -372,10 +376,11 @@ main (int argc, char *argv[]) |
372 | } | 376 | } |
373 | if (debug && (rc = mailer_set_debug (mailer, debug))) | 377 | if (debug && (rc = mailer_set_debug (mailer, debug))) |
374 | { | 378 | { |
375 | fprintf (stderr, "mailer_set_debug failed: %s\n", mu_errstring (rc)); | 379 | fprintf (stderr, "mailer_set_debug failed: %s\n", |
380 | mu_errstring (rc)); | ||
376 | goto cleanup; | 381 | goto cleanup; |
377 | } | 382 | } |
378 | 383 | } | |
379 | /* Create, give a ticket to, and open the mailbox. */ | 384 | /* Create, give a ticket to, and open the mailbox. */ |
380 | if ((rc = mailbox_create_default (&mbox, opts.mbox)) != 0) | 385 | if ((rc = mailbox_create_default (&mbox, opts.mbox)) != 0) |
381 | { | 386 | { |
... | @@ -397,20 +402,23 @@ main (int argc, char *argv[]) | ... | @@ -397,20 +402,23 @@ main (int argc, char *argv[]) |
397 | 402 | ||
398 | if ((rc = mailbox_get_folder (mbox, &folder))) | 403 | if ((rc = mailbox_get_folder (mbox, &folder))) |
399 | { | 404 | { |
400 | fprintf (stderr, "mailbox_get_folder failed: %s", mu_errstring (rc)); | 405 | fprintf (stderr, "mailbox_get_folder failed: %s", |
406 | mu_errstring (rc)); | ||
401 | goto cleanup; | 407 | goto cleanup; |
402 | } | 408 | } |
403 | 409 | ||
404 | if ((rc = folder_get_authority (folder, &auth))) | 410 | if ((rc = folder_get_authority (folder, &auth))) |
405 | { | 411 | { |
406 | fprintf (stderr, "folder_get_authority failed: %s", mu_errstring (rc)); | 412 | fprintf (stderr, "folder_get_authority failed: %s", |
413 | mu_errstring (rc)); | ||
407 | goto cleanup; | 414 | goto cleanup; |
408 | } | 415 | } |
409 | 416 | ||
410 | /* Authentication-less folders don't have authorities. */ | 417 | /* Authentication-less folders don't have authorities. */ |
411 | if (auth && (rc = authority_set_ticket (auth, ticket))) | 418 | if (auth && (rc = authority_set_ticket (auth, ticket))) |
412 | { | 419 | { |
413 | fprintf (stderr, "authority_set_ticket failed: %s", mu_errstring (rc)); | 420 | fprintf (stderr, "authority_set_ticket failed: %s", |
421 | mu_errstring (rc)); | ||
414 | goto cleanup; | 422 | goto cleanup; |
415 | } | 423 | } |
416 | } | 424 | } |
... | @@ -445,11 +453,14 @@ main (int argc, char *argv[]) | ... | @@ -445,11 +453,14 @@ main (int argc, char *argv[]) |
445 | if ((rc = mailbox_get_message (mbox, msgno, &msg)) != 0) | 453 | if ((rc = mailbox_get_message (mbox, msgno, &msg)) != 0) |
446 | { | 454 | { |
447 | fprintf (stderr, "get message on %s (msg %d) failed: %s\n", | 455 | fprintf (stderr, "get message on %s (msg %d) failed: %s\n", |
448 | opts.mbox ? opts.mbox : "default", msgno, mu_errstring (rc)); | 456 | opts.mbox ? opts.mbox : "default", msgno, |
457 | mu_errstring (rc)); | ||
449 | goto cleanup; | 458 | goto cleanup; |
450 | } | 459 | } |
451 | 460 | ||
452 | rc = sv_script_execute (script, msg, ticket, debug, mailer, opts.no_actions); | 461 | rc = |
462 | sv_script_execute (script, msg, ticket, debug, mailer, | ||
463 | opts.no_actions); | ||
453 | 464 | ||
454 | if (rc) | 465 | if (rc) |
455 | { | 466 | { |
... | @@ -476,13 +487,13 @@ cleanup: | ... | @@ -476,13 +487,13 @@ cleanup: |
476 | fprintf (stderr, "expunge on %s failed: %s\n", | 487 | fprintf (stderr, "expunge on %s failed: %s\n", |
477 | opts.mbox ? opts.mbox : "default", mu_errstring (e)); | 488 | opts.mbox ? opts.mbox : "default", mu_errstring (e)); |
478 | 489 | ||
479 | if(e && !rc) | 490 | if (e && !rc) |
480 | rc = e; | 491 | rc = e; |
481 | } | 492 | } |
482 | 493 | ||
483 | mailbox_close (mbox); | 494 | mailbox_close (mbox); |
484 | mailbox_destroy (&mbox); | 495 | mailbox_destroy (&mbox); |
485 | mu_debug_destroy(&debug, interp); | 496 | mu_debug_destroy (&debug, interp); |
486 | sv_script_free (&script); | 497 | sv_script_free (&script); |
487 | sv_interp_free (&interp); | 498 | sv_interp_free (&interp); |
488 | 499 | ||
... | @@ -503,4 +514,3 @@ mutil_register_all_mbox_formats (void) | ... | @@ -503,4 +514,3 @@ mutil_register_all_mbox_formats (void) |
503 | list_append (bookie, sendmail_record); | 514 | list_append (bookie, sendmail_record); |
504 | list_append (bookie, smtp_record); | 515 | list_append (bookie, smtp_record); |
505 | } | 516 | } |
506 | ... | ... |
-
Please register or sign in to post a comment