masqmail
view src/masqmail.c @ 368:b35c17fcf69d
Added cast to avoid compiler warning.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 20 Oct 2011 10:22:40 +0200 |
parents | 41958685480d |
children | 5781ba87df95 |
line source
1 /*
2 ** MasqMail
3 ** Copyright (C) 1999-2001 Oliver Kurth
4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
21 #include <stdio.h>
22 #include <errno.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/time.h>
29 #include <netinet/in.h>
30 #include <netdb.h>
31 #include <syslog.h>
32 #include <signal.h>
34 #include <glib.h>
36 #include "masqmail.h"
38 /*
39 ** mutually exclusive modes. Note that there is no 'queue daemon' mode.
40 ** It, as well as the distinction beween the two (non exclusive) daemon
41 ** (queue and listen) modes, is handled by flags.
42 */
43 enum mta_mode {
44 MODE_NONE = 0, /* to check if a mode was set */
45 MODE_ACCEPT, /* accept message on stdin (fallback mode) */
46 MODE_DAEMON, /* run as daemon */
47 MODE_RUNQUEUE, /* single queue run, online or offline */
48 MODE_SMTP, /* accept SMTP on stdin */
49 MODE_LIST, /* list queue */
50 MODE_MCMD, /* do queue manipulation */
51 MODE_VERSION, /* show version */
52 MODE_BI, /* fake ;-) */
53 };
54 enum mta_mode mta_mode = MODE_NONE;
56 char *pidfile = NULL;
57 volatile int sigterm_in_progress = 0;
59 static void
60 sigterm_handler(int sig)
61 {
62 if (sigterm_in_progress)
63 raise(sig);
64 sigterm_in_progress = 1;
66 if (pidfile) {
67 uid_t uid = geteuid();
68 if (seteuid(0) != 0) {
69 logwrite(LOG_ALERT, "sigterm_handler: could not set euid to %d: %s\n", 0, strerror(errno));
70 }
71 if (unlink(pidfile) != 0)
72 logwrite(LOG_WARNING, "could not delete pid file %s: %s\n", pidfile, strerror(errno));
73 seteuid(uid); /* we exit anyway after this, just to be sure */
74 }
76 signal(sig, SIG_DFL);
77 raise(sig);
78 }
80 #ifdef ENABLE_IDENT /* so far used for that only */
81 static gboolean
82 is_in_netlist(gchar *host, GList *netlist)
83 {
84 guint hostip = inet_addr(host);
85 struct in_addr addr;
87 addr.s_addr = hostip;
88 if (addr.s_addr != INADDR_NONE) {
89 GList *node;
90 foreach(netlist, node) {
91 struct in_addr *net = (struct in_addr *) (node->data);
92 if ((addr.s_addr & net->s_addr) == net->s_addr)
93 return TRUE;
94 }
95 }
96 return FALSE;
97 }
98 #endif
100 /*
101 ** argv: the original argv
102 ** argp: number of arg (may get modified!)
103 ** cp: pointing to the char after the option
104 ** e.g. `-d 6' `-d6'
105 ** ^ ^
106 */
107 gchar*
108 get_optarg(char *argv[], gint *argp, char *cp)
109 {
110 if (*cp) {
111 /* this kind: -xval */
112 return cp;
113 }
114 cp = argv[*argp+1];
115 if (cp && (*cp != '-')) {
116 /* this kind: -x val */
117 (*argp)++;
118 return cp;
119 }
120 return NULL;
121 }
123 gboolean
124 write_pidfile(gchar *name)
125 {
126 FILE *fptr;
128 if ((fptr = fopen(name, "wt"))) {
129 fprintf(fptr, "%d\n", getpid());
130 fclose(fptr);
131 pidfile = strdup(name);
132 return TRUE;
133 }
134 logwrite(LOG_WARNING, "could not write pid file: %s\n", strerror(errno));
135 return FALSE;
136 }
138 /* on -bd or if -q has an argument */
139 static void
140 mode_daemon(gboolean do_listen, gint queue_interval, char *argv[])
141 {
142 guint pid;
144 /* daemon */
145 if (!conf.run_as_user) {
146 if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
147 fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
148 exit(1);
149 }
150 }
152 /* reparent to init only if init is not already the parent */
153 if (getppid() != 1) {
154 if ((pid = fork()) > 0) {
155 exit(0);
156 } else if (pid < 0) {
157 logwrite(LOG_ALERT, "could not fork!\n");
158 exit(1);
159 }
160 }
162 signal(SIGTERM, sigterm_handler);
163 write_pidfile(PIDFILEDIR "/masqmail.pid");
165 conf.do_verbose = FALSE;
167 /*
168 ** closing and reopening the log ensures that it is open afterwards
169 ** because it is possible that the log is assigned to fd 1 and gets
170 ** thus closes by fclose(stdout). Similar for the debugfile.
171 */
172 logclose();
173 fclose(stdin);
174 fclose(stdout);
175 fclose(stderr);
176 logopen();
178 logwrite(LOG_NOTICE, "%s %s daemon starting\n", PACKAGE, VERSION);
179 listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv);
180 }
182 /* -bs or called as smtpd or in.smtpd */
183 static void
184 mode_smtp()
185 {
186 /* accept smtp message on stdin */
187 /* write responses to stderr. */
189 struct sockaddr_in saddr;
190 gchar *peername = NULL;
191 int dummy = sizeof(saddr);
193 conf.do_verbose = FALSE;
195 if (!conf.run_as_user) {
196 set_euidgid(conf.orig_uid, conf.orig_gid, NULL, NULL);
197 }
199 DEBUG(5) debugf("accepting smtp message on stdin\n");
201 if (getpeername(0, (struct sockaddr *) (&saddr), &dummy) == 0) {
202 peername = g_strdup(inet_ntoa(saddr.sin_addr));
203 } else if (errno != ENOTSOCK)
204 exit(1);
206 smtp_in(stdin, stderr, peername, NULL);
207 }
209 /* default mode if address args or -t is specified, or called as rmail */
210 static void
211 mode_accept(address *return_path, gchar *full_sender_name, guint accept_flags,
212 char **addresses, int addr_cnt)
213 {
214 /* accept message on stdin */
215 accept_error err;
216 message *msg = create_message();
217 gint i;
218 pid_t pid;
220 if (return_path && !is_privileged_user(conf.orig_uid)) {
221 fprintf(stderr, "must be root, %s or in group %s for setting return path.\n", DEF_MAIL_USER, DEF_MAIL_GROUP);
222 exit(1);
223 }
225 if (!conf.run_as_user) {
226 set_euidgid(conf.orig_uid, conf.orig_gid, NULL, NULL);
227 }
229 DEBUG(5) debugf("accepting message on stdin\n");
231 msg->received_prot = PROT_LOCAL;
233 /* warn if -t option and cmdline addr args */
234 if (addr_cnt && (accept_flags & ACC_RCPT_FROM_HEAD)) {
235 logwrite(LOG_ALERT, "command line address arguments are now *added* to the mail header\\\n");
236 logwrite(LOG_ALERT, " recipient addresses (instead of substracted) when -t is given.\\\n");
237 logwrite(LOG_ALERT, " this changed with version 0.3.1\n");
238 }
240 for (i = 0; i < addr_cnt; i++) {
241 if (addresses[i][0] == '|') {
242 logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
243 /* should we better ignore this one addr? */
244 exit(1);
245 }
246 msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
247 }
249 /* -f option */
250 msg->return_path = return_path;
252 /* -F option */
253 msg->full_sender_name = full_sender_name;
255 err = accept_message(stdin, msg, accept_flags);
257 switch (err) {
258 case AERR_OK:
259 /* to continue; all other cases exit */
260 break;
261 case AERR_EOF:
262 fprintf(stderr, "unexpected EOF.\n");
263 exit(1);
264 case AERR_NORCPT:
265 fprintf(stderr, "no recipients.\n");
266 exit(1);
267 case AERR_SIZE:
268 fprintf(stderr, "max message size exceeded.\n");
269 exit(1);
270 default:
271 /* should never happen: */
272 fprintf(stderr, "Unknown error (%d)\r\n", err);
273 exit(1);
274 }
276 if (!spool_write(msg, TRUE)) {
277 fprintf(stderr, "Could not write spool file\n");
278 exit(1);
279 }
281 /* here the mail is queued and thus in our responsibility */
282 logwrite(LOG_NOTICE, "%s <= %s with %s\n", msg->uid, addr_string(msg->return_path), prot_names[PROT_LOCAL]);
284 if (conf.do_queue) {
285 /* we're finished as we only need to queue it */
286 return;
287 }
289 /* deliver at once */
290 if ((pid = fork()) < 0) {
291 logwrite(LOG_ALERT, "could not fork for delivery, id = %s\n", msg->uid);
292 } else if (pid == 0) {
293 conf.do_verbose = FALSE;
294 fclose(stdin);
295 fclose(stdout);
296 fclose(stderr);
297 if (deliver(msg)) {
298 exit(0);
299 } else {
300 /*
301 ** TODO: Should we really fail here? Because the
302 ** mail is queued already. If we fail the client
303 ** might submit it again. If at-once-delivery
304 ** is seen as an additional best-effort service,
305 ** then we should still exit successful here.
306 */
307 exit(1);
308 }
309 }
310 }
312 /*
313 ** if -Mrm is given
314 **
315 ** currently only the `rm' command is supported
316 ** until this changes, we don't need any facility for further commands
317 ** return success if at least one message had been deleted
318 */
319 static int
320 manipulate_queue(char *cmd, char *id[])
321 {
322 gboolean ok = FALSE;
324 if (strcmp(cmd, "rm") != 0) {
325 fprintf(stderr, "unknown command %s\n", cmd);
326 return FALSE;
327 }
329 set_euidgid(conf.mail_uid, conf.mail_gid, NULL, NULL);
331 /* privileged users may delete any mail */
332 if (is_privileged_user(conf.orig_uid)) {
333 for (; *id; id++) {
334 fprintf(stderr, "id: %s\n", *id);
335 if (queue_delete(*id)) {
336 ok = TRUE;
337 }
338 }
339 return ok;
340 }
342 struct passwd *pw = getpwuid(conf.orig_uid);
343 if (!pw) {
344 fprintf(stderr, "could not find a passwd entry for uid %d: %s\n",
345 conf.orig_uid, strerror(errno));
346 return FALSE;
347 }
349 /* non-privileged users may only delete their own messages */
350 for (; *id; id++) {
351 message *msg = msg_spool_read(*id);
353 fprintf(stderr, "id: %s\n", *id);
355 if (!msg->ident) {
356 fprintf(stderr, "message %s does not have an ident\n", *id);
357 continue;
358 }
359 if (strcmp(pw->pw_name, msg->ident) != 0) {
360 fprintf(stderr, "you do not own message id %s\n", *id);
361 continue;
362 }
364 if ( (msg->received_host || (msg->received_prot != PROT_LOCAL))
365 #ifdef ENABLE_IDENT
366 && !is_in_netlist(msg->received_host, conf.ident_trusted_nets)
367 #endif
368 ) {
369 fprintf(stderr, "message %s was not received locally or from a trusted network\n", *id);
370 continue;
371 }
373 ok = queue_delete(*id);
374 }
375 return ok;
376 }
378 /* -qo, -q (without argument), or called as runq */
379 static int
380 run_queue(gboolean do_runq, gboolean do_runq_online, char *route_name)
381 {
382 int ret;
384 /* queue runs */
385 set_identity(conf.orig_uid, "queue run");
387 if (do_runq) {
388 ret = queue_run();
389 }
391 if (do_runq_online) {
392 if (route_name) {
393 conf.online_query = g_strdup_printf("/bin/echo %s", route_name);
394 }
395 /*
396 ** TODO: change behavior of `-qo without argument'?
397 ** Because that behavior is included in -q.
398 */
399 ret = queue_run_online();
400 }
401 return ret;
402 }
404 /* -bV or default mode if neither addr arg nor -t */
405 static void
406 mode_version(void)
407 {
408 gchar *with_resolver = "";
409 gchar *with_auth = "";
410 gchar *with_ident = "";
412 #ifdef ENABLE_RESOLVER
413 with_resolver = " +resolver";
414 #endif
415 #ifdef ENABLE_AUTH
416 with_auth = " +auth";
417 #endif
418 #ifdef ENABLE_IDENT
419 with_ident = " +ident";
420 #endif
422 printf("%s %s%s%s%s\n", PACKAGE, VERSION, with_resolver, with_auth,
423 with_ident);
424 }
426 void
427 set_mode(enum mta_mode mode)
428 {
429 if (mta_mode && mta_mode!=mode) {
430 fprintf(stderr, "operation mode was already specified (%d vs. %d)\n", mta_mode, mode);
431 exit(1);
432 }
434 mta_mode = mode;
435 return;
436 }
438 int
439 main(int argc, char *argv[])
440 {
441 gchar *progname;
442 char *opt;
443 gint arg;
445 gboolean do_listen = FALSE;
446 gboolean do_runq = FALSE;
447 gboolean do_runq_online = FALSE;
448 gboolean do_queue = FALSE;
449 gint queue_interval = 0;
450 gchar *M_cmd = NULL;
451 gboolean opt_t = FALSE;
452 gboolean opt_i = FALSE;
453 gchar *conf_file = CONF_FILE;
454 gchar *route_name = NULL;
455 gchar *f_address = NULL;
456 address *return_path = NULL; /* may be changed by -f option */
457 gchar *full_sender_name = NULL;
458 gboolean do_verbose = FALSE;
459 gint debug_level = -1;
461 /* strip the path part */
462 progname = strrchr(argv[0], '/');
463 progname = (progname) ? progname+1 : argv[0];
465 if (strcmp(progname, "mailq") == 0) {
466 mta_mode = MODE_LIST;
467 } else if (strcmp(progname, "mailrm") == 0) {
468 mta_mode = MODE_MCMD;
469 M_cmd = "rm";
470 } else if (strcmp(progname, "newaliases") == 0) {
471 mta_mode = MODE_BI;
472 } else if (strcmp(progname, "rmail") == 0) {
473 /*
474 ** the `rmail' alias should probably be removed now
475 ** that we have the rmail script. But let's keep it
476 ** for some while for compatibility. 2010-06-19
477 */
478 mta_mode = MODE_ACCEPT;
479 opt_i = TRUE;
480 } else if (strcmp(progname, "runq") == 0) {
481 mta_mode = MODE_RUNQUEUE;
482 do_runq = TRUE;
483 } else if (strcmp(progname, "smtpd") == 0
484 || strcmp(progname, "in.smtpd") == 0) {
485 mta_mode = MODE_SMTP;
486 }
488 /* parse cmd line */
489 for (arg=1; arg<argc && argv[arg][0]=='-'; arg++) {
490 opt = argv[arg] + 1; /* points to the char after the dash */
492 if (strcmp(opt, "-") == 0) {
493 /* everything after `--' are address arguments */
494 arg++;
495 break;
497 } else if (strcmp(opt, "bm") == 0) {
498 set_mode(MODE_ACCEPT);
500 } else if (strcmp(opt, "bd") == 0) {
501 set_mode(MODE_DAEMON);
502 do_listen = TRUE;
504 } else if (strcmp(opt, "bi") == 0) {
505 set_mode(MODE_BI);
507 } else if (strcmp(opt, "bs") == 0) {
508 set_mode(MODE_SMTP);
510 } else if (strcmp(opt, "bp") == 0) {
511 set_mode(MODE_LIST);
513 } else if (strcmp(opt, "bV") == 0) {
514 set_mode(MODE_VERSION);
516 } else if (strncmp(opt, "B", 1) == 0) {
517 /* we ignore this and throw the argument away */
518 get_optarg(argv, &arg, opt+1);
520 } else if (strncmp(opt, "C", 1) == 0) {
521 conf_file = get_optarg(argv, &arg, opt+1);
522 if (!conf_file) {
523 fprintf(stderr, "-C requires a filename as argument.\n");
524 exit(1);
525 }
527 } else if (strncmp(opt, "d", 1) == 0) {
528 if (getuid() != 0) {
529 fprintf(stderr, "only root may set the debug level.\n");
530 exit(1);
531 }
532 char *lvl = get_optarg(argv, &arg, opt+1);
533 if (!lvl) {
534 fprintf(stderr, "-d requires a number argument.\n");
535 exit(1);
536 }
537 debug_level = atoi(lvl);
539 } else if (strncmp(opt, "f", 1) == 0) {
540 /* set return path */
541 gchar *address = get_optarg(argv, &arg, opt+1);
542 if (!address) {
543 fprintf(stderr, "-f requires an address argument\n");
544 exit(1);
545 }
546 f_address = g_strdup(address);
548 } else if (strncmp(opt, "F", 1) == 0) {
549 full_sender_name = get_optarg(argv, &arg, opt+1);
550 if (!full_sender_name) {
551 fprintf(stderr, "-F requires a name argument\n");
552 exit(1);
553 }
555 } else if (strcmp(opt, "i") == 0) {
556 opt_i = TRUE;
558 } else if (strcmp(opt, "m") == 0) {
559 /* ignore -m (me too) switch (see man page) */
561 } else if (strcmp(opt, "Mrm") == 0) {
562 set_mode(MODE_MCMD);
563 M_cmd = "rm";
565 } else if (strcmp(opt, "odq") == 0) {
566 do_queue = TRUE;
568 } else if (strcmp(opt, "oi") == 0) {
569 opt_i = TRUE;
571 } else if (strncmp(opt, "o", 1) == 0) {
572 /* ignore all other -oXXX options */
574 } else if (strncmp(opt, "qo", 2) == 0) {
575 /* must be before the `q' check */
576 set_mode(MODE_RUNQUEUE);
577 do_runq_online = TRUE;
578 /* can be NULL, then we use online detection method */
579 /* TODO: behavior might change if it is NULL */
580 route_name = get_optarg(argv, &arg, opt+2);
581 if (!route_name) {
582 fprintf(stderr, "Please do not use -qo without argument anymore; use -q instead.\n");
583 fprintf(stderr, "The behavior for -qo without argument is likely to change.\n");
584 }
586 } else if (strncmp(opt, "q", 1) == 0) {
587 /* must be after the `qo' check */
588 gchar *optarg;
590 optarg = get_optarg(argv, &arg, opt+1);
591 if (optarg) {
592 /* not just one single queue run but regular runs */
593 set_mode(MODE_DAEMON);
594 queue_interval = time_interval(optarg);
595 } else {
596 set_mode(MODE_RUNQUEUE);
597 do_runq = TRUE;
598 }
600 } else if (strcmp(opt, "t") == 0) {
601 opt_t = TRUE;
603 } else if (strcmp(opt, "v") == 0) {
604 do_verbose = TRUE;
606 } else {
607 fprintf(stderr, "unrecognized option `-%s'\n", opt);
608 exit(1);
609 }
610 }
612 if (!mta_mode && arg==argc && !opt_t) {
613 /*
614 ** In this case no rcpts can be found, thus no mail
615 ** can be sent, thus masqmail will always fail. We
616 ** rather do something better instead. This covers
617 ** also the case of calling masqmail without args.
618 */
619 mode_version();
620 exit(0);
621 }
623 if (mta_mode == MODE_VERSION) {
624 mode_version();
625 exit(0);
626 }
628 if (!mta_mode) {
629 mta_mode = MODE_ACCEPT;
630 }
632 /* initialize random generator */
633 srand(time(NULL));
634 /* ignore SIGPIPE signal */
635 signal(SIGPIPE, SIG_IGN);
637 /* close all possibly open file descriptors, except std{in,out,err} */
638 {
639 int i, max_fd = sysconf(_SC_OPEN_MAX);
641 if (max_fd <= 0) {
642 max_fd = 64;
643 }
644 for (i=3; i<max_fd; i++) {
645 close(i);
646 }
647 }
649 init_conf();
651 /*
652 ** if we are not privileged, and the config file was changed we
653 ** implicetely set the the run_as_user flag and give up all
654 ** privileges.
655 **
656 ** So it is possible for a user to run his own daemon without
657 ** breaking security.
658 */
659 if ((strcmp(conf_file, CONF_FILE) != 0) && (conf.orig_uid != 0)) {
660 conf.run_as_user = TRUE;
661 set_euidgid(conf.orig_uid, conf.orig_gid, NULL, NULL);
662 if (setgid(conf.orig_gid)) {
663 logwrite(LOG_ALERT, "could not set gid to %d: %s\n", conf.orig_gid, strerror(errno));
664 exit(1);
665 }
666 if (setuid(conf.orig_uid)) {
667 logwrite(LOG_ALERT, "could not set uid to %d: %s\n", conf.orig_uid, strerror(errno));
668 exit(1);
669 }
670 }
672 conf.log_dir = LOG_DIR;
673 /* FIXME: fails if we run as user */
674 logopen();
675 if (!read_conf(conf_file)) {
676 logwrite(LOG_ALERT, "SHUTTING DOWN due to problems reading config\n");
677 exit(5);
678 }
679 logclose();
681 if (do_queue) {
682 conf.do_queue = TRUE;
683 }
684 if (do_verbose) {
685 conf.do_verbose = TRUE;
686 }
687 if (debug_level >= 0) { /* if >= 0, it was given by argument */
688 conf.debug_level = debug_level;
689 }
691 /*
692 ** It appears that changing to / ensures that we are never in
693 ** a directory which we cannot access. This situation could be
694 ** possible after changing identity.
695 ** Maybe we should only change to / if we not run as user, to
696 ** allow relative paths for log files in test setups for
697 ** instance.
698 */
699 chdir("/");
701 if (!conf.run_as_user) {
702 if (setgid(0) != 0) {
703 fprintf(stderr, "could not set gid to 0. Is the setuid bit set? : %s\n", strerror(errno));
704 exit(1);
705 }
706 if (setuid(0) != 0) {
707 fprintf(stderr, "could not gain root privileges. Is the setuid bit set? : %s\n", strerror(errno));
708 exit(1);
709 }
710 }
712 if (!logopen()) {
713 fprintf(stderr, "could not open log file\n");
714 exit(1);
715 }
717 DEBUG(1) debugf("masqmail %s starting\n", VERSION);
719 DEBUG(5) {
720 gchar **str = argv;
721 debugf("args: \n");
722 while (*str) {
723 debugf("%s \n", *str);
724 str++;
725 }
726 }
727 DEBUG(5) debugf("queue_interval = %d\n", queue_interval);
729 if (f_address) {
730 return_path = create_address_qualified(f_address, TRUE, conf.host_name);
731 g_free(f_address);
732 if (!return_path) {
733 fprintf(stderr, "invalid RFC821 address: %s\n", f_address);
734 exit(1);
735 }
736 }
738 switch (mta_mode) {
739 case MODE_DAEMON:
740 mode_daemon(do_listen, queue_interval, argv);
741 break;
743 case MODE_RUNQUEUE:
744 exit(run_queue(do_runq, do_runq_online, route_name) ? 0 : 1);
745 break;
747 case MODE_SMTP:
748 mode_smtp();
749 break;
751 case MODE_LIST:
752 queue_list();
753 break;
755 case MODE_BI:
756 exit(0);
757 break; /* well... */
759 case MODE_MCMD:
760 exit(manipulate_queue(M_cmd, &argv[arg]) ? 0 : 1);
761 break;
763 case MODE_ACCEPT:
764 {
765 guint accept_flags = (opt_t ? ACC_RCPT_FROM_HEAD : 0)
766 | (opt_i ? ACC_DOT_IGNORE : ACC_NODOT_RELAX);
767 mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg);
768 exit(0);
769 }
770 break;
772 default:
773 fprintf(stderr, "unknown mode: %d\n", mta_mode);
774 break;
775 }
777 logclose();
779 exit(0);
780 }