masqmail

view src/masqmail.c @ 16:163aa299bedb

fixed man pages added backslashes to dashes (to satisfy Debian) removed wrong sentence about /etc/aliases. Thanks to Alexis. (Closes Debian bug #480477) fixed typos reported by Reuben Thomas. (Closes Debian bug #427096)
author meillo@marmaro.de
date Thu, 06 Nov 2008 09:33:32 +0100
parents 26e34ae9a3e3
children 3cb6f383f07e
line source
1 /* MasqMail
2 Copyright (C) 1999-2001 Oliver Kurth
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
19 #include <stdio.h>
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <sys/time.h>
27 #include <netinet/in.h>
28 #include <netdb.h>
29 #include <syslog.h>
30 #include <signal.h>
32 #include <glib.h>
34 #include "masqmail.h"
36 /* mutually exclusive modes. Note that there is neither a 'get' mode
37 nor a 'queue daemon' mode. These, as well as the distinction beween
38 the two (non exclusive) daemon (queue and listen) modes are handled
39 by flags.*/
40 typedef enum _mta_mode {
41 MODE_ACCEPT = 0, /* accept message on stdin */
42 MODE_DAEMON, /* run as daemon */
43 MODE_RUNQUEUE, /* single queue run, online or offline */
44 MODE_GET_DAEMON, /* run as get (retrieve) daemon */
45 MODE_SMTP, /* accept SMTP on stdin */
46 MODE_LIST, /* list queue */
47 MODE_MCMD, /* do queue manipulation */
48 MODE_VERSION, /* show version */
49 MODE_BI, /* fake ;-) */
50 MODE_NONE /* to prevent default MODE_ACCEPT */
51 } mta_mode;
53 char *pidfile = NULL;
54 volatile int sigterm_in_progress = 0;
56 static void
57 sigterm_handler(int sig)
58 {
59 if (sigterm_in_progress)
60 raise(sig);
61 sigterm_in_progress = 1;
63 if (pidfile) {
64 uid_t uid;
65 uid = seteuid(0);
66 if (unlink(pidfile) != 0)
67 logwrite(LOG_WARNING, "could not delete pid file %s: %s\n", pidfile, strerror(errno));
68 seteuid(uid); /* we exit anyway after this, just to be sure */
69 }
71 signal(sig, SIG_DFL);
72 raise(sig);
73 }
75 #ifdef ENABLE_IDENT /* so far used for that only */
76 static gboolean
77 is_in_netlist(gchar * host, GList * netlist)
78 {
79 guint hostip = inet_addr(host);
80 struct in_addr addr;
82 addr.s_addr = hostip;
83 if (addr.s_addr != INADDR_NONE) {
84 GList *node;
85 foreach(netlist, node) {
86 struct in_addr *net = (struct in_addr *) (node->data);
87 if ((addr.s_addr & net->s_addr) == net->s_addr)
88 return TRUE;
89 }
90 }
91 return FALSE;
92 }
93 #endif
95 gchar*
96 get_optarg(char *argv[], gint argc, gint * argp, gint * pos)
97 {
98 if (argv[*argp][*pos])
99 return &(argv[*argp][*pos]);
100 else {
101 if (*argp + 1 < argc) {
102 if (argv[(*argp) + 1][0] != '-') {
103 (*argp)++;
104 *pos = 0;
105 return &(argv[*argp][*pos]);
106 }
107 }
108 }
109 return NULL;
110 }
112 gchar*
113 get_progname(gchar * arg0)
114 {
115 gchar *p = arg0 + strlen(arg0) - 1;
116 while (p > arg0) {
117 if (*p == '/')
118 return p + 1;
119 p--;
120 }
121 return p;
122 }
124 gboolean
125 write_pidfile(gchar * name)
126 {
127 FILE *fptr;
129 if ((fptr = fopen(name, "wt"))) {
130 fprintf(fptr, "%d\n", getpid());
131 fclose(fptr);
132 pidfile = strdup(name);
133 return TRUE;
134 }
135 logwrite(LOG_WARNING, "could not write pid file: %s\n", strerror(errno));
136 return FALSE;
137 }
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(EXIT_FAILURE);
149 }
150 }
152 if ((pid = fork()) > 0) {
153 exit(EXIT_SUCCESS);
154 } else if (pid < 0) {
155 logwrite(LOG_ALERT, "could not fork!");
156 exit(EXIT_FAILURE);
157 }
159 signal(SIGTERM, sigterm_handler);
160 write_pidfile(PIDFILEDIR "/masqmail.pid");
162 conf.do_verbose = FALSE;
164 fclose(stdin);
165 fclose(stdout);
166 fclose(stderr);
168 listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv);
169 }
171 #ifdef ENABLE_POP3
172 static void
173 mode_get_daemon(gint get_interval, char *argv[])
174 {
175 guint pid;
177 /* daemon */
178 if (!conf.run_as_user) {
179 if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
180 fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
181 exit(EXIT_FAILURE);
182 }
183 }
185 if ((pid = fork()) > 0) {
186 exit(EXIT_SUCCESS);
187 } else if (pid < 0) {
188 logwrite(LOG_ALERT, "could not fork!");
189 exit(EXIT_FAILURE);
190 }
192 signal(SIGTERM, sigterm_handler);
193 write_pidfile(PIDFILEDIR "/masqmail-get.pid");
195 conf.do_verbose = FALSE;
197 fclose(stdin);
198 fclose(stdout);
199 fclose(stderr);
201 get_daemon(get_interval, argv);
202 }
203 #endif
205 #ifdef ENABLE_SMTP_SERVER
206 static void
207 mode_smtp()
208 {
209 /* accept smtp message on stdin */
210 /* write responses to stderr. */
212 struct sockaddr_in saddr;
213 gchar *peername = NULL;
214 int dummy = sizeof(saddr);
216 conf.do_verbose = FALSE;
218 if (!conf.run_as_user) {
219 seteuid(conf.orig_uid);
220 setegid(conf.orig_gid);
221 }
223 DEBUG(5) debugf("accepting smtp message on stdin\n");
225 if (getpeername(0, (struct sockaddr *) (&saddr), &dummy) == 0) {
226 peername = g_strdup(inet_ntoa(saddr.sin_addr));
227 } else if (errno != ENOTSOCK)
228 exit(EXIT_FAILURE);
230 smtp_in(stdin, stderr, peername, NULL);
231 }
232 #endif
234 static void
235 mode_accept(address * return_path, gchar * full_sender_name, guint accept_flags, char **addresses, int addr_cnt)
236 {
237 /* accept message on stdin */
238 accept_error err;
239 message *msg = create_message();
240 gint i;
242 if (return_path != NULL) {
243 if ((conf.orig_uid != 0)
244 && (conf.orig_uid != conf.mail_uid)
245 && (!is_ingroup(conf.orig_uid, conf.mail_gid))) {
246 fprintf(stderr, "must be in root, %s or in group %s for setting return path.\n", DEF_MAIL_USER, DEF_MAIL_GROUP);
247 exit(EXIT_FAILURE);
248 }
249 }
251 if (!conf.run_as_user) {
252 seteuid(conf.orig_uid);
253 setegid(conf.orig_gid);
254 }
256 DEBUG(5) debugf("accepting message on stdin\n");
258 msg->received_prot = PROT_LOCAL;
259 for (i = 0; i < addr_cnt; i++) {
260 if (addresses[i][0] != '|')
261 msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
262 else {
263 logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
264 exit(EXIT_FAILURE);
265 }
266 }
268 /* -f option */
269 msg->return_path = return_path;
271 /* -F option */
272 msg->full_sender_name = full_sender_name;
274 if ((err = accept_message(stdin, msg, accept_flags)) == AERR_OK) {
275 if (spool_write(msg, TRUE)) {
276 pid_t pid;
277 logwrite(LOG_NOTICE, "%s <= %s with %s\n", msg->uid, addr_string(msg->return_path), prot_names[PROT_LOCAL]);
279 if (!conf.do_queue) {
280 if ((pid = fork()) == 0) {
281 conf.do_verbose = FALSE;
282 fclose(stdin);
283 fclose(stdout);
284 fclose(stderr);
285 if (deliver(msg)) {
286 exit(EXIT_SUCCESS);
287 } else
288 exit(EXIT_FAILURE);
289 } else if (pid < 0) {
290 logwrite(LOG_ALERT, "could not fork for delivery, id = %s", msg->uid);
291 }
292 }
293 } else {
294 fprintf(stderr, "Could not write spool file\n");
295 exit(EXIT_FAILURE);
296 }
297 } else {
298 switch (err) {
299 case AERR_EOF:
300 fprintf(stderr, "unexpected EOF.\n");
301 exit(EXIT_FAILURE);
302 case AERR_NORCPT:
303 fprintf(stderr, "no recipients.\n");
304 exit(EXIT_FAILURE);
305 default:
306 /* should never happen: */
307 fprintf(stderr, "Unknown error (%d)\r\n", err);
308 exit(EXIT_FAILURE);
309 }
310 exit(EXIT_FAILURE);
311 }
312 }
314 int
315 main(int argc, char *argv[])
316 {
317 /* cmd line flags */
318 gchar *conf_file = CONF_FILE;
319 gint arg = 1;
320 gboolean do_get = FALSE;
321 gboolean do_get_online = FALSE;
323 gboolean do_listen = FALSE;
324 gboolean do_runq = FALSE;
325 gboolean do_runq_online = FALSE;
327 gboolean do_queue = FALSE;
329 gboolean do_verbose = FALSE;
330 gint debug_level = -1;
332 mta_mode mta_mode = MODE_ACCEPT;
334 gint queue_interval = 0;
335 gint get_interval = 0;
336 gboolean opt_t = FALSE;
337 gboolean opt_i = FALSE;
338 gboolean opt_odb = FALSE;
339 gboolean opt_oem = FALSE;
340 gboolean exit_failure = FALSE;
342 gchar *M_cmd = NULL;
344 gint exit_code = EXIT_SUCCESS;
345 gchar *route_name = NULL;
346 gchar *get_name = NULL;
347 gchar *progname;
348 gchar *f_address = NULL;
349 gchar *full_sender_name = NULL;
350 address *return_path = NULL; /* may be changed by -f option */
352 progname = get_progname(argv[0]);
354 if (strcmp(progname, "mailq") == 0) {
355 mta_mode = MODE_LIST;
356 } else if (strcmp(progname, "mailrm") == 0) {
357 mta_mode = MODE_MCMD;
358 M_cmd = "rm";
359 } else if (strcmp(progname, "runq") == 0) {
360 mta_mode = MODE_RUNQUEUE;
361 do_runq = TRUE;
362 } else if (strcmp(progname, "rmail") == 0) {
363 mta_mode = MODE_ACCEPT;
364 opt_i = TRUE;
365 } else if (strcmp(progname, "smtpd") == 0 || strcmp(progname, "in.smtpd") == 0) {
366 mta_mode = MODE_SMTP;
367 }
369 /* parse cmd line */
370 while (arg < argc) {
371 gint pos = 0;
372 if ((argv[arg][pos] == '-') && (argv[arg][pos + 1] != '-')) {
373 pos++;
374 switch (argv[arg][pos++]) {
375 case 'b':
376 switch (argv[arg][pos++]) {
377 case 'd':
378 do_listen = TRUE;
379 mta_mode = MODE_DAEMON;
380 break;
381 case 'i':
382 /* ignored */
383 mta_mode = MODE_BI;
384 break;
385 case 's':
386 mta_mode = MODE_SMTP;
387 break;
388 case 'p':
389 mta_mode = MODE_LIST;
390 break;
391 case 'V':
392 mta_mode = MODE_VERSION;
393 break;
394 default:
395 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
396 exit(EXIT_FAILURE);
397 }
398 break;
399 case 'B':
400 /* we ignore this and throw the argument away */
401 get_optarg(argv, argc, &arg, &pos);
402 break;
403 case 'C':
404 if (!(conf_file = get_optarg(argv, argc, &arg, &pos))) {
405 fprintf(stderr, "-C requires a filename as argument.\n");
406 exit(EXIT_FAILURE);
407 }
408 break;
409 case 'F':
410 {
411 full_sender_name = get_optarg(argv, argc, &arg, &pos);
412 if (!full_sender_name) {
413 fprintf(stderr, "-F requires a name as an argument\n");
414 exit(EXIT_FAILURE);
415 }
416 }
417 break;
418 case 'd':
419 if (getuid() == 0) {
420 char *lvl = get_optarg(argv, argc, &arg, &pos);
421 if (lvl)
422 debug_level = atoi(lvl);
423 else {
424 fprintf(stderr, "-d requires a number as an argument.\n");
425 exit(EXIT_FAILURE);
426 }
427 } else {
428 fprintf(stderr, "only root may set the debug level.\n");
429 exit(EXIT_FAILURE);
430 }
431 break;
432 case 'f':
433 /* set return path */
434 {
435 gchar *address;
436 address = get_optarg(argv, argc, &arg, &pos);
437 if (address) {
438 f_address = g_strdup(address);
439 } else {
440 fprintf(stderr, "-f requires an address as an argument\n");
441 exit(EXIT_FAILURE);
442 }
443 }
444 break;
445 case 'g':
446 do_get = TRUE;
447 if (!mta_mode)
448 mta_mode = MODE_NONE; /* to prevent default MODE_ACCEPT */
449 if (argv[arg][pos] == 'o') {
450 pos++;
451 do_get_online = TRUE;
452 /* can be NULL, then we use online detection method */
453 route_name = get_optarg(argv, argc, &arg, &pos);
455 if (route_name != NULL) {
456 if (isdigit(route_name[0])) {
457 get_interval = time_interval(route_name, &pos);
458 route_name = get_optarg(argv, argc, &arg, &pos);
459 mta_mode = MODE_GET_DAEMON;
460 do_get = FALSE;
461 }
462 }
463 } else {
464 if ((optarg = get_optarg(argv, argc, &arg, &pos))) {
465 get_name = get_optarg(argv, argc, &arg, &pos);
466 }
467 }
468 break;
469 case 'i':
470 if (argv[arg][pos] == 0) {
471 opt_i = TRUE;
472 exit_failure = FALSE; /* may override -oem */
473 } else {
474 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
475 exit(EXIT_FAILURE);
476 }
477 break;
478 case 'M':
479 {
480 mta_mode = MODE_MCMD;
481 M_cmd = g_strdup(&(argv[arg][pos]));
482 }
483 break;
484 case 'o':
485 switch (argv[arg][pos++]) {
486 case 'e':
487 if (argv[arg][pos++] == 'm') /* -oem */
488 if (!opt_i)
489 exit_failure = TRUE;
490 opt_oem = TRUE;
491 break;
492 case 'd':
493 if (argv[arg][pos] == 'b') /* -odb */
494 opt_odb = TRUE;
495 else if (argv[arg][pos] == 'q') /* -odq */
496 do_queue = TRUE;
497 break;
498 case 'i':
499 opt_i = TRUE;
500 exit_failure = FALSE; /* may override -oem */
501 break;
502 }
503 break;
505 case 'q':
506 {
507 gchar *optarg;
509 do_runq = TRUE;
510 mta_mode = MODE_RUNQUEUE;
511 if (argv[arg][pos] == 'o') {
512 pos++;
513 do_runq = FALSE;
514 do_runq_online = TRUE;
515 /* can be NULL, then we use online detection method */
516 route_name = get_optarg(argv, argc, &arg, &pos);
517 } else
518 if ((optarg = get_optarg(argv, argc, &arg, &pos))) {
519 mta_mode = MODE_DAEMON;
520 queue_interval = time_interval(optarg, &pos);
521 }
522 }
523 break;
524 case 't':
525 if (argv[arg][pos] == 0) {
526 opt_t = TRUE;
527 } else {
528 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
529 exit(EXIT_FAILURE);
530 }
531 break;
532 case 'v':
533 do_verbose = TRUE;
534 break;
535 default:
536 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
537 exit(EXIT_FAILURE);
538 }
539 } else {
540 if (argv[arg][pos + 1] == '-') {
541 if (argv[arg][pos + 2] != '\0') {
542 fprintf(stderr, "unrecognized option '%s'\n", argv[arg]);
543 exit(EXIT_FAILURE);
544 }
545 arg++;
546 }
547 break;
548 }
549 arg++;
550 }
552 if (mta_mode == MODE_VERSION) {
553 gchar *with_resolver = "";
554 gchar *with_smtp_server = "";
555 gchar *with_pop3 = "";
556 gchar *with_auth = "";
557 gchar *with_maildir = "";
558 gchar *with_ident = "";
559 gchar *with_mserver = "";
561 #ifdef ENABLE_RESOLVER
562 with_resolver = " +resolver";
563 #endif
564 #ifdef ENABLE_SMTP_SERVER
565 with_smtp_server = " +smtp-server";
566 #endif
567 #ifdef ENABLE_POP3
568 with_pop3 = " +pop3";
569 #endif
570 #ifdef ENABLE_AUTH
571 with_auth = " +auth";
572 #endif
573 #ifdef ENABLE_MAILDIR
574 with_maildir = " +maildir";
575 #endif
576 #ifdef ENABLE_IDENT
577 with_ident = " +ident";
578 #endif
579 #ifdef ENABLE_MSERVER
580 with_mserver = " +mserver";
581 #endif
583 printf("%s %s%s%s%s%s%s%s%s\n", PACKAGE, VERSION, with_resolver, with_smtp_server,
584 with_pop3, with_auth, with_maildir, with_ident, with_mserver);
586 exit(EXIT_SUCCESS);
587 }
589 /* initialize random generator */
590 srand(time(NULL));
591 /* ignore SIGPIPE signal */
592 signal(SIGPIPE, SIG_IGN);
594 /* close all possibly open file descriptors */
595 {
596 int i, max_fd = sysconf(_SC_OPEN_MAX);
598 if (max_fd <= 0)
599 max_fd = 64;
600 for (i = 3; i < max_fd; i++)
601 close(i);
602 }
604 init_conf();
606 /* if we are not privileged, and the config file was changed we
607 implicetely set the the run_as_user flag and give up all
608 privileges.
610 So it is possible for a user to run his own daemon without
611 breaking security.
612 */
613 if (strcmp(conf_file, CONF_FILE) != 0) {
614 if (conf.orig_uid != 0) {
615 conf.run_as_user = TRUE;
616 seteuid(conf.orig_uid);
617 setegid(conf.orig_gid);
618 setuid(conf.orig_uid);
619 setgid(conf.orig_gid);
620 }
621 }
623 read_conf(conf_file);
625 if (do_queue)
626 conf.do_queue = TRUE;
627 if (do_verbose)
628 conf.do_verbose = TRUE;
629 if (debug_level >= 0) /* if >= 0, it was given by argument */
630 conf.debug_level = debug_level;
632 chdir("/");
634 if (!conf.run_as_user) {
635 if (setgid(0) != 0) {
636 fprintf(stderr, "could not set gid to 0. Is the setuid bit set? : %s\n", strerror(errno));
637 exit(EXIT_FAILURE);
638 }
639 if (setuid(0) != 0) {
640 fprintf(stderr, "could not gain root privileges. Is the setuid bit set? : %s\n", strerror(errno));
641 exit(EXIT_FAILURE);
642 }
643 }
645 if (!logopen()) {
646 fprintf(stderr, "could not open log file\n");
647 exit(EXIT_FAILURE);
648 }
650 DEBUG(1) debugf("masqmail %s starting\n", VERSION);
652 DEBUG(5) {
653 gchar **str = argv;
654 debugf("args: \n");
655 while (*str) {
656 debugf("%s \n", *str);
657 str++;
658 }
659 }
660 DEBUG(5) debugf("queue_interval = %d\n", queue_interval);
662 if (f_address) {
663 return_path = create_address_qualified(f_address, TRUE, conf.host_name);
664 g_free(f_address);
665 if (!return_path) {
666 fprintf(stderr, "invalid RFC821 address: %s\n", f_address);
667 exit(EXIT_FAILURE);
668 }
669 }
671 if (do_get) {
672 #ifdef ENABLE_POP3
673 if ((mta_mode == MODE_NONE) || (mta_mode == MODE_RUNQUEUE)) {
674 set_identity(conf.orig_uid, "getting mail");
675 if (do_get_online) {
676 if (route_name != NULL) {
677 conf.online_detect = g_strdup("argument");
678 set_online_name(route_name);
679 }
680 get_online();
681 } else {
682 if (get_name)
683 get_from_name(get_name);
684 else
685 get_all();
686 }
687 } else {
688 logwrite(LOG_ALERT, "get (-g) only allowed alone or together with queue run (-q)\n");
689 }
690 #else
691 fprintf(stderr, "get (pop) support not compiled in\n");
692 #endif
693 }
695 switch (mta_mode) {
696 case MODE_DAEMON:
697 mode_daemon(do_listen, queue_interval, argv);
698 break;
699 case MODE_RUNQUEUE:
700 {
701 /* queue runs */
702 set_identity(conf.orig_uid, "queue run");
704 if (do_runq)
705 exit_code = queue_run() ? EXIT_SUCCESS : EXIT_FAILURE;
707 if (do_runq_online) {
708 if (route_name != NULL) {
709 conf.online_detect = g_strdup("argument");
710 set_online_name(route_name);
711 }
712 exit_code =
713 queue_run_online() ? EXIT_SUCCESS : EXIT_FAILURE;
714 }
715 }
716 break;
717 case MODE_GET_DAEMON:
718 #ifdef ENABLE_POP3
719 if (route_name != NULL) {
720 conf.online_detect = g_strdup("argument");
721 set_online_name(route_name);
722 }
723 mode_get_daemon(get_interval, argv);
724 #endif
725 break;
727 case MODE_SMTP:
728 #ifdef ENABLE_SMTP_SERVER
729 mode_smtp();
730 #else
731 fprintf(stderr, "smtp server support not compiled in\n");
732 #endif
733 break;
735 case MODE_LIST:
736 queue_list();
737 break;
739 case MODE_BI:
740 exit(EXIT_SUCCESS);
741 break; /* well... */
743 case MODE_MCMD:
744 if (strcmp(M_cmd, "rm") == 0) {
745 gboolean ok = FALSE;
747 set_euidgid(conf.mail_uid, conf.mail_gid, NULL, NULL);
749 if (is_privileged_user(conf.orig_uid)) {
750 for (; arg < argc; arg++) {
751 if (queue_delete(argv[arg]))
752 ok = TRUE;
753 }
754 } else {
755 struct passwd *pw = getpwuid(conf.orig_uid);
756 if (pw) {
757 for (; arg < argc; arg++) {
758 message *msg = msg_spool_read(argv[arg], FALSE);
759 #ifdef ENABLE_IDENT
760 if (((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL))
761 || is_in_netlist(msg->received_host, conf.ident_trusted_nets)) {
762 #else
763 if ((msg->received_host == NULL) && (msg->received_prot == PROT_LOCAL)) {
764 #endif
765 if (msg->ident) {
766 if (strcmp(pw->pw_name, msg->ident) == 0) {
767 if (queue_delete(argv[arg]))
768 ok = TRUE;
769 } else {
770 fprintf(stderr, "you do not own message id %s\n", argv[arg]);
771 }
772 } else
773 fprintf(stderr, "message %s does not have an ident.\n", argv[arg]);
774 } else {
775 fprintf(stderr, "message %s was not received locally or from a trusted network.\n", argv[arg]);
776 }
777 }
778 } else {
779 fprintf(stderr, "could not find a passwd entry for uid %d: %s\n", conf.orig_uid, strerror(errno));
780 }
781 }
782 exit(ok ? EXIT_SUCCESS : EXIT_FAILURE);
783 } else {
784 fprintf(stderr, "unknown command %s\n", M_cmd);
785 exit(EXIT_FAILURE);
786 }
787 break;
789 case MODE_ACCEPT:
790 {
791 guint accept_flags = (opt_t ? ACC_DEL_RCPTS | ACC_DEL_BCC | ACC_RCPT_FROM_HEAD : ACC_HEAD_FROM_RCPT)
792 | (opt_i ? ACC_NODOT_TERM : ACC_NODOT_RELAX);
793 mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg);
794 exit(exit_failure ? EXIT_FAILURE : EXIT_SUCCESS);
795 }
796 break;
797 case MODE_NONE:
798 break;
799 default:
800 fprintf(stderr, "unknown mode: %d\n", mta_mode);
801 break;
802 }
804 logclose();
806 exit(exit_code);
807 }