Mercurial > masqmail
comparison src/masqmail.c @ 278:c35c59a36a2a
added -bm for mode accept (the other MTAs have it too)
usually one does not need it as it's the default
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Mon, 06 Dec 2010 17:41:50 -0300 |
parents | 1abc1faeb45d |
children | ea5f86e0a81c |
comparison
equal
deleted
inserted
replaced
277:5f559921391a | 278:c35c59a36a2a |
---|---|
36 | 36 |
37 /* mutually exclusive modes. Note that there is no 'queue daemon' mode. | 37 /* mutually exclusive modes. Note that there is no 'queue daemon' mode. |
38 It, as well as the distinction beween the two (non exclusive) daemon | 38 It, as well as the distinction beween the two (non exclusive) daemon |
39 (queue and listen) modes, is handled by flags.*/ | 39 (queue and listen) modes, is handled by flags.*/ |
40 typedef enum _mta_mode { | 40 typedef enum _mta_mode { |
41 MODE_NONE = 0, /* for being able to check if a mode was defined */ | 41 MODE_ACCEPT = 0, /* accept message on stdin (fallback mode) */ |
42 MODE_ACCEPT, /* accept message on stdin */ | |
43 MODE_DAEMON, /* run as daemon */ | 42 MODE_DAEMON, /* run as daemon */ |
44 MODE_RUNQUEUE, /* single queue run, online or offline */ | 43 MODE_RUNQUEUE, /* single queue run, online or offline */ |
45 MODE_SMTP, /* accept SMTP on stdin */ | 44 MODE_SMTP, /* accept SMTP on stdin */ |
46 MODE_LIST, /* list queue */ | 45 MODE_LIST, /* list queue */ |
47 MODE_MCMD, /* do queue manipulation */ | 46 MODE_MCMD, /* do queue manipulation */ |
420 { | 419 { |
421 gchar *progname; | 420 gchar *progname; |
422 char* opt; | 421 char* opt; |
423 gint arg; | 422 gint arg; |
424 | 423 |
425 mta_mode mta_mode = MODE_NONE; | 424 mta_mode mta_mode = MODE_ACCEPT; |
426 gboolean do_listen = FALSE; | 425 gboolean do_listen = FALSE; |
427 gboolean do_runq = FALSE; | 426 gboolean do_runq = FALSE; |
428 gboolean do_runq_online = FALSE; | 427 gboolean do_runq_online = FALSE; |
429 gboolean do_queue = FALSE; | 428 gboolean do_queue = FALSE; |
430 gint queue_interval = 0; | 429 gint queue_interval = 0; |
468 if (strcmp(opt, "-") == 0) { | 467 if (strcmp(opt, "-") == 0) { |
469 /* everything after `--' are address arguments */ | 468 /* everything after `--' are address arguments */ |
470 arg++; | 469 arg++; |
471 break; | 470 break; |
472 | 471 |
472 } else if (strcmp(opt, "bm") == 0) { | |
473 mta_mode = MODE_ACCEPT; | |
474 | |
473 } else if (strcmp(opt, "bd") == 0) { | 475 } else if (strcmp(opt, "bd") == 0) { |
474 do_listen = TRUE; | 476 do_listen = TRUE; |
475 mta_mode = MODE_DAEMON; | 477 mta_mode = MODE_DAEMON; |
476 | 478 |
477 } else if (strcmp(opt, "bi") == 0) { | 479 } else if (strcmp(opt, "bi") == 0) { |
544 | 546 |
545 } else if (strncmp(opt, "o", 1) == 0) { | 547 } else if (strncmp(opt, "o", 1) == 0) { |
546 /* ignore all other -oXXX options */ | 548 /* ignore all other -oXXX options */ |
547 | 549 |
548 } else if (strncmp(opt, "qo", 2) == 0) { | 550 } else if (strncmp(opt, "qo", 2) == 0) { |
551 /* must be before the `q' check */ | |
549 mta_mode = MODE_RUNQUEUE; | 552 mta_mode = MODE_RUNQUEUE; |
550 do_runq = FALSE; | 553 do_runq = FALSE; |
551 do_runq_online = TRUE; | 554 do_runq_online = TRUE; |
552 /* can be NULL, then we use online detection method */ | 555 /* can be NULL, then we use online detection method */ |
553 route_name = get_optarg(argv, &arg, opt+2); | 556 route_name = get_optarg(argv, &arg, opt+2); |
575 fprintf(stderr, "unrecognized option `-%s'\n", opt); | 578 fprintf(stderr, "unrecognized option `-%s'\n", opt); |
576 exit(1); | 579 exit(1); |
577 } | 580 } |
578 } | 581 } |
579 | 582 |
580 if (!mta_mode) { | 583 if (mta_mode==MODE_ACCEPT && arg==argc && !opt_t) { |
581 mta_mode = (arg<argc || opt_t) ? MODE_ACCEPT : MODE_VERSION; | 584 /* |
585 In this case no rcpts can be found, thus no mail | |
586 can be sent, thus masqmail will always fail. We | |
587 rather do something better instead. This covers | |
588 also the case of calling masqmail without args. | |
589 */ | |
590 mta_mode = MODE_VERSION; | |
582 } | 591 } |
583 | 592 |
584 if (mta_mode == MODE_VERSION) { | 593 if (mta_mode == MODE_VERSION) { |
585 mode_version(); | 594 mode_version(); |
586 exit(0); | 595 exit(0); |