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>
29 #include <sys/resource.h>
30 #endif /* HAVE_SETRLIMIT */
31 #include <sys/utsname.h>
33 #ifdef HAVE_GETHOSTBYNAME
35 #endif /* HAVE_GETHOSTBYNAME */
42 #include "fetchmail.h"
49 #define ENETUNREACH 128 /* Interactive doesn't know this */
50 #endif /* ENETUNREACH */
52 /* prototypes for internal functions */
53 static int load_params(int, char **, int);
54 static void dump_params (struct runctl *runp, struct query *, flag implicit);
55 static int query_host(struct query *);
57 /* controls the detail level of status/progress messages written to stderr */
58 int outlevel; /* see the O_.* constants above */
60 /* miscellaneous global controls */
61 struct runctl run; /* global controls for this run */
62 flag nodetach; /* if TRUE, don't detach daemon process */
63 flag quitmode; /* if --quit was set */
64 flag check_only; /* if --probe was set */
65 flag versioninfo; /* emit only version info */
66 char *user; /* the name of the invoking user */
67 char *home; /* invoking user's home directory */
68 char *program_name; /* the name to prefix error messages with */
69 flag configdump; /* dump control blocks for configurator */
70 const char *fetchmailhost; /* either `localhost' or the host's FQDN */
75 #endif /* NET_SECURITY */
77 static char *lockfile; /* name of lockfile */
78 static int lock_acquired; /* have we acquired a lock */
79 static int querystatus; /* status of query */
80 static int successes; /* count number of successful polls */
81 static struct runctl cmd_run; /* global options set from command line */
82 static time_t parsetime; /* time of last parse */
84 static void terminate_run(int);
85 static void terminate_poll(int);
88 static void unlockit(int n, void *p)
90 static void unlockit(void)
92 /* must-do actions for exit (but we can't count on being able to do malloc) */
94 if (lockfile && lock_acquired)
99 /* drop SGID kmem privileage until we need it */
100 static void dropprivs(void)
110 if (gr && !strcmp(gr->gr_name, "kmem"))
112 extern void interface_set_gids(gid_t egid, gid_t rgid);
113 interface_set_gids(egid, rgid);
119 int main(int argc, char **argv)
121 int st, bkgd = FALSE;
122 int parsestatus, implicitmode = FALSE;
125 netrc_entry *netrc_list;
126 char *netrc_file, *tmpbuf;
134 envquery(argc, argv);
136 bindtextdomain(PACKAGE, LOCALEDIR);
141 * Note: because we can't initialize reporting before we know whether
142 * syslog is supposed to be on, this message will go to stdout and
143 * be lost when running in background.
145 if (outlevel >= O_VERBOSE)
149 report(stdout, "fetchmail: invoked with");
150 for (i = 0; i < argc; i++)
151 report(stdout, " %s", argv[i]);
152 report(stdout, "\n");
155 #define IDFILE_NAME ".fetchids"
156 run.idfile = (char *) xmalloc(strlen(home)+sizeof(IDFILE_NAME)+1);
157 strcpy(run.idfile, home);
158 strcat(run.idfile, "/");
159 strcat(run.idfile, IDFILE_NAME);
164 * We used to arrange for the lockfile to be removed on exit close
165 * to where the lock was asserted. Now we need to do it here, because
166 * we might have re-executed in background with an existing lockfile
167 * as the result of a changed rcfile (see the code near the execvp(3)
168 * call near the beginning of the polling loop for details). We want
169 * to be sure the lockfile gets nuked on any error exit, basically.
175 on_exit(unlockit, (char *)NULL);
178 if ((parsestatus = parsecmdline(argc,argv, &cmd_run, &cmd_opts)) < 0)
183 printf(_("This is fetchmail release %s"), VERSION);
186 #endif /* POP2_ENABLE */
189 #endif /* POP3_ENABLE */
192 #endif /* IMAP_ENABLE */
198 #endif /* RPA_ENABLE */
201 #endif /* NTLM_ENABLE */
204 #endif /* SDPS_ENABLE */
207 #endif /* ETRN_ENABLE */
213 #endif /* OPIE_ENABLE */
216 #endif /* INET6_ENABLE */
219 #endif /* NET_SECURITY */
222 #endif /* HAVE_SOCKS */
225 #endif /* ENABLE_NLS */
229 /* this is an attempt to help remote debugging */
233 /* avoid parsing the config file if all we're doing is killing a daemon */
234 if (!(quitmode && argc == 2))
235 implicitmode = load_params(argc, argv, optind);
237 #if defined(HAVE_SYSLOG)
238 /* logging should be set up early in case we were restarted from exec */
241 #if defined(LOG_MAIL)
242 openlog(program_name, LOG_PID, LOG_MAIL);
244 /* Assume BSD4.2 openlog with two arguments */
245 openlog(program_name, LOG_PID);
251 report_init((run.poll_interval == 0 || nodetach) && !run.logfile);
253 /* set up to do lock protocol */
254 #define FETCHMAIL_PIDFILE "fetchmail.pid"
256 xalloca(tmpbuf, char *,
257 sizeof(PID_DIR) + sizeof(FETCHMAIL_PIDFILE));
258 sprintf(tmpbuf, "%s/%s", PID_DIR, FETCHMAIL_PIDFILE);
260 xalloca(tmpbuf, char *, strlen(home) + sizeof(FETCHMAIL_PIDFILE) + 2);
261 strcpy(tmpbuf, home);
262 strcat(tmpbuf, "/.");
263 strcat(tmpbuf, FETCHMAIL_PIDFILE);
265 #undef FETCHMAIL_PIDFILE
267 #ifdef HAVE_SETRLIMIT
269 * Before getting passwords, disable core dumps unless -v -d0 mode is on.
270 * Core dumps could otherwise contain passwords to be scavenged by a
273 if (outlevel < O_VERBOSE || run.poll_interval > 0)
275 struct rlimit corelimit;
276 corelimit.rlim_cur = 0;
277 corelimit.rlim_max = 0;
278 setrlimit(RLIMIT_CORE, &corelimit);
280 #endif /* HAVE_SETRLIMIT */
282 #define NETRC_FILE ".netrc"
283 /* parse the ~/.netrc file (if present) for future password lookups. */
284 xalloca(netrc_file, char *, strlen (home) + sizeof(NETRC_FILE) + 1);
285 strcpy (netrc_file, home);
286 strcat (netrc_file, "/");
287 strcat (netrc_file, NETRC_FILE);
288 netrc_list = parse_netrc(netrc_file);
291 /* pick up passwords where we can */
292 for (ctl = querylist; ctl; ctl = ctl->next)
294 if (ctl->active && !(implicitmode && ctl->server.skip)&&!ctl->password)
296 if (ctl->server.preauthenticate == A_KERBEROS_V4 ||
297 ctl->server.preauthenticate == A_KERBEROS_V5 ||
298 ctl->server.preauthenticate == A_SSH ||
300 ctl->server.protocol == P_IMAP_GSS ||
302 ctl->server.protocol == P_IMAP_K4)
303 /* Server won't care what the password is, but there
304 must be some non-null string here. */
305 ctl->password = ctl->remotename;
310 /* look up the pollname and account in the .netrc file. */
311 p = search_netrc(netrc_list,
312 ctl->server.pollname, ctl->remotename);
313 /* if we find a matching entry with a password, use it */
314 if (p && p->password)
315 ctl->password = xstrdup(p->password);
317 /* otherwise try with "via" name if there is one */
318 else if (ctl->server.via)
320 p = search_netrc(netrc_list,
321 ctl->server.via, ctl->remotename);
322 if (p && p->password)
323 ctl->password = xstrdup(p->password);
329 /* perhaps we just want to check options? */
332 int havercfile = access(rcfile, 0);
334 printf(_("Taking options from command line%s%s\n"),
335 havercfile ? "" : _(" and "),
336 havercfile ? "" : rcfile);
338 if (outlevel >= O_VERBOSE)
339 printf(_("Lockfile at %s\n"), tmpbuf);
341 if (querylist == NULL)
343 _("No mailservers set up -- perhaps %s is missing?\n"),
346 dump_params(&run, querylist, implicitmode);
350 /* dump options as a Python dictionary, for configurator use */
353 dump_config(&run, querylist);
357 /* check for another fetchmail running concurrently */
359 if ((lockfile = (char *) malloc(strlen(tmpbuf) + 1)) == NULL)
361 report(stderr,_("fetchmail: cannot allocate memory for lock name.\n"));
365 (void) strcpy(lockfile, tmpbuf);
366 if ((lockfp = fopen(lockfile, "r")) != NULL )
368 bkgd = (fscanf(lockfp,"%d %d", &pid, &st) == 2);
370 if (kill(pid, 0) == -1) {
371 fprintf(stderr,_("fetchmail: removing stale lockfile\n"));
376 fclose(lockfp); /* not checking should be safe, file mode was "r" */
379 /* if no mail servers listed and nothing in background, we're done */
380 if (!(quitmode && argc == 2) && pid == -1 && querylist == NULL) {
381 (void)fputs(_("fetchmail: no mailservers have been specified.\n"),stderr);
385 /* perhaps user asked us to kill the other fetchmail */
390 fprintf(stderr,_("fetchmail: no other fetchmail is running\n"));
394 else if (kill(pid, SIGTERM) < 0)
396 fprintf(stderr,_("fetchmail: error killing %s fetchmail at %d; bailing out.\n"),
397 bkgd ? _("background") : _("foreground"), pid);
402 fprintf(stderr,_("fetchmail: %s fetchmail at %d killed.\n"),
403 bkgd ? _("background") : _("foreground"), pid);
412 /* another fetchmail is running -- wake it up or die */
418 _("fetchmail: can't check mail while another fetchmail to same host is running.\n"));
421 else if (!implicitmode)
424 _("fetchmail: can't poll specified hosts with another fetchmail running at %d.\n"),
431 _("fetchmail: another foreground fetchmail is running at %d.\n"),
437 /* this test enables re-execing on a changed rcfile */
439 lock_acquired = TRUE;
443 _("fetchmail: can't accept options while a background fetchmail is running.\n"));
447 else if (kill(pid, SIGUSR1) == 0)
450 _("fetchmail: background fetchmail at %d awakened.\n"),
457 * Should never happen -- possible only if a background fetchmail
458 * croaks after the first kill probe above but before the
459 * SIGUSR1/SIGHUP transmission.
462 _("fetchmail: elder sibling at %d died mysteriously.\n"),
464 return(PS_UNDEFINED);
468 /* pick up interactively any passwords we need but don't have */
469 for (ctl = querylist; ctl; ctl = ctl->next)
471 if (ctl->active && !(implicitmode && ctl->server.skip)
472 && ctl->server.protocol != P_ETRN
473 && ctl->server.protocol != P_IMAP_K4
475 && ctl->server.protocol != P_IMAP_GSS
481 _("fetchmail: can't find a password for %s@s.\n"),
482 ctl->remotename, ctl->server.pollname);
487 char* password_prompt = _("Enter password for %s@%s: ");
489 xalloca(tmpbuf, char *, strlen(password_prompt) +
490 strlen(ctl->remotename) +
491 strlen(ctl->server.pollname) + 1);
492 (void) sprintf(tmpbuf, password_prompt,
493 ctl->remotename, ctl->server.pollname);
494 ctl->password = xstrdup((char *)getpassword(tmpbuf));
499 * Time to initiate the SOCKS library (this is not mandatory: it just
500 * registers the correct application name for logging purpose. If you
501 * have some problem, comment out these lines).
504 SOCKSinit("fetchmail");
505 #endif /* HAVE_SOCKS */
508 * Maybe time to go to demon mode...
510 if (run.poll_interval)
513 daemonize(run.logfile, terminate_run);
514 report(stdout, _("starting fetchmail %s daemon \n"), VERSION);
517 * We'll set up a handler for these when we're sleeping,
518 * but ignore them otherwise so as not to interrupt a poll.
520 signal(SIGUSR1, SIG_IGN);
521 if (run.poll_interval && !getuid())
522 signal(SIGHUP, SIG_IGN);
524 else if (run.logfile && access(run.logfile, F_OK) == 0)
526 freopen(run.logfile, "a", stdout);
527 freopen(run.logfile, "a", stderr);
535 /* beyond here we don't want more than one fetchmail running per user */
537 signal(SIGABRT, terminate_run);
538 signal(SIGINT, terminate_run);
539 signal(SIGTERM, terminate_run);
540 signal(SIGALRM, terminate_run);
541 signal(SIGPIPE, terminate_run);
542 signal(SIGQUIT, terminate_run);
544 /* here's the exclusion lock */
546 #define O_SYNC 0 /* use it if we have it */
548 if ((st = open(lockfile, O_WRONLY|O_CREAT|O_EXCL|O_SYNC, 0666)) != -1)
550 sprintf(tmpbuf,"%d", getpid());
551 write(st, tmpbuf, strlen(tmpbuf));
552 if (run.poll_interval)
554 sprintf(tmpbuf," %d", run.poll_interval);
555 write(st, tmpbuf, strlen(tmpbuf));
557 close(st); /* should be safe, fd was opened with O_SYNC */
558 lock_acquired = TRUE;
562 * Query all hosts. If there's only one, the error return will
563 * reflect the status of that transaction.
567 * Check to see if the rcfile has been touched. If so,
568 * re-exec so the file will be reread. Doing it this way
569 * avoids all the complications of trying to deallocate the
570 * in-core control structures -- and the potential memory
575 if (stat(rcfile, &rcstat) == -1)
579 _("couldn't time-check %s (error %d)\n"),
582 else if (rcstat.st_mtime > parsetime)
584 report(stdout, _("restarting fetchmail (%s changed)\n"), rcfile);
585 execvp("fetchmail", argv);
586 report(stderr, _("attempt to re-exec fetchmail failed\n"));
589 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
591 * This was an efficiency hack that backfired. The theory
592 * was that using TCP/IP for DNS queries would get us better
593 * reliability and shave off some per-UDP-packet costs.
594 * Unfortunately it interacted badly with diald, which effectively
595 * filters out DNS queries over TCP/IP for reasons having to do
596 * with some obscure kernel problem involving bootstrapping of
597 * dynamically-addressed links. I don't understand this mess
598 * and don't want to, so it's "See ya!" to this hack.
600 sethostent(TRUE); /* use TCP/IP for mailserver queries */
601 #endif /* HAVE_RES_SEARCH */
604 for (ctl = querylist; ctl; ctl = ctl->next)
606 if (ctl->active && !(implicitmode && ctl->server.skip))
611 _("poll of %s skipped (failed authentication or too many timeouts)\n"),
612 ctl->server.pollname);
616 /* check skip interval first so that it counts all polls */
617 if (run.poll_interval && ctl->server.interval)
619 if (ctl->server.poll_count++ % ctl->server.interval)
621 if (outlevel >= O_VERBOSE)
623 _("interval not reached, not querying %s\n"),
624 ctl->server.pollname);
629 #if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__)
631 * Don't do monitoring if we were woken by a signal.
632 * Note that interface_approve() does its own error logging.
634 if (!interface_approve(&ctl->server, !lastsig))
636 #endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */
638 querystatus = query_host(ctl);
643 #endif /* POP3_ENABLE */
645 if (querystatus == PS_SUCCESS)
647 else if (!check_only &&
648 ((querystatus!=PS_NOMAIL) || (outlevel==O_DEBUG)))
652 report(stdout, "Query status=0 (SUCCESS)\n"); break ;
654 report(stdout, "Query status=1 (NOMAIL)\n"); break ;
656 report(stdout, "Query status=2 (SOCKET)\n"); break ;
658 report(stdout, "Query status=3 (AUTHFAIL)\n"); break ;
660 report(stdout, "Query status=4 (PROTOCOL)\n"); break ;
662 report(stdout, "Query status=5 (SYNTAX)\n"); break ;
664 report(stdout, "Query status=6 (IOERR)\n"); break ;
666 report(stdout, "Query status=7 (ERROR)\n"); break ;
668 report(stdout, "Query status=8 (EXCLUDE)\n"); break ;
670 report(stdout, "Query status=9 (LOCKBUSY)\n"); break ;
672 report(stdout, "Query status=10 (SMTP)\n"); break ;
674 report(stdout, "Query status=11 (DNS)\n"); break ;
676 report(stdout, "Query status=12 (BSMTP)\n"); break ;
678 report(stdout, "Query status=13 (MAXFETCH)\n"); break ;
680 report(stdout, _("Query status=%d\n"), querystatus); break;
683 #if (defined(linux) && !INET6_ENABLE) || defined (__FreeBSD__)
684 if (ctl->server.monitor)
687 * Allow some time for the link to quiesce. One
688 * second is usually sufficient, three is safe.
689 * Note: this delay is important - don't remove!
692 interface_note_activity(&ctl->server);
694 #endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */
698 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
699 endhostent(); /* release TCP/IP connection to nameserver */
700 #endif /* HAVE_RES_SEARCH */
702 /* close connections cleanly */
706 * OK, we've polled. Now sleep.
708 if (run.poll_interval)
711 * Because passwords can expire, it may happen that *all*
712 * hosts are now out of the loop due to authfail
713 * conditions. If this happens daemon-mode fetchmail
714 * should softly and silently vanish away, rather than
715 * spinning uselessly.
719 for (ctl = querylist; ctl; ctl = ctl->next)
720 if (ctl->active && !(implicitmode && ctl->server.skip))
725 report(stderr, _("All connections are wedged. Exiting.\n"));
726 /* FIXME: someday, send notification mail */
730 if (outlevel >= O_VERBOSE)
732 _("fetchmail: sleeping at %s\n"), rfc822timestamp());
735 * OK, now pause util it's time for the next poll cycle.
736 * A nonzero return indicates we received a wakeup signal;
737 * unwedge all servers in case the problem has been
740 if ((lastsig = interruptible_idle(run.poll_interval)))
742 #ifdef SYS_SIGLIST_DECLARED
744 _("awakened by %s\n"), sys_siglist[lastsig]);
747 _("awakened by signal %d\n"), lastsig);
749 for (ctl = querylist; ctl; ctl = ctl->next)
753 if (outlevel >= O_VERBOSE)
754 report(stdout, _("awakened at %s\n"), rfc822timestamp());
759 if (outlevel >= O_VERBOSE)
760 report(stdout, _("normal termination, status %d\n"),
761 successes ? PS_SUCCESS : querystatus);
764 exit(successes ? PS_SUCCESS : querystatus);
767 static void list_merge(struct idlist **dstl, struct idlist **srcl, int force)
770 * If force is off, modify dstl fields only when they're empty (treat srcl
771 * as defaults). If force is on, modify each dstl field whenever scrcl
772 * is nonempty (treat srcl as an override).
774 if (force ? !!*srcl : !*dstl)
776 struct idlist *cpl = copy_str_list(*srcl);
778 append_str_list(dstl, &cpl);
782 static void optmerge(struct query *h2, struct query *h1, int force)
783 /* merge two options records */
785 list_merge(&h2->server.localdomains, &h1->server.localdomains, force);
786 list_merge(&h2->localnames, &h1->localnames, force);
787 list_merge(&h2->mailboxes, &h1->mailboxes, force);
788 list_merge(&h2->smtphunt, &h1->smtphunt, force);
789 list_merge(&h2->antispam, &h1->antispam, force);
791 #define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
792 FLAG_MERGE(server.via);
793 FLAG_MERGE(server.protocol);
795 FLAG_MERGE(server.service);
796 FLAG_MERGE(server.netsec);
797 #else /* INET6_ENABLE */
798 FLAG_MERGE(server.port);
799 #endif /* INET6_ENABLE */
800 FLAG_MERGE(server.interval);
801 FLAG_MERGE(server.preauthenticate);
802 FLAG_MERGE(server.timeout);
803 FLAG_MERGE(server.envelope);
804 FLAG_MERGE(server.envskip);
805 FLAG_MERGE(server.qvirtual);
806 FLAG_MERGE(server.skip);
807 FLAG_MERGE(server.dns);
808 FLAG_MERGE(server.checkalias);
809 FLAG_MERGE(server.uidl);
811 #if defined(linux) || defined(__FreeBSD__)
812 FLAG_MERGE(server.interface);
813 FLAG_MERGE(server.monitor);
814 FLAG_MERGE(server.interface_pair);
815 #endif /* linux || defined(__FreeBSD__) */
817 FLAG_MERGE(server.plugin);
818 FLAG_MERGE(server.plugout);
820 FLAG_MERGE(wildcard);
821 FLAG_MERGE(remotename);
822 FLAG_MERGE(password);
825 FLAG_MERGE(listener);
826 FLAG_MERGE(smtpaddress);
827 FLAG_MERGE(preconnect);
828 FLAG_MERGE(postconnect);
832 FLAG_MERGE(fetchall);
836 FLAG_MERGE(pass8bits);
837 FLAG_MERGE(dropstatus);
838 FLAG_MERGE(mimedecode);
841 FLAG_MERGE(warnings);
842 FLAG_MERGE(fetchlimit);
843 FLAG_MERGE(batchlimit);
851 FLAG_MERGE(properties);
855 static int load_params(int argc, char **argv, int optind)
857 int implicitmode, st;
859 struct query def_opts, *ctl;
862 run.bouncemail = TRUE;
864 memset(&def_opts, '\0', sizeof(struct query));
865 def_opts.smtp_socket = -1;
866 def_opts.smtpaddress = (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? */
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.use_syslog)
967 run.use_syslog = (cmd_run.use_syslog == FLAG_TRUE);
968 if (cmd_run.postmaster)
969 run.postmaster = cmd_run.postmaster;
970 if (cmd_run.bouncemail)
971 run.bouncemail = cmd_run.bouncemail;
973 /* check and daemon options are not compatible */
974 if (check_only && run.poll_interval)
975 run.poll_interval = 0;
977 /* merge in wired defaults, do sanity checks and prepare internal fields */
978 for (ctl = querylist; ctl; ctl = ctl->next)
982 if (configdump || (ctl->active && !(implicitmode && ctl->server.skip)))
984 /* merge in defaults */
985 optmerge(ctl, &def_opts, FALSE);
987 /* force command-line options */
988 optmerge(ctl, &cmd_opts, TRUE);
990 /* this code enables flags to be turned off */
991 #define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
993 else if (flag == FLAG_FALSE)\
997 DEFAULT(ctl->keep, FALSE);
998 DEFAULT(ctl->fetchall, FALSE);
999 DEFAULT(ctl->flush, FALSE);
1000 DEFAULT(ctl->rewrite, TRUE);
1001 DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
1002 DEFAULT(ctl->forcecr, FALSE);
1003 DEFAULT(ctl->pass8bits, FALSE);
1004 DEFAULT(ctl->dropstatus, FALSE);
1005 DEFAULT(ctl->mimedecode, FALSE);
1006 DEFAULT(ctl->idle, FALSE);
1007 DEFAULT(ctl->server.dns, TRUE);
1008 DEFAULT(ctl->server.uidl, FALSE);
1010 DEFAULT(ctl->use_ssl, FALSE);
1012 DEFAULT(ctl->server.checkalias, FALSE);
1016 * DNS support is required for some protocols. We used to
1017 * do this unconditionally, but it made fetchmail excessively
1018 * vulnerable to misconfigured DNS setups.
1020 * If we're using ETRN, the smtp hunt list is the list of
1021 * systems we're polling on behalf of; these have to be
1022 * fully-qualified domain names. The default for this list
1023 * should be the FQDN of localhost.
1025 * If we're using Kerberos for authentication, we need
1026 * the FQDN in order to generate capability keys.
1028 if (ctl->server.protocol == P_ETRN
1029 || ctl->server.preauthenticate == A_KERBEROS_V4
1030 || ctl->server.preauthenticate == A_KERBEROS_V5)
1031 if (strcmp(fetchmailhost, "localhost") == 0)
1032 fetchmailhost = host_fqdn();
1035 * Make sure we have a nonempty host list to forward to.
1038 save_str(&ctl->smtphunt, fetchmailhost, FALSE);
1040 /* if `user' doesn't name a real local user, try to run as root */
1041 if ((pw = getpwnam(user)) == (struct passwd *)NULL)
1044 ctl->uid = pw->pw_uid; /* for local delivery via MDA */
1045 if (!ctl->localnames) /* for local delivery via SMTP */
1046 save_str_pair(&ctl->localnames, user, NULL);
1048 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
1049 /* can't handle multidrop mailboxes unless we can do DNS lookups */
1050 if (ctl->localnames && ctl->localnames->next && ctl->server.dns)
1052 ctl->server.dns = FALSE;
1053 report(stderr, _("fetchmail: warning: no DNS available to check multidrop fetches from %s\n"), ctl->server.pollname);
1055 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
1059 * Compute the true name of the mailserver host.
1060 * There are two clashing cases here:
1062 * (1) The poll name is a label, possibly on one of several
1063 * poll configurations for the same host. In this case
1064 * the `via' option will be present and give the true name.
1066 * (2) The poll name is the true one, the via name is
1067 * localhost. This is going to be typical for ssh-using
1070 * We're going to assume the via name is true unless it's
1073 if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
1074 ctl->server.queryname = xstrdup(ctl->server.via);
1076 ctl->server.queryname = xstrdup(ctl->server.pollname);
1079 /* If either the pollname or vianame are "hesiod" we want to
1080 lookup the user's hesiod pobox host */
1082 if (!strcasecmp(ctl->server.queryname, "hesiod")) {
1083 struct hes_postoffice *hes_p;
1084 hes_p = hes_getmailhost(ctl->remotename);
1085 if (hes_p != NULL && strcmp(hes_p->po_type, "POP") == 0) {
1086 free(ctl->server.queryname);
1087 ctl->server.queryname = xstrdup(hes_p->po_host);
1088 if (ctl->server.via)
1089 free(ctl->server.via);
1090 ctl->server.via = xstrdup(hes_p->po_host);
1093 _("couldn't find HESIOD pobox for %s\n"),
1100 * We may have to canonicalize the server truename for later use.
1101 * Do this just once for each lead server, if necessary, in order
1102 * to minimize DNS round trips.
1104 if (ctl->server.lead_server)
1106 char *leadname = ctl->server.lead_server->truename;
1108 /* prevent core dump from ill-formed or duplicate entry */
1112 _("Lead server has no name.\n"));
1116 ctl->server.truename = xstrdup(leadname);
1118 #ifdef HAVE_GETHOSTBYNAME
1119 else if (ctl->server.preauthenticate==A_KERBEROS_V4 ||
1120 ctl->server.preauthenticate==A_KERBEROS_V5 ||
1121 (ctl->server.dns && MULTIDROP(ctl)))
1123 struct hostent *namerec;
1125 /* compute the canonical name of the host */
1127 namerec = gethostbyname(ctl->server.queryname);
1128 if (namerec == (struct hostent *)NULL)
1131 _("couldn't find canonical DNS name of %s\n"),
1132 ctl->server.pollname);
1136 ctl->server.truename=xstrdup((char *)namerec->h_name);
1138 #endif /* HAVE_GETHOSTBYNAME */
1140 ctl->server.truename = xstrdup(ctl->server.queryname);
1142 /* if no folders were specified, set up the null one as default */
1143 if (!ctl->mailboxes)
1144 save_str(&ctl->mailboxes, (char *)NULL, 0);
1146 /* maybe user overrode timeout on command line? */
1147 if (ctl->server.timeout == -1)
1148 ctl->server.timeout = CLIENT_TIMEOUT;
1152 if (ctl->server.port < 0)
1154 (void) fprintf(stderr,
1155 _("%s configuration invalid, port number cannot be negative\n"),
1156 ctl->server.pollname);
1159 if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
1161 (void) fprintf(stderr,
1162 _("%s configuration invalid, RPOP requires a privileged port\n"),
1163 ctl->server.pollname);
1166 if (ctl->listener == LMTP_MODE)
1170 for (idp = ctl->smtphunt; idp; idp = idp->next)
1174 if (!(cp = strrchr(idp->id, '/')) ||
1175 (atoi(++cp) == SMTP_PORT))
1177 (void) fprintf(stderr,
1178 _("%s configuration invalid, LMTP can't use default SMTP port\n"),
1179 ctl->server.pollname);
1184 #endif /* !INET6_ENABLE */
1187 * "I beg to you, have mercy on the week minds like myself."
1188 * wrote Pehr Anderson. Your petition is granted.
1190 if (ctl->fetchall && ctl->keep && run.poll_interval && !nodetach)
1192 (void) fprintf(stderr,
1193 _("Both fetchall and keep on in daemon mode is a mistake!\n"));
1200 /* initialize UID handling */
1201 if (!versioninfo && (st = prc_filecheck(run.idfile, !versioninfo)) != 0)
1204 initialize_saved_lists(querylist, run.idfile);
1205 #endif /* POP3_ENABLE */
1208 * If the user didn't set a last-resort user to get misaddressed
1209 * multidrop mail, set an appropriate default here.
1211 if (!run.postmaster)
1213 if (getuid()) /* ordinary user */
1214 run.postmaster = user;
1216 run.postmaster = "postmaster";
1219 return(implicitmode);
1222 static void terminate_poll(int sig)
1223 /* to be executed at the end of a poll cycle */
1226 * Close all SMTP delivery sockets. For optimum performance
1227 * we'd like to hold them open til end of run, but (1) this
1228 * loses if our poll interval is longer than the MTA's inactivity
1229 * timeout, and (2) some MTAs (like smail) don't deliver after
1230 * each message, but rather queue up mail and wait to actually
1231 * deliver it until the input socket is closed.
1233 * Sending SMTP QUIT on signal is theoretically nice, but led to a
1234 * subtle bug. If fetchmail was terminated by signal while it was
1235 * shipping message text, it would hang forever waiting for a
1236 * command acknowledge. In theory we could enable the QUIT
1237 * only outside of the message send. In practice, we don't
1238 * care. All mailservers hang up on a dropped TCP/IP connection
1243 report(stdout, _("terminated with signal %d\n"), sig);
1248 /* terminate all SMTP connections cleanly */
1249 for (ctl = querylist; ctl; ctl = ctl->next)
1250 if (ctl->smtp_socket != -1)
1252 SMTP_quit(ctl->smtp_socket);
1253 SockClose(ctl->smtp_socket);
1254 ctl->smtp_socket = -1;
1260 * Update UID information at end of each poll, rather than at end
1261 * of run, because that way we don't lose all UIDL information since
1262 * the beginning of time if fetchmail crashes.
1265 write_saved_lists(querylist, run.idfile);
1266 #endif /* POP3_ENABLE */
1269 static void terminate_run(int sig)
1270 /* to be executed on normal or signal-induced termination */
1274 terminate_poll(sig);
1277 * Craig Metz, the RFC1938 one-time-password guy, points out:
1278 * "Remember that most kernels don't zero pages before handing them to the
1279 * next process and many kernels share pages between user and kernel space.
1280 * You'd be very surprised what you can find from a short program to do a
1281 * malloc() and then dump the contents of the pages you got. By zeroing
1282 * the secrets at end of run (earlier if you can), you make sure the next
1283 * guy can't get the password/pass phrase."
1285 * Right you are, Craig!
1287 for (ctl = querylist; ctl; ctl = ctl->next)
1289 memset(ctl->password, '\0', strlen(ctl->password));
1291 #if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
1295 exit(successes ? PS_SUCCESS : querystatus);
1299 * Sequence of protocols to try when autoprobing, most capable to least.
1301 static const int autoprobe[] =
1305 #endif /* IMAP_ENABLE */
1308 #endif /* POP3_ENABLE */
1311 #endif /* POP2_ENABLE */
1314 static int query_host(struct query *ctl)
1315 /* perform fetch transaction with single host */
1320 * If we're syslogging the progress messages are automatically timestamped.
1321 * Force timestamping if we're going to a logfile.
1323 if (outlevel >= O_VERBOSE || (run.logfile && outlevel > O_SILENT))
1325 report(stdout, _("%s querying %s (protocol %s) at %s\n"),
1327 ctl->server.pollname,
1328 showproto(ctl->server.protocol),
1331 switch (ctl->server.protocol) {
1333 for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
1335 ctl->server.protocol = autoprobe[i];
1336 if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY || st == PS_SMTP)
1339 ctl->server.protocol = P_AUTO;
1343 return(doPOP2(ctl));
1345 report(stderr, _("POP2 support is not configured.\n"));
1346 return(PS_PROTOCOL);
1347 #endif /* POP2_ENABLE */
1353 return(doPOP3(ctl));
1355 report(stderr, _("POP3 support is not configured.\n"));
1356 return(PS_PROTOCOL);
1357 #endif /* POP3_ENABLE */
1361 case P_IMAP_CRAM_MD5:
1367 return(doIMAP(ctl));
1369 report(stderr, _("IMAP support is not configured.\n"));
1370 return(PS_PROTOCOL);
1371 #endif /* IMAP_ENABLE */
1374 report(stderr, _("ETRN support is not configured.\n"));
1375 return(PS_PROTOCOL);
1377 #ifdef HAVE_GETHOSTBYNAME
1378 return(doETRN(ctl));
1380 report(stderr, _("Cannot support ETRN without gethostbyname(2).\n"));
1381 return(PS_PROTOCOL);
1382 #endif /* HAVE_GETHOSTBYNAME */
1383 #endif /* ETRN_ENABLE */
1385 report(stderr, _("unsupported protocol selected.\n"));
1386 return(PS_PROTOCOL);
1390 static void dump_params (struct runctl *runp,
1391 struct query *querylist, flag implicit)
1392 /* display query parameters in English */
1396 if (runp->poll_interval)
1397 printf(_("Poll interval is %d seconds\n"), runp->poll_interval);
1399 printf(_("Logfile is %s\n"), runp->logfile);
1400 if (strcmp(runp->idfile, IDFILE_NAME))
1401 printf(_("Idfile is %s\n"), runp->idfile);
1402 #if defined(HAVE_SYSLOG)
1403 if (runp->use_syslog)
1404 printf(_("Progress messages will be logged via syslog\n"));
1406 if (runp->invisible)
1407 printf(_("Fetchmail will masquerade and will not generate Received\n"));
1408 if (runp->postmaster)
1409 printf(_("Fetchmail will forward misaddressed multidrop messages to %s.\n"),
1412 if (!runp->bouncemail)
1413 printf(_("Fetchmail will direct error mail to the postmaster.\n"));
1414 else if (outlevel >= O_VERBOSE)
1415 printf(_("Fetchmail will direct error mail to the sender.\n"));
1417 for (ctl = querylist; ctl; ctl = ctl->next)
1419 if (!ctl->active || (implicit && ctl->server.skip))
1422 printf(_("Options for retrieving from %s@%s:\n"),
1423 ctl->remotename, visbuf(ctl->server.pollname));
1425 if (ctl->server.via && (ctl->server.protocol != P_ETRN))
1426 printf(_(" Mail will be retrieved via %s\n"), ctl->server.via);
1428 if (ctl->server.interval)
1429 printf(_(" Poll of this server will occur every %d intervals.\n"),
1430 ctl->server.interval);
1431 if (ctl->server.truename)
1432 printf(_(" True name of server is %s.\n"), ctl->server.truename);
1433 if (ctl->server.skip || outlevel >= O_VERBOSE)
1434 printf(_(" This host %s be queried when no host is specified.\n"),
1435 ctl->server.skip ? _("will not") : _("will"));
1437 * Don't poll for password when there is one or when using the ETRN
1438 * or IMAP-GSS protocol
1440 /* ETRN, IMAP_GSS, and IMAP_K4 do not need a password, so skip this */
1441 if ( (ctl->server.protocol != P_ETRN)
1443 && (ctl->server.protocol != P_IMAP_GSS)
1445 && (ctl->server.protocol != P_IMAP_K4) ) {
1447 printf(_(" Password will be prompted for.\n"));
1448 else if (outlevel >= O_VERBOSE)
1450 if (ctl->server.protocol == P_APOP)
1451 printf(_(" APOP secret = \"%s\".\n"),
1452 visbuf(ctl->password));
1453 else if (ctl->server.protocol == P_RPOP)
1454 printf(_(" RPOP id = \"%s\".\n"),
1455 visbuf(ctl->password));
1457 printf(_(" Password = \"%s\".\n"),
1458 visbuf(ctl->password));
1462 if (ctl->server.protocol == P_POP3
1464 && ctl->server.service && !strcmp(ctl->server.service, KPOP_PORT)
1465 #else /* INET6_ENABLE */
1466 && ctl->server.port == KPOP_PORT
1467 #endif /* INET6_ENABLE */
1468 && (ctl->server.preauthenticate == A_KERBEROS_V4 ||
1469 ctl->server.preauthenticate == A_KERBEROS_V5))
1470 printf(_(" Protocol is KPOP with Kerberos %s authentication"),
1471 ctl->server.preauthenticate == A_KERBEROS_V5 ? "V" : "IV");
1473 printf(_(" Protocol is %s"), showproto(ctl->server.protocol));
1475 if (ctl->server.service)
1476 printf(_(" (using service %s)"), ctl->server.service);
1477 if (ctl->server.netsec)
1478 printf(_(" (using network security options %s)"), ctl->server.netsec);
1479 #else /* INET6_ENABLE */
1480 if (ctl->server.port)
1481 printf(_(" (using port %d)"), ctl->server.port);
1482 #endif /* INET6_ENABLE */
1483 else if (outlevel >= O_VERBOSE)
1484 printf(_(" (using default port)"));
1485 if (ctl->server.uidl && (ctl->server.protocol != P_ETRN))
1486 printf(_(" (forcing UIDL use)"));
1489 if (ctl->server.preauthenticate == A_KERBEROS_V4)
1490 printf(_(" Kerberos V4 preauthentication enabled.\n"));
1491 else if (ctl->server.preauthenticate == A_KERBEROS_V5)
1492 printf(_(" Kerberos V5 preauthentication enabled.\n"));
1493 else if (ctl->server.preauthenticate == A_SSH)
1494 printf(_(" End-to-end encryption assumed.\n"));
1497 printf(" SSL encrypted sessions enabled.\n");
1499 if (ctl->server.timeout > 0)
1500 printf(_(" Server nonresponse timeout is %d seconds"), ctl->server.timeout);
1501 if (ctl->server.timeout == CLIENT_TIMEOUT)
1502 printf(_(" (default).\n"));
1506 if (ctl->server.protocol != P_ETRN) {
1507 if (!ctl->mailboxes->id)
1508 printf(_(" Default mailbox selected.\n"));
1513 printf(_(" Selected mailboxes are:"));
1514 for (idp = ctl->mailboxes; idp; idp = idp->next)
1515 printf(" %s", idp->id);
1518 printf(_(" %s messages will be retrieved (--all %s).\n"),
1519 ctl->fetchall ? _("All") : _("Only new"),
1520 ctl->fetchall ? "on" : "off");
1521 printf(_(" Fetched messages %s be kept on the server (--keep %s).\n"),
1522 ctl->keep ? _("will") : _("will not"),
1523 ctl->keep ? "on" : "off");
1524 printf(_(" Old messages %s be flushed before message retrieval (--flush %s).\n"),
1525 ctl->flush ? _("will") : _("will not"),
1526 ctl->flush ? "on" : "off");
1527 printf(_(" Rewrite of server-local addresses is %s (--norewrite %s).\n"),
1528 ctl->rewrite ? _("enabled") : _("disabled"),
1529 ctl->rewrite ? "off" : "on");
1530 printf(_(" Carriage-return stripping is %s (stripcr %s).\n"),
1531 ctl->stripcr ? _("enabled") : _("disabled"),
1532 ctl->stripcr ? "on" : "off");
1533 printf(_(" Carriage-return forcing is %s (forcecr %s).\n"),
1534 ctl->forcecr ? _("enabled") : _("disabled"),
1535 ctl->forcecr ? "on" : "off");
1536 printf(_(" Interpretation of Content-Transfer-Encoding is %s (pass8bits %s).\n"),
1537 ctl->pass8bits ? _("disabled") : _("enabled"),
1538 ctl->pass8bits ? "on" : "off");
1539 printf(_(" MIME decoding is %s (mimedecode %s).\n"),
1540 ctl->mimedecode ? _("enabled") : _("disabled"),
1541 ctl->mimedecode ? "on" : "off");
1542 printf(_(" Idle after poll is %s (idle %s).\n"),
1543 ctl->idle ? _("enabled") : _("disabled"),
1544 ctl->idle ? "on" : "off");
1545 printf(_(" Nonempty Status lines will be %s (dropstatus %s)\n"),
1546 ctl->dropstatus ? _("discarded") : _("kept"),
1547 ctl->dropstatus ? "on" : "off");
1548 if (NUM_NONZERO(ctl->limit))
1550 if (NUM_NONZERO(ctl->limit))
1551 printf(_(" Message size limit is %d octets (--limit %d).\n"),
1552 ctl->limit, ctl->limit);
1553 else if (outlevel >= O_VERBOSE)
1554 printf(_(" No message size limit (--limit 0).\n"));
1555 if (run.poll_interval > 0)
1556 printf(_(" Message size warning interval is %d seconds (--warnings %d).\n"),
1557 ctl->warnings, ctl->warnings);
1558 else if (outlevel >= O_VERBOSE)
1559 printf(_(" Size warnings on every poll (--warnings 0).\n"));
1561 if (NUM_NONZERO(ctl->fetchlimit))
1562 printf(_(" Received-message limit is %d (--fetchlimit %d).\n"),
1563 ctl->fetchlimit, ctl->fetchlimit);
1564 else if (outlevel >= O_VERBOSE)
1565 printf(_(" No received-message limit (--fetchlimit 0).\n"));
1566 if (NUM_NONZERO(ctl->batchlimit))
1567 printf(_(" SMTP message batch limit is %d.\n"), ctl->batchlimit);
1568 else if (outlevel >= O_VERBOSE)
1569 printf(_(" No SMTP message batch limit (--batchlimit 0).\n"));
1570 if (ctl->server.protocol == P_IMAP)
1572 if (NUM_NONZERO(ctl->expunge))
1573 printf(_(" Deletion interval between expunges forced to %d (--expunge %d).\n"), ctl->expunge, ctl->expunge);
1574 else if (outlevel >= O_VERBOSE)
1575 printf(_(" No forced expunges (--expunge 0).\n"));
1579 printf(_(" Messages will be appended to %s as BSMTP\n"), visbuf(ctl->bsmtp));
1580 else if (ctl->mda && (ctl->server.protocol != P_ETRN))
1581 printf(_(" Messages will be delivered with \"%s\".\n"), visbuf(ctl->mda));
1586 printf(_(" Messages will be %cMTP-forwarded to:"), ctl->listener);
1587 for (idp = ctl->smtphunt; idp; idp = idp->next)
1589 printf(" %s", idp->id);
1590 if (!idp->val.status.mark)
1591 printf(_(" (default)"));
1594 if (ctl->smtpaddress)
1595 printf(_(" Host part of MAIL FROM line will be %s\n"),
1598 if (ctl->server.protocol != P_ETRN)
1600 if (ctl->antispam != (struct idlist *)NULL)
1604 printf(_(" Recognized listener spam block responses are:"));
1605 for (idp = ctl->antispam; idp; idp = idp->next)
1606 printf(" %d", idp->val.status.num);
1609 else if (outlevel >= O_VERBOSE)
1610 printf(_(" Spam-blocking disabled\n"));
1612 if (ctl->preconnect)
1613 printf(_(" Server connection will be brought up with \"%s\".\n"),
1614 visbuf(ctl->preconnect));
1615 else if (outlevel >= O_VERBOSE)
1616 printf(_(" No pre-connection command.\n"));
1617 if (ctl->postconnect)
1618 printf(_(" Server connection will be taken down with \"%s\".\n"),
1619 visbuf(ctl->postconnect));
1620 else if (outlevel >= O_VERBOSE)
1621 printf(_(" No post-connection command.\n"));
1622 if (ctl->server.protocol != P_ETRN) {
1623 if (!ctl->localnames)
1624 printf(_(" No localnames declared for this host.\n"));
1630 for (idp = ctl->localnames; idp; idp = idp->next)
1633 if (count > 1 || ctl->wildcard)
1634 printf(_(" Multi-drop mode: "));
1636 printf(_(" Single-drop mode: "));
1638 printf(_("%d local name(s) recognized.\n"), count);
1639 if (outlevel >= O_VERBOSE)
1641 for (idp = ctl->localnames; idp; idp = idp->next)
1643 printf("\t%s -> %s\n", idp->id, idp->val.id2);
1645 printf("\t%s\n", idp->id);
1647 fputs("\t*\n", stdout);
1650 if (count > 1 || ctl->wildcard)
1652 printf(_(" DNS lookup for multidrop addresses is %s.\n"),
1653 ctl->server.dns ? _("enabled") : _("disabled"));
1654 if (ctl->server.dns)
1656 printf(_(" Server aliases will be compared with multidrop addresses by "));
1657 if (ctl->server.checkalias)
1658 printf(_("IP address.\n"));
1660 printf(_("name.\n"));
1662 if (ctl->server.envelope == STRING_DISABLED)
1663 printf(_(" Envelope-address routing is disabled\n"));
1666 printf(_(" Envelope header is assumed to be: %s\n"),
1667 ctl->server.envelope ? ctl->server.envelope:_("Received"));
1668 if (ctl->server.envskip > 1 || outlevel >= O_VERBOSE)
1669 printf(_(" Number of envelope header to be parsed: %d\n"),
1670 ctl->server.envskip);
1671 if (ctl->server.qvirtual)
1672 printf(_(" Prefix %s will be removed from user id\n"),
1673 ctl->server.qvirtual);
1674 else if (outlevel >= O_VERBOSE)
1675 printf(_(" No prefix stripping\n"));
1678 if (ctl->server.akalist)
1682 printf(_(" Predeclared mailserver aliases:"));
1683 for (idp = ctl->server.akalist; idp; idp = idp->next)
1684 printf(" %s", idp->id);
1687 if (ctl->server.localdomains)
1691 printf(_(" Local domains:"));
1692 for (idp = ctl->server.localdomains; idp; idp = idp->next)
1693 printf(" %s", idp->id);
1699 #if defined(linux) || defined(__FreeBSD__)
1700 if (ctl->server.interface)
1701 printf(_(" Connection must be through interface %s.\n"), ctl->server.interface);
1702 else if (outlevel >= O_VERBOSE)
1703 printf(_(" No interface requirement specified.\n"));
1704 if (ctl->server.monitor)
1705 printf(_(" Polling loop will monitor %s.\n"), ctl->server.monitor);
1706 else if (outlevel >= O_VERBOSE)
1707 printf(_(" No monitor interface specified.\n"));
1710 if (ctl->server.plugin)
1711 printf(_(" Server connections will be mode via plugin %s (--plugin %s).\n"), ctl->server.plugin, ctl->server.plugin);
1712 else if (outlevel >= O_VERBOSE)
1713 printf(_(" No plugin command specified.\n"));
1714 if (ctl->server.plugout)
1715 printf(_(" Listener connections will be mode via plugout %s (--plugout %s).\n"), ctl->server.plugout, ctl->server.plugout);
1716 else if (outlevel >= O_VERBOSE)
1717 printf(_(" No plugout command specified.\n"));
1719 if (ctl->server.protocol > P_POP2 && (ctl->server.protocol != P_ETRN))
1722 printf(_(" No UIDs saved from this host.\n"));
1728 for (idp = ctl->oldsaved; idp; idp = idp->next)
1731 printf(_(" %d UIDs saved.\n"), count);
1732 if (outlevel >= O_VERBOSE)
1733 for (idp = ctl->oldsaved; idp; idp = idp->next)
1734 printf("\t%s\n", idp->id);
1738 if (ctl->properties)
1739 printf(_(" Pass-through properties \"%s\".\n"),
1740 visbuf(ctl->properties));
1744 /* fetchmail.c ends here */