2 * fetchmail.c -- main driver module for fetchmail
4 * For license terms, see the file COPYING in this directory.
9 #if defined(STDC_HEADERS)
12 #if defined(HAVE_UNISTD_H)
18 #if defined(HAVE_SYSLOG)
26 #include <sys/types.h>
28 #include <sys/time.h> /* needed for Sun 4.1.2 */
30 #include <sys/resource.h>
31 #endif /* HAVE_SETRLIMIT */
32 #include <sys/utsname.h>
34 #ifdef HAVE_NET_SOCKET_H
35 #include <net/socket.h>
37 #ifdef HAVE_GETHOSTBYNAME
39 #endif /* HAVE_GETHOSTBYNAME */
46 #include "fetchmail.h"
54 #define ENETUNREACH 128 /* Interactive doesn't know this */
55 #endif /* ENETUNREACH */
57 /* prototypes for internal functions */
58 static int load_params(int, char **, int);
59 static void dump_params (struct runctl *runp, struct query *, flag implicit);
60 static int query_host(struct query *);
62 /* controls the detail level of status/progress messages written to stderr */
63 int outlevel; /* see the O_.* constants above */
65 /* miscellaneous global controls */
66 struct runctl run; /* global controls for this run */
67 flag nodetach; /* if TRUE, don't detach daemon process */
68 flag quitmode; /* if --quit was set */
69 flag check_only; /* if --probe was set */
70 flag versioninfo; /* emit only version info */
71 char *user; /* the name of the invoking user */
72 char *home; /* invoking user's home directory */
73 char *fmhome; /* fetchmail's home directory */
74 char *program_name; /* the name to prefix error messages with */
75 flag configdump; /* dump control blocks for configurator */
76 const char *fetchmailhost; /* either `localhost' or the host's FQDN */
81 #endif /* NET_SECURITY */
83 static int querystatus; /* status of query */
84 static int successes; /* count number of successful polls */
85 static int activecount; /* count number of active entries */
86 static struct runctl cmd_run; /* global options set from command line */
87 static time_t parsetime; /* time of last parse */
89 static void terminate_run(int);
90 static void terminate_poll(int);
92 #if defined(__FreeBSD__) && defined(__FreeBSD_USE_KVM)
93 /* drop SGID kmem privileage until we need it */
94 static void dropprivs(void)
104 if (gr && !strcmp(gr->gr_name, "kmem"))
106 extern void interface_set_gids(gid_t egid, gid_t rgid);
107 interface_set_gids(egid, rgid);
113 #if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME)
116 static char *timestamp (void)
122 setlocale (LC_TIME, "");
123 strftime (buf, sizeof (buf), "%c", localtime(&now));
124 setlocale (LC_TIME, "C");
128 #define timestamp rfc822timestamp
131 int main(int argc, char **argv)
133 int st, bkgd = FALSE;
134 int parsestatus, implicitmode = FALSE;
136 netrc_entry *netrc_list;
137 char *netrc_file, *tmpbuf;
141 #if defined(__FreeBSD__) && defined(__FreeBSD_USE_KVM)
145 envquery(argc, argv);
147 setlocale (LC_ALL, "");
148 bindtextdomain(PACKAGE, LOCALEDIR);
153 * Note: because we can't initialize reporting before we know whether
154 * syslog is supposed to be on, this message will go to stdout and
155 * be lost when running in background.
157 if (outlevel >= O_VERBOSE)
161 report(stdout, _("fetchmail: invoked with"));
162 for (i = 0; i < argc; i++)
163 report(stdout, " %s", argv[i]);
164 report(stdout, "\n");
167 #define IDFILE_NAME ".fetchids"
168 run.idfile = (char *) xmalloc(strlen(fmhome)+sizeof(IDFILE_NAME)+2);
169 strcpy(run.idfile, fmhome);
170 strcat(run.idfile, "/");
171 strcat(run.idfile, IDFILE_NAME);
176 * We used to arrange for the lock to be removed on exit close
177 * to where the lock was asserted. Now we need to do it here, because
178 * we might have re-executed in background with an existing lock
179 * as the result of a changed rcfile (see the code near the execvp(3)
180 * call near the beginning of the polling loop for details). We want
181 * to be sure the lock gets nuked on any error exit, basically.
185 if ((parsestatus = parsecmdline(argc,argv, &cmd_run, &cmd_opts)) < 0)
190 printf(_("This is fetchmail release %s"), VERSION);
193 #endif /* POP2_ENABLE */
196 #endif /* POP3_ENABLE */
199 #endif /* IMAP_ENABLE */
205 #endif /* RPA_ENABLE */
208 #endif /* NTLM_ENABLE */
211 #endif /* SDPS_ENABLE */
214 #endif /* ETRN_ENABLE */
217 #endif /* ODMR_ENABLE */
223 #endif /* OPIE_ENABLE */
226 #endif /* INET6_ENABLE */
229 #endif /* NET_SECURITY */
232 #endif /* HAVE_SOCKS */
235 #endif /* ENABLE_NLS */
239 /* this is an attempt to help remote debugging */
243 /* avoid parsing the config file if all we're doing is killing a daemon */
244 if (!(quitmode && argc == 2))
245 implicitmode = load_params(argc, argv, optind);
247 #if defined(HAVE_SYSLOG)
248 /* logging should be set up early in case we were restarted from exec */
251 #if defined(LOG_MAIL)
252 openlog(program_name, LOG_PID, LOG_MAIL);
254 /* Assume BSD4.2 openlog with two arguments */
255 openlog(program_name, LOG_PID);
261 report_init((run.poll_interval == 0 || nodetach) && !run.logfile);
263 /* construct the lockfile */
266 #ifdef HAVE_SETRLIMIT
268 * Before getting passwords, disable core dumps unless -v -d0 mode is on.
269 * Core dumps could otherwise contain passwords to be scavenged by a
272 if (outlevel < O_VERBOSE || run.poll_interval > 0)
274 struct rlimit corelimit;
275 corelimit.rlim_cur = 0;
276 corelimit.rlim_max = 0;
277 setrlimit(RLIMIT_CORE, &corelimit);
279 #endif /* HAVE_SETRLIMIT */
281 #define NETRC_FILE ".netrc"
282 /* parse the ~/.netrc file (if present) for future password lookups. */
283 xalloca(netrc_file, char *, strlen(home) + sizeof(NETRC_FILE) + 2);
284 strcpy (netrc_file, home);
285 strcat (netrc_file, "/");
286 strcat (netrc_file, NETRC_FILE);
287 netrc_list = parse_netrc(netrc_file);
290 /* pick up passwords where we can */
291 for (ctl = querylist; ctl; ctl = ctl->next)
293 if (ctl->active && !(implicitmode && ctl->server.skip)&&!ctl->password)
295 if (NO_PASSWORD(ctl))
296 /* Server won't care what the password is, but there
297 must be some non-null string here. */
298 ctl->password = ctl->remotename;
303 /* look up the pollname and account in the .netrc file. */
304 p = search_netrc(netrc_list,
305 ctl->server.pollname, ctl->remotename);
306 /* if we find a matching entry with a password, use it */
307 if (p && p->password)
308 ctl->password = xstrdup(p->password);
310 /* otherwise try with "via" name if there is one */
311 else if (ctl->server.via)
313 p = search_netrc(netrc_list,
314 ctl->server.via, ctl->remotename);
315 if (p && p->password)
316 ctl->password = xstrdup(p->password);
322 /* perhaps we just want to check options? */
325 int havercfile = access(rcfile, 0);
327 printf(_("Taking options from command line%s%s\n"),
328 havercfile ? "" : _(" and "),
329 havercfile ? "" : rcfile);
331 if (querylist == NULL)
333 _("No mailservers set up -- perhaps %s is missing?\n"),
336 dump_params(&run, querylist, implicitmode);
340 /* dump options as a Python dictionary, for configurator use */
343 dump_config(&run, querylist);
347 /* check for another fetchmail running concurrently */
350 pid = bkgd ? -pid : pid;
352 /* if no mail servers listed and nothing in background, we're done */
353 if (!(quitmode && argc == 2) && pid == 0 && querylist == NULL) {
354 (void)fputs(_("fetchmail: no mailservers have been specified.\n"),stderr);
358 /* perhaps user asked us to kill the other fetchmail */
363 fprintf(stderr,_("fetchmail: no other fetchmail is running\n"));
367 else if (kill(pid, SIGTERM) < 0)
369 fprintf(stderr,_("fetchmail: error killing %s fetchmail at %d; bailing out.\n"),
370 bkgd ? _("background") : _("foreground"), pid);
375 fprintf(stderr,_("fetchmail: %s fetchmail at %d killed.\n"),
376 bkgd ? _("background") : _("foreground"), pid);
385 /* another fetchmail is running -- wake it up or die */
391 _("fetchmail: can't check mail while another fetchmail to same host is running.\n"));
394 else if (!implicitmode)
397 _("fetchmail: can't poll specified hosts with another fetchmail running at %d.\n"),
404 _("fetchmail: another foreground fetchmail is running at %d.\n"),
410 /* this test enables re-execing on a changed rcfile */
416 _("fetchmail: can't accept options while a background fetchmail is running.\n"));
420 else if (kill(pid, SIGUSR1) == 0)
423 _("fetchmail: background fetchmail at %d awakened.\n"),
430 * Should never happen -- possible only if a background fetchmail
431 * croaks after the first kill probe above but before the
432 * SIGUSR1/SIGHUP transmission.
435 _("fetchmail: elder sibling at %d died mysteriously.\n"),
437 return(PS_UNDEFINED);
441 /* pick up interactively any passwords we need but don't have */
442 for (ctl = querylist; ctl; ctl = ctl->next)
444 if (ctl->active && !(implicitmode && ctl->server.skip)
445 && !NO_PASSWORD(ctl) && !ctl->password)
450 _("fetchmail: can't find a password for %s@%s.\n"),
451 ctl->remotename, ctl->server.pollname);
456 char* password_prompt = _("Enter password for %s@%s: ");
458 xalloca(tmpbuf, char *, strlen(password_prompt) +
459 strlen(ctl->remotename) +
460 strlen(ctl->server.pollname) + 1);
461 (void) sprintf(tmpbuf, password_prompt,
462 ctl->remotename, ctl->server.pollname);
463 ctl->password = xstrdup((char *)fm_getpassword(tmpbuf));
469 * Time to initiate the SOCKS library (this is not mandatory: it just
470 * registers the correct application name for logging purpose. If you
471 * have some problem, comment out these lines).
474 SOCKSinit("fetchmail");
475 #endif /* HAVE_SOCKS */
478 * Maybe time to go to demon mode...
480 if (run.poll_interval)
485 daemonize(run.logfile, terminate_run);
486 report(stdout, _("starting fetchmail %s daemon \n"), VERSION);
489 * We'll set up a handler for these when we're sleeping,
490 * but ignore them otherwise so as not to interrupt a poll.
492 signal(SIGUSR1, SIG_IGN);
493 if (run.poll_interval && !getuid())
494 signal(SIGHUP, SIG_IGN);
496 else if (run.logfile && access(run.logfile, F_OK) == 0)
498 freopen(run.logfile, "a", stdout);
499 freopen(run.logfile, "a", stderr);
507 /* beyond here we don't want more than one fetchmail running per user */
509 signal(SIGABRT, terminate_run);
510 signal(SIGINT, terminate_run);
511 signal(SIGTERM, terminate_run);
512 signal(SIGALRM, terminate_run);
513 signal(SIGPIPE, terminate_run);
514 signal(SIGQUIT, terminate_run);
516 /* here's the exclusion lock */
520 * Query all hosts. If there's only one, the error return will
521 * reflect the status of that transaction.
525 * Check to see if the rcfile has been touched. If so,
526 * re-exec so the file will be reread. Doing it this way
527 * avoids all the complications of trying to deallocate the
528 * in-core control structures -- and the potential memory
533 if (stat(rcfile, &rcstat) == -1)
537 _("couldn't time-check %s (error %d)\n"),
540 else if (rcstat.st_mtime > parsetime)
542 report(stdout, _("restarting fetchmail (%s changed)\n"), rcfile);
544 * Matthias Andree: Isn't this prone to introduction of
545 * "false" programs by interfering with PATH? Those
546 * path-searching execs might not be the best ideas for
549 * Rob Funk: But is there any way for someone to modify
550 * the PATH variable of a running fetchmail? I don't know
553 * Dave's change makes fetchmail restart itself in exactly
554 * the way it was started from the shell (or shell script)
555 * in the first place. If you're concerned about PATH
556 * contamination, call fetchmail initially with a full
557 * path, and use Dave's patch.
559 * Not using a -p variant of exec means that the restart
560 * will break if both (a) the user depended on PATH to
561 * call fetchmail in the first place, and (b) the system
562 * doesn't save the whole path in argv[0] if the whole
563 * path wasn't used in the initial call. (If I recall
564 * correctly, Linux saves it but many other Unices don't.)
566 execvp(argv[0], argv);
567 report(stderr, _("attempt to re-exec fetchmail failed\n"));
570 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
572 * This was an efficiency hack that backfired. The theory
573 * was that using TCP/IP for DNS queries would get us better
574 * reliability and shave off some per-UDP-packet costs.
575 * Unfortunately it interacted badly with diald, which effectively
576 * filters out DNS queries over TCP/IP for reasons having to do
577 * with some obscure Linux kernel problem involving bootstrapping of
578 * dynamically-addressed links. I don't understand this mess
579 * and don't want to, so it's "See ya!" to this hack.
581 sethostent(TRUE); /* use TCP/IP for mailserver queries */
582 #endif /* HAVE_RES_SEARCH */
586 for (ctl = querylist; ctl; ctl = ctl->next)
590 if (!(implicitmode && ctl->server.skip))
595 _("poll of %s skipped (failed authentication or too many timeouts)\n"),
596 ctl->server.pollname);
600 /* check skip interval first so that it counts all polls */
601 if (run.poll_interval && ctl->server.interval)
603 if (ctl->server.poll_count++ % ctl->server.interval)
605 if (outlevel >= O_VERBOSE)
607 _("interval not reached, not querying %s\n"),
608 ctl->server.pollname);
613 #if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__)
615 * Don't do monitoring if we were woken by a signal.
616 * Note that interface_approve() does its own error logging.
618 if (!interface_approve(&ctl->server, !lastsig))
620 #endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */
622 querystatus = query_host(ctl);
625 /* leave the UIDL state alone if there have been any errors */
627 ((querystatus==PS_SUCCESS) || (querystatus==PS_NOMAIL) || (querystatus==PS_MAXFETCH)))
629 #endif /* POP3_ENABLE */
631 if (querystatus == PS_SUCCESS)
633 else if (!check_only &&
634 ((querystatus!=PS_NOMAIL) || (outlevel==O_DEBUG)))
638 report(stdout,_("Query status=0 (SUCCESS)\n"));break;
640 report(stdout,_("Query status=1 (NOMAIL)\n")); break;
642 report(stdout,_("Query status=2 (SOCKET)\n")); break;
644 report(stdout,_("Query status=3 (AUTHFAIL)\n"));break;
646 report(stdout,_("Query status=4 (PROTOCOL)\n"));break;
648 report(stdout,_("Query status=5 (SYNTAX)\n")); break;
650 report(stdout,_("Query status=6 (IOERR)\n")); break;
652 report(stdout,_("Query status=7 (ERROR)\n")); break;
654 report(stdout,_("Query status=8 (EXCLUDE)\n")); break;
656 report(stdout,_("Query status=9 (LOCKBUSY)\n"));break;
658 report(stdout,_("Query status=10 (SMTP)\n")); break;
660 report(stdout,_("Query status=11 (DNS)\n")); break;
662 report(stdout,_("Query status=12 (BSMTP)\n")); break;
664 report(stdout,_("Query status=13 (MAXFETCH)\n"));break;
666 report(stdout,_("Query status=%d\n"),querystatus);
670 #if (defined(linux) && !INET6_ENABLE) || defined (__FreeBSD__)
671 if (ctl->server.monitor)
674 * Allow some time for the link to quiesce. One
675 * second is usually sufficient, three is safe.
676 * Note: this delay is important - don't remove!
679 interface_note_activity(&ctl->server);
681 #endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */
685 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
686 endhostent(); /* release TCP/IP connection to nameserver */
687 #endif /* HAVE_RES_SEARCH */
689 /* close connections cleanly */
693 * OK, we've polled. Now sleep.
695 if (run.poll_interval)
698 * Because passwords can expire, it may happen that *all*
699 * hosts are now out of the loop due to authfail
700 * conditions. If this happens daemon-mode fetchmail
701 * should softly and silently vanish away, rather than
702 * spinning uselessly.
706 for (ctl = querylist; ctl; ctl = ctl->next)
707 if (ctl->active && !(implicitmode && ctl->server.skip))
712 report(stderr, _("All connections are wedged. Exiting.\n"));
713 /* FIXME: someday, send notification mail */
717 if (outlevel >= O_VERBOSE)
719 _("fetchmail: sleeping at %s\n"), timestamp());
722 * OK, now pause util it's time for the next poll cycle.
723 * A nonzero return indicates we received a wakeup signal;
724 * unwedge all servers in case the problem has been
727 if ((lastsig = interruptible_idle(run.poll_interval)))
729 #ifdef SYS_SIGLIST_DECLARED
731 _("awakened by %s\n"), sys_siglist[lastsig]);
734 _("awakened by signal %d\n"), lastsig);
736 for (ctl = querylist; ctl; ctl = ctl->next)
740 if (outlevel >= O_VERBOSE)
741 report(stdout, _("awakened at %s\n"), timestamp());
746 if (outlevel >= O_VERBOSE)
747 report(stdout, _("normal termination, status %d\n"),
748 successes ? PS_SUCCESS : querystatus);
754 else if (querystatus)
757 /* in case we interrupted before a successful fetch */
761 static void list_merge(struct idlist **dstl, struct idlist **srcl, int force)
764 * If force is off, modify dstl fields only when they're empty (treat srcl
765 * as defaults). If force is on, modify each dstl field whenever scrcl
766 * is nonempty (treat srcl as an override).
768 if (force ? !!*srcl : !*dstl)
770 struct idlist *cpl = copy_str_list(*srcl);
772 append_str_list(dstl, &cpl);
776 static void optmerge(struct query *h2, struct query *h1, int force)
777 /* merge two options records */
779 list_merge(&h2->server.localdomains, &h1->server.localdomains, force);
780 list_merge(&h2->localnames, &h1->localnames, force);
781 list_merge(&h2->mailboxes, &h1->mailboxes, force);
782 list_merge(&h2->smtphunt, &h1->smtphunt, force);
783 list_merge(&h2->antispam, &h1->antispam, force);
785 #define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
786 FLAG_MERGE(server.via);
787 FLAG_MERGE(server.protocol);
789 FLAG_MERGE(server.service);
790 FLAG_MERGE(server.netsec);
791 #else /* INET6_ENABLE */
792 FLAG_MERGE(server.port);
793 #endif /* INET6_ENABLE */
794 FLAG_MERGE(server.interval);
795 FLAG_MERGE(server.authenticate);
796 FLAG_MERGE(server.timeout);
797 FLAG_MERGE(server.envelope);
798 FLAG_MERGE(server.envskip);
799 FLAG_MERGE(server.qvirtual);
800 FLAG_MERGE(server.skip);
801 FLAG_MERGE(server.dns);
802 FLAG_MERGE(server.checkalias);
803 FLAG_MERGE(server.uidl);
804 FLAG_MERGE(server.principal);
806 #if defined(linux) || defined(__FreeBSD__)
807 FLAG_MERGE(server.interface);
808 FLAG_MERGE(server.monitor);
809 FLAG_MERGE(server.interface_pair);
810 #endif /* linux || defined(__FreeBSD__) */
812 FLAG_MERGE(server.plugin);
813 FLAG_MERGE(server.plugout);
815 FLAG_MERGE(wildcard);
816 FLAG_MERGE(remotename);
817 FLAG_MERGE(password);
820 FLAG_MERGE(listener);
821 FLAG_MERGE(smtpaddress);
822 FLAG_MERGE(smtpname);
823 FLAG_MERGE(preconnect);
824 FLAG_MERGE(postconnect);
828 FLAG_MERGE(fetchall);
832 FLAG_MERGE(pass8bits);
833 FLAG_MERGE(dropstatus);
834 FLAG_MERGE(dropdelivered);
835 FLAG_MERGE(mimedecode);
838 FLAG_MERGE(warnings);
839 FLAG_MERGE(fetchlimit);
840 FLAG_MERGE(batchlimit);
845 FLAG_MERGE(sslproto);
849 FLAG_MERGE(properties);
853 static int load_params(int argc, char **argv, int optind)
855 int implicitmode, st;
857 struct query def_opts, *ctl;
860 run.bouncemail = TRUE;
861 run.spambounce = FALSE; /* don't bounce back to innocent bystanders */
863 memset(&def_opts, '\0', sizeof(struct query));
864 def_opts.smtp_socket = -1;
865 def_opts.smtpaddress = (char *)0;
866 def_opts.smtpname = (char *)0;
867 #define ANTISPAM(n) save_str(&def_opts.antispam, STRING_DUMMY, 0)->val.status.num = (n)
868 ANTISPAM(571); /* sendmail */
869 ANTISPAM(550); /* old exim */
870 ANTISPAM(501); /* new exim */
871 ANTISPAM(554); /* Postfix */
874 def_opts.server.protocol = P_AUTO;
875 def_opts.server.timeout = CLIENT_TIMEOUT;
876 def_opts.warnings = WARNING_INTERVAL;
877 def_opts.remotename = user;
878 def_opts.listener = SMTP_MODE;
880 /* note the parse time, so we can pick up on modifications */
881 parsetime = 0; /* foil compiler warnings */
882 if (stat(rcfile, &rcstat) != -1)
883 parsetime = rcstat.st_mtime;
884 else if (errno != ENOENT)
885 report(stderr, _("couldn't time-check the run-control file\n"));
887 /* this builds the host list */
888 if ((st = prc_parse_file(rcfile, !versioninfo)) != 0)
890 * FIXME: someday, send notification mail here if backgrounded.
891 * Right now, that can happen if the user changes the rcfile
892 * while the fetchmail is running in background. Do similarly
893 * for the other exit() calls in this function.
897 if ((implicitmode = (optind >= argc)))
899 for (ctl = querylist; ctl; ctl = ctl->next)
903 for (; optind < argc; optind++)
905 flag predeclared = FALSE;
908 * If hostname corresponds to a host known from the rc file,
909 * simply declare it active. Otherwise synthesize a host
910 * record from command line and defaults
912 for (ctl = querylist; ctl; ctl = ctl->next)
913 if (!strcmp(ctl->server.pollname, argv[optind])
914 || str_in_list(&ctl->server.akalist, argv[optind], TRUE))
916 /* Is this correct? */
917 if (predeclared && outlevel == O_VERBOSE)
918 fprintf(stderr,_("Warning: multiple mentions of host %s in config file\n"),argv[optind]);
926 * Allocate and link record without copying in
927 * command-line args; we'll do that with the optmerge
930 ctl = hostalloc((struct query *)NULL);
932 ctl->server.pollname = xstrdup(argv[optind]);
934 ctl->server.lead_server = (struct hostdata *)NULL;
939 * If there's a defaults record, merge it and lose it.
941 if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
943 for (ctl = querylist->next; ctl; ctl = ctl->next)
944 optmerge(ctl, querylist, FALSE);
945 querylist = querylist->next;
948 /* don't allow a defaults record after the first */
949 for (ctl = querylist; ctl; ctl = ctl->next)
950 if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
953 /* use localhost if we never fetch the FQDN of this host */
954 fetchmailhost = "localhost";
956 /* here's where we override globals */
958 run.logfile = cmd_run.logfile;
960 run.idfile = cmd_run.idfile;
961 /* do this before the keep/fetchall test below, otherwise -d0 may fail */
962 if (cmd_run.poll_interval >= 0)
963 run.poll_interval = cmd_run.poll_interval;
964 if (cmd_run.invisible)
965 run.invisible = cmd_run.invisible;
966 if (cmd_run.showdots)
967 run.showdots = cmd_run.showdots;
968 if (cmd_run.use_syslog)
969 run.use_syslog = (cmd_run.use_syslog == FLAG_TRUE);
970 if (cmd_run.postmaster)
971 run.postmaster = cmd_run.postmaster;
972 if (cmd_run.bouncemail)
973 run.bouncemail = cmd_run.bouncemail;
975 /* check and daemon options are not compatible */
976 if (check_only && run.poll_interval)
977 run.poll_interval = 0;
979 /* merge in wired defaults, do sanity checks and prepare internal fields */
980 for (ctl = querylist; ctl; ctl = ctl->next)
984 if (configdump || ctl->active )
986 /* merge in defaults */
987 optmerge(ctl, &def_opts, FALSE);
989 /* force command-line options */
990 optmerge(ctl, &cmd_opts, TRUE);
992 /* this code enables flags to be turned off */
993 #define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
995 else if (flag == FLAG_FALSE)\
999 DEFAULT(ctl->keep, FALSE);
1000 DEFAULT(ctl->fetchall, FALSE);
1001 DEFAULT(ctl->flush, FALSE);
1002 DEFAULT(ctl->rewrite, TRUE);
1003 DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
1004 DEFAULT(ctl->forcecr, FALSE);
1005 DEFAULT(ctl->pass8bits, FALSE);
1006 DEFAULT(ctl->dropstatus, FALSE);
1007 DEFAULT(ctl->dropdelivered, FALSE);
1008 DEFAULT(ctl->mimedecode, FALSE);
1009 DEFAULT(ctl->idle, FALSE);
1010 DEFAULT(ctl->server.dns, TRUE);
1011 DEFAULT(ctl->server.uidl, FALSE);
1013 DEFAULT(ctl->use_ssl, FALSE);
1015 DEFAULT(ctl->server.checkalias, FALSE);
1019 * DNS support is required for some protocols. We used to
1020 * do this unconditionally, but it made fetchmail excessively
1021 * vulnerable to misconfigured DNS setups.
1023 * If we're using ETRN or ODMR, the smtp hunt list is the
1024 * list of systems we're polling on behalf of; these have
1025 * to be fully-qualified domain names. The default for
1026 * this list should be the FQDN of localhost.
1028 * If we're using Kerberos for authentication, we need
1029 * the FQDN in order to generate capability keys. */
1030 if (ctl->server.protocol==P_ETRN || ctl->server.protocol==P_ODMR
1031 || ctl->server.authenticate == A_KERBEROS_V4
1032 || ctl->server.authenticate == A_KERBEROS_V5)
1033 if (strcmp(fetchmailhost, "localhost") == 0)
1034 fetchmailhost = host_fqdn();
1037 * Make sure we have a nonempty host list to forward to.
1040 save_str(&ctl->smtphunt, fetchmailhost, FALSE);
1042 /* if `user' doesn't name a real local user, try to run as root */
1043 if ((pw = getpwnam(user)) == (struct passwd *)NULL)
1046 ctl->uid = pw->pw_uid; /* for local delivery via MDA */
1047 if (!ctl->localnames) /* for local delivery via SMTP */
1048 save_str_pair(&ctl->localnames, user, NULL);
1050 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
1051 /* can't handle multidrop mailboxes unless we can do DNS lookups */
1052 if (ctl->localnames && ctl->localnames->next && ctl->server.dns)
1054 ctl->server.dns = FALSE;
1055 report(stderr, _("fetchmail: warning: no DNS available to check multidrop fetches from %s\n"), ctl->server.pollname);
1057 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
1061 * Compute the true name of the mailserver host.
1062 * There are two clashing cases here:
1064 * (1) The poll name is a label, possibly on one of several
1065 * poll configurations for the same host. In this case
1066 * the `via' option will be present and give the true name.
1068 * (2) The poll name is the true one, the via name is
1069 * localhost. This is going to be typical for ssh-using
1072 * We're going to assume the via name is true unless it's
1075 if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
1076 ctl->server.queryname = xstrdup(ctl->server.via);
1078 ctl->server.queryname = xstrdup(ctl->server.pollname);
1081 /* If either the pollname or vianame are "hesiod" we want to
1082 lookup the user's hesiod pobox host */
1084 if (!strcasecmp(ctl->server.queryname, "hesiod")) {
1085 struct hes_postoffice *hes_p;
1086 hes_p = hes_getmailhost(ctl->remotename);
1087 if (hes_p != NULL && strcmp(hes_p->po_type, "POP") == 0) {
1088 free(ctl->server.queryname);
1089 ctl->server.queryname = xstrdup(hes_p->po_host);
1090 if (ctl->server.via)
1091 free(ctl->server.via);
1092 ctl->server.via = xstrdup(hes_p->po_host);
1095 _("couldn't find HESIOD pobox for %s\n"),
1102 * We may have to canonicalize the server truename for later use.
1103 * Do this just once for each lead server, if necessary, in order
1104 * to minimize DNS round trips.
1106 if (ctl->server.lead_server)
1108 char *leadname = ctl->server.lead_server->truename;
1110 /* prevent core dump from ill-formed or duplicate entry */
1113 report(stderr, _("Lead server has no name.\n"));
1117 ctl->server.truename = xstrdup(leadname);
1119 #ifdef HAVE_GETHOSTBYNAME
1120 else if (!configdump)
1122 if (ctl->server.authenticate==A_KERBEROS_V4 ||
1123 ctl->server.authenticate==A_KERBEROS_V5 ||
1124 (ctl->server.dns && MULTIDROP(ctl)))
1126 struct hostent *namerec;
1128 /* compute the canonical name of the host */
1130 namerec = gethostbyname(ctl->server.queryname);
1131 if (namerec == (struct hostent *)NULL)
1134 _("couldn't find canonical DNS name of %s\n"),
1135 ctl->server.pollname);
1136 ctl->server.truename = xstrdup(ctl->server.queryname);
1137 ctl->server.trueaddr = NULL;
1140 ctl->server.truename=xstrdup((char *)namerec->h_name);
1142 #endif /* HAVE_GETHOSTBYNAME */
1145 #ifdef HAVE_GETHOSTBYNAME
1146 struct hostent *namerec;
1149 * Get the host's IP, so we can report it like this:
1151 * Received: from hostname [10.0.0.1]
1153 * For ultra-efficiency, we should find the IP later, when
1154 * we are actually resolving the hostname for a connection.
1155 * Problem is this would have to be done inside SockOpen
1156 * and there's no way to do that that wouldn't both (a)
1157 * be horribly complicated, and (b) blow a couple of
1158 * layers of modularity all to hell.
1161 namerec = gethostbyname(ctl->server.queryname);
1162 if (namerec == (struct hostent *)NULL)
1165 _("couldn't find canonical DNS name of %s\n"),
1166 ctl->server.pollname);
1170 ctl->server.truename=xstrdup((char *)namerec->h_name);
1171 ctl->server.trueaddr=xmalloc(namerec->h_length);
1172 memcpy(ctl->server.trueaddr,
1173 namerec->h_addr_list[0],
1177 ctl->server.truename = xstrdup(ctl->server.queryname);
1178 #endif /* HAVE_GETHOSTBYNAME */
1183 * This is a kluge. It enables users to edit their
1184 * configurations when DNS isn't available.
1186 ctl->server.truename = xstrdup(ctl->server.queryname);
1188 /* if no folders were specified, set up the null one as default */
1189 if (!ctl->mailboxes)
1190 save_str(&ctl->mailboxes, (char *)NULL, 0);
1192 /* maybe user overrode timeout on command line? */
1193 if (ctl->server.timeout == -1)
1194 ctl->server.timeout = CLIENT_TIMEOUT;
1198 if (ctl->server.port < 0)
1200 (void) fprintf(stderr,
1201 _("%s configuration invalid, port number cannot be negative\n"),
1202 ctl->server.pollname);
1205 if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
1207 (void) fprintf(stderr,
1208 _("%s configuration invalid, RPOP requires a privileged port\n"),
1209 ctl->server.pollname);
1212 if (ctl->listener == LMTP_MODE)
1216 for (idp = ctl->smtphunt; idp; idp = idp->next)
1220 if (!(cp = strrchr(idp->id, '/')) ||
1221 (atoi(++cp) == SMTP_PORT))
1223 (void) fprintf(stderr,
1224 _("%s configuration invalid, LMTP can't use default SMTP port\n"),
1225 ctl->server.pollname);
1230 #endif /* !INET6_ENABLE */
1233 * "I beg to you, have mercy on the week minds like myself."
1234 * wrote Pehr Anderson. Your petition is granted.
1236 if (ctl->fetchall && ctl->keep && run.poll_interval && !nodetach)
1238 (void) fprintf(stderr,
1239 _("Both fetchall and keep on in daemon mode is a mistake!\n"));
1246 /* initialize UID handling */
1247 if (!versioninfo && (st = prc_filecheck(run.idfile, !versioninfo)) != 0)
1250 initialize_saved_lists(querylist, run.idfile);
1251 #endif /* POP3_ENABLE */
1254 * If the user didn't set a last-resort user to get misaddressed
1255 * multidrop mail, set an appropriate default here.
1257 if (!run.postmaster)
1259 if (getuid()) /* ordinary user */
1260 run.postmaster = user;
1262 run.postmaster = "postmaster";
1265 return(implicitmode);
1268 static void terminate_poll(int sig)
1269 /* to be executed at the end of a poll cycle */
1272 * Close all SMTP delivery sockets. For optimum performance
1273 * we'd like to hold them open til end of run, but (1) this
1274 * loses if our poll interval is longer than the MTA's inactivity
1275 * timeout, and (2) some MTAs (like smail) don't deliver after
1276 * each message, but rather queue up mail and wait to actually
1277 * deliver it until the input socket is closed.
1279 * Sending SMTP QUIT on signal is theoretically nice, but led to a
1280 * subtle bug. If fetchmail was terminated by signal while it was
1281 * shipping message text, it would hang forever waiting for a
1282 * command acknowledge. In theory we could enable the QUIT
1283 * only outside of the message send. In practice, we don't
1284 * care. All mailservers hang up on a dropped TCP/IP connection
1289 report(stdout, _("terminated with signal %d\n"), sig);
1294 /* terminate all SMTP connections cleanly */
1295 for (ctl = querylist; ctl; ctl = ctl->next)
1296 if (ctl->smtp_socket != -1)
1298 SMTP_quit(ctl->smtp_socket);
1299 SockClose(ctl->smtp_socket);
1300 ctl->smtp_socket = -1;
1306 * Update UID information at end of each poll, rather than at end
1307 * of run, because that way we don't lose all UIDL information since
1308 * the beginning of time if fetchmail crashes.
1311 write_saved_lists(querylist, run.idfile);
1312 #endif /* POP3_ENABLE */
1315 static void terminate_run(int sig)
1316 /* to be executed on normal or signal-induced termination */
1320 terminate_poll(sig);
1323 * Craig Metz, the RFC1938 one-time-password guy, points out:
1324 * "Remember that most kernels don't zero pages before handing them to the
1325 * next process and many kernels share pages between user and kernel space.
1326 * You'd be very surprised what you can find from a short program to do a
1327 * malloc() and then dump the contents of the pages you got. By zeroing
1328 * the secrets at end of run (earlier if you can), you make sure the next
1329 * guy can't get the password/pass phrase."
1331 * Right you are, Craig!
1333 for (ctl = querylist; ctl; ctl = ctl->next)
1335 memset(ctl->password, '\0', strlen(ctl->password));
1337 #if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
1341 if (activecount == 0)
1344 exit(successes ? PS_SUCCESS : querystatus);
1348 * Sequence of protocols to try when autoprobing, most capable to least.
1350 static const int autoprobe[] =
1354 #endif /* IMAP_ENABLE */
1357 #endif /* POP3_ENABLE */
1360 #endif /* POP2_ENABLE */
1363 static int query_host(struct query *ctl)
1364 /* perform fetch transaction with single host */
1369 * If we're syslogging the progress messages are automatically timestamped.
1370 * Force timestamping if we're going to a logfile.
1372 if (outlevel >= O_VERBOSE || (run.logfile && outlevel > O_SILENT))
1374 report(stdout, _("%s querying %s (protocol %s) at %s\n"),
1376 ctl->server.pollname,
1377 showproto(ctl->server.protocol),
1380 switch (ctl->server.protocol) {
1382 for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
1384 ctl->server.protocol = autoprobe[i];
1385 if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY || st == PS_SMTP)
1388 ctl->server.protocol = P_AUTO;
1392 return(doPOP2(ctl));
1394 report(stderr, _("POP2 support is not configured.\n"));
1395 return(PS_PROTOCOL);
1396 #endif /* POP2_ENABLE */
1402 return(doPOP3(ctl));
1404 report(stderr, _("POP3 support is not configured.\n"));
1405 return(PS_PROTOCOL);
1406 #endif /* POP3_ENABLE */
1410 return(doIMAP(ctl));
1412 report(stderr, _("IMAP support is not configured.\n"));
1413 return(PS_PROTOCOL);
1414 #endif /* IMAP_ENABLE */
1417 report(stderr, _("ETRN support is not configured.\n"));
1418 return(PS_PROTOCOL);
1420 #ifdef HAVE_GETHOSTBYNAME
1421 return(doETRN(ctl));
1423 report(stderr, _("Cannot support ETRN without gethostbyname(2).\n"));
1424 return(PS_PROTOCOL);
1425 #endif /* HAVE_GETHOSTBYNAME */
1426 #endif /* ETRN_ENABLE */
1429 report(stderr, _("ODMR support is not configured.\n"));
1430 return(PS_PROTOCOL);
1432 #ifdef HAVE_GETHOSTBYNAME
1433 return(doODMR(ctl));
1435 report(stderr, _("Cannot support ODMR without gethostbyname(2).\n"));
1436 return(PS_PROTOCOL);
1437 #endif /* HAVE_GETHOSTBYNAME */
1438 #endif /* ODMR_ENABLE */
1440 report(stderr, _("unsupported protocol selected.\n"));
1441 return(PS_PROTOCOL);
1445 static void dump_params (struct runctl *runp,
1446 struct query *querylist, flag implicit)
1447 /* display query parameters in English */
1451 if (runp->poll_interval)
1452 printf(_("Poll interval is %d seconds\n"), runp->poll_interval);
1454 printf(_("Logfile is %s\n"), runp->logfile);
1455 if (strcmp(runp->idfile, IDFILE_NAME))
1456 printf(_("Idfile is %s\n"), runp->idfile);
1457 #if defined(HAVE_SYSLOG)
1458 if (runp->use_syslog)
1459 printf(_("Progress messages will be logged via syslog\n"));
1461 if (runp->invisible)
1462 printf(_("Fetchmail will masquerade and will not generate Received\n"));
1464 printf(_("Fetchmail will show progress dots even in logfiles.\n"));
1465 if (runp->postmaster)
1466 printf(_("Fetchmail will forward misaddressed multidrop messages to %s.\n"),
1469 if (!runp->bouncemail)
1470 printf(_("Fetchmail will direct error mail to the postmaster.\n"));
1471 else if (outlevel >= O_VERBOSE)
1472 printf(_("Fetchmail will direct error mail to the sender.\n"));
1474 for (ctl = querylist; ctl; ctl = ctl->next)
1476 if (!ctl->active || (implicit && ctl->server.skip))
1479 printf(_("Options for retrieving from %s@%s:\n"),
1480 ctl->remotename, visbuf(ctl->server.pollname));
1482 if (ctl->server.via && MAILBOX_PROTOCOL(ctl))
1483 printf(_(" Mail will be retrieved via %s\n"), ctl->server.via);
1485 if (ctl->server.interval)
1486 printf(_(" Poll of this server will occur every %d intervals.\n"),
1487 ctl->server.interval);
1488 if (ctl->server.truename)
1489 printf(_(" True name of server is %s.\n"), ctl->server.truename);
1490 if (ctl->server.skip || outlevel >= O_VERBOSE)
1491 printf(_(" This host %s be queried when no host is specified.\n"),
1492 ctl->server.skip ? _("will not") : _("will"));
1493 if (!NO_PASSWORD(ctl))
1496 printf(_(" Password will be prompted for.\n"));
1497 else if (outlevel >= O_VERBOSE)
1499 if (ctl->server.protocol == P_APOP)
1500 printf(_(" APOP secret = \"%s\".\n"),
1501 visbuf(ctl->password));
1502 else if (ctl->server.protocol == P_RPOP)
1503 printf(_(" RPOP id = \"%s\".\n"),
1504 visbuf(ctl->password));
1506 printf(_(" Password = \"%s\".\n"),
1507 visbuf(ctl->password));
1511 if (ctl->server.protocol == P_POP3
1513 && ctl->server.service && !strcmp(ctl->server.service, KPOP_PORT)
1514 #else /* INET6_ENABLE */
1515 && ctl->server.port == KPOP_PORT
1516 #endif /* INET6_ENABLE */
1517 && (ctl->server.authenticate == A_KERBEROS_V4 ||
1518 ctl->server.authenticate == A_KERBEROS_V5))
1519 printf(_(" Protocol is KPOP with Kerberos %s authentication"),
1520 ctl->server.authenticate == A_KERBEROS_V5 ? "V" : "IV");
1522 printf(_(" Protocol is %s"), showproto(ctl->server.protocol));
1524 if (ctl->server.service)
1525 printf(_(" (using service %s)"), ctl->server.service);
1526 if (ctl->server.netsec)
1527 printf(_(" (using network security options %s)"), ctl->server.netsec);
1528 #else /* INET6_ENABLE */
1529 if (ctl->server.port)
1530 printf(_(" (using port %d)"), ctl->server.port);
1531 #endif /* INET6_ENABLE */
1532 else if (outlevel >= O_VERBOSE)
1533 printf(_(" (using default port)"));
1534 if (ctl->server.uidl && MAILBOX_PROTOCOL(ctl))
1535 printf(_(" (forcing UIDL use)"));
1538 switch (ctl->server.authenticate)
1541 printf(_(" All available authentication methods will be tried.\n"));
1544 printf(_(" Password authentication will be forced.\n"));
1547 printf(_(" NTLM authentication will be forced.\n"));
1550 printf(_(" OTP authentication will be forced.\n"));
1553 printf(_(" CRAM-Md5 authentication will be forced.\n"));
1556 printf(_(" GSSAPI authentication will be forced.\n"));
1559 printf(_(" Kerberos V4 authentication will be forced.\n"));
1562 printf(_(" Kerberos V5 authentication will be forced.\n"));
1565 printf(_(" End-to-end encryption assumed.\n"));
1568 if (ctl->server.principal != (char *) NULL)
1569 printf(_(" Mail service principal is: %s\n"), ctl->server.principal);
1572 printf(" SSL encrypted sessions enabled.\n");
1574 if (ctl->server.timeout > 0)
1575 printf(_(" Server nonresponse timeout is %d seconds"), ctl->server.timeout);
1576 if (ctl->server.timeout == CLIENT_TIMEOUT)
1577 printf(_(" (default).\n"));
1581 if (MAILBOX_PROTOCOL(ctl)) {
1582 if (!ctl->mailboxes->id)
1583 printf(_(" Default mailbox selected.\n"));
1588 printf(_(" Selected mailboxes are:"));
1589 for (idp = ctl->mailboxes; idp; idp = idp->next)
1590 printf(" %s", idp->id);
1593 printf(_(" %s messages will be retrieved (--all %s).\n"),
1594 ctl->fetchall ? _("All") : _("Only new"),
1595 ctl->fetchall ? "on" : "off");
1596 printf(_(" Fetched messages %s be kept on the server (--keep %s).\n"),
1597 ctl->keep ? _("will") : _("will not"),
1598 ctl->keep ? "on" : "off");
1599 printf(_(" Old messages %s be flushed before message retrieval (--flush %s).\n"),
1600 ctl->flush ? _("will") : _("will not"),
1601 ctl->flush ? "on" : "off");
1602 printf(_(" Rewrite of server-local addresses is %s (--norewrite %s).\n"),
1603 ctl->rewrite ? _("enabled") : _("disabled"),
1604 ctl->rewrite ? "off" : "on");
1605 printf(_(" Carriage-return stripping is %s (stripcr %s).\n"),
1606 ctl->stripcr ? _("enabled") : _("disabled"),
1607 ctl->stripcr ? "on" : "off");
1608 printf(_(" Carriage-return forcing is %s (forcecr %s).\n"),
1609 ctl->forcecr ? _("enabled") : _("disabled"),
1610 ctl->forcecr ? "on" : "off");
1611 printf(_(" Interpretation of Content-Transfer-Encoding is %s (pass8bits %s).\n"),
1612 ctl->pass8bits ? _("disabled") : _("enabled"),
1613 ctl->pass8bits ? "on" : "off");
1614 printf(_(" MIME decoding is %s (mimedecode %s).\n"),
1615 ctl->mimedecode ? _("enabled") : _("disabled"),
1616 ctl->mimedecode ? "on" : "off");
1617 printf(_(" Idle after poll is %s (idle %s).\n"),
1618 ctl->idle ? _("enabled") : _("disabled"),
1619 ctl->idle ? "on" : "off");
1620 printf(_(" Nonempty Status lines will be %s (dropstatus %s)\n"),
1621 ctl->dropstatus ? _("discarded") : _("kept"),
1622 ctl->dropstatus ? "on" : "off");
1623 printf(_(" Delivered-To lines will be %s (dropdelivered %s)\n"),
1624 ctl->dropdelivered ? _("discarded") : _("kept"),
1625 ctl->dropdelivered ? "on" : "off");
1626 if (NUM_NONZERO(ctl->limit))
1628 if (NUM_NONZERO(ctl->limit))
1629 printf(_(" Message size limit is %d octets (--limit %d).\n"),
1630 ctl->limit, ctl->limit);
1631 else if (outlevel >= O_VERBOSE)
1632 printf(_(" No message size limit (--limit 0).\n"));
1633 if (run.poll_interval > 0)
1634 printf(_(" Message size warning interval is %d seconds (--warnings %d).\n"),
1635 ctl->warnings, ctl->warnings);
1636 else if (outlevel >= O_VERBOSE)
1637 printf(_(" Size warnings on every poll (--warnings 0).\n"));
1639 if (NUM_NONZERO(ctl->fetchlimit))
1640 printf(_(" Received-message limit is %d (--fetchlimit %d).\n"),
1641 ctl->fetchlimit, ctl->fetchlimit);
1642 else if (outlevel >= O_VERBOSE)
1643 printf(_(" No received-message limit (--fetchlimit 0).\n"));
1644 if (NUM_NONZERO(ctl->batchlimit))
1645 printf(_(" SMTP message batch limit is %d.\n"), ctl->batchlimit);
1646 else if (outlevel >= O_VERBOSE)
1647 printf(_(" No SMTP message batch limit (--batchlimit 0).\n"));
1648 if (MAILBOX_PROTOCOL(ctl))
1650 if (NUM_NONZERO(ctl->expunge))
1651 printf(_(" Deletion interval between expunges forced to %d (--expunge %d).\n"), ctl->expunge, ctl->expunge);
1652 else if (outlevel >= O_VERBOSE)
1653 printf(_(" No forced expunges (--expunge 0).\n"));
1657 printf(_(" Messages will be appended to %s as BSMTP\n"), visbuf(ctl->bsmtp));
1658 else if (ctl->mda && MAILBOX_PROTOCOL(ctl))
1659 printf(_(" Messages will be delivered with \"%s\".\n"), visbuf(ctl->mda));
1664 printf(_(" Messages will be %cMTP-forwarded to:"), ctl->listener);
1665 for (idp = ctl->smtphunt; idp; idp = idp->next)
1667 printf(" %s", idp->id);
1668 if (!idp->val.status.mark)
1669 printf(_(" (default)"));
1672 if (ctl->smtpaddress)
1673 printf(_(" Host part of MAIL FROM line will be %s\n"),
1676 printf(_(" Address to be put in RCPT TO lines shipped to SMTP will be %s\n"),
1679 if (MAILBOX_PROTOCOL(ctl))
1681 if (ctl->antispam != (struct idlist *)NULL)
1685 printf(_(" Recognized listener spam block responses are:"));
1686 for (idp = ctl->antispam; idp; idp = idp->next)
1687 printf(" %d", idp->val.status.num);
1690 else if (outlevel >= O_VERBOSE)
1691 printf(_(" Spam-blocking disabled\n"));
1693 if (ctl->preconnect)
1694 printf(_(" Server connection will be brought up with \"%s\".\n"),
1695 visbuf(ctl->preconnect));
1696 else if (outlevel >= O_VERBOSE)
1697 printf(_(" No pre-connection command.\n"));
1698 if (ctl->postconnect)
1699 printf(_(" Server connection will be taken down with \"%s\".\n"),
1700 visbuf(ctl->postconnect));
1701 else if (outlevel >= O_VERBOSE)
1702 printf(_(" No post-connection command.\n"));
1703 if (MAILBOX_PROTOCOL(ctl)) {
1704 if (!ctl->localnames)
1705 printf(_(" No localnames declared for this host.\n"));
1711 for (idp = ctl->localnames; idp; idp = idp->next)
1714 if (count > 1 || ctl->wildcard)
1715 printf(_(" Multi-drop mode: "));
1717 printf(_(" Single-drop mode: "));
1719 printf(_("%d local name(s) recognized.\n"), count);
1720 if (outlevel >= O_VERBOSE)
1722 for (idp = ctl->localnames; idp; idp = idp->next)
1724 printf("\t%s -> %s\n", idp->id, idp->val.id2);
1726 printf("\t%s\n", idp->id);
1728 fputs("\t*\n", stdout);
1731 if (count > 1 || ctl->wildcard)
1733 printf(_(" DNS lookup for multidrop addresses is %s.\n"),
1734 ctl->server.dns ? _("enabled") : _("disabled"));
1735 if (ctl->server.dns)
1737 printf(_(" Server aliases will be compared with multidrop addresses by "));
1738 if (ctl->server.checkalias)
1739 printf(_("IP address.\n"));
1741 printf(_("name.\n"));
1743 if (ctl->server.envelope == STRING_DISABLED)
1744 printf(_(" Envelope-address routing is disabled\n"));
1747 printf(_(" Envelope header is assumed to be: %s\n"),
1748 ctl->server.envelope ? ctl->server.envelope:_("Received"));
1749 if (ctl->server.envskip > 1 || outlevel >= O_VERBOSE)
1750 printf(_(" Number of envelope header to be parsed: %d\n"),
1751 ctl->server.envskip);
1752 if (ctl->server.qvirtual)
1753 printf(_(" Prefix %s will be removed from user id\n"),
1754 ctl->server.qvirtual);
1755 else if (outlevel >= O_VERBOSE)
1756 printf(_(" No prefix stripping\n"));
1759 if (ctl->server.akalist)
1763 printf(_(" Predeclared mailserver aliases:"));
1764 for (idp = ctl->server.akalist; idp; idp = idp->next)
1765 printf(" %s", idp->id);
1768 if (ctl->server.localdomains)
1772 printf(_(" Local domains:"));
1773 for (idp = ctl->server.localdomains; idp; idp = idp->next)
1774 printf(" %s", idp->id);
1780 #if defined(linux) || defined(__FreeBSD__)
1781 if (ctl->server.interface)
1782 printf(_(" Connection must be through interface %s.\n"), ctl->server.interface);
1783 else if (outlevel >= O_VERBOSE)
1784 printf(_(" No interface requirement specified.\n"));
1785 if (ctl->server.monitor)
1786 printf(_(" Polling loop will monitor %s.\n"), ctl->server.monitor);
1787 else if (outlevel >= O_VERBOSE)
1788 printf(_(" No monitor interface specified.\n"));
1791 if (ctl->server.plugin)
1792 printf(_(" Server connections will be made via plugin %s (--plugin %s).\n"), ctl->server.plugin, ctl->server.plugin);
1793 else if (outlevel >= O_VERBOSE)
1794 printf(_(" No plugin command specified.\n"));
1795 if (ctl->server.plugout)
1796 printf(_(" Listener connections will be made via plugout %s (--plugout %s).\n"), ctl->server.plugout, ctl->server.plugout);
1797 else if (outlevel >= O_VERBOSE)
1798 printf(_(" No plugout command specified.\n"));
1800 if (ctl->server.protocol > P_POP2 && MAILBOX_PROTOCOL(ctl))
1803 printf(_(" No UIDs saved from this host.\n"));
1809 for (idp = ctl->oldsaved; idp; idp = idp->next)
1812 printf(_(" %d UIDs saved.\n"), count);
1813 if (outlevel >= O_VERBOSE)
1814 for (idp = ctl->oldsaved; idp; idp = idp->next)
1815 printf("\t%s\n", idp->id);
1819 if (ctl->properties)
1820 printf(_(" Pass-through properties \"%s\".\n"),
1821 visbuf(ctl->properties));
1825 /* fetchmail.c ends here */