2 * fetchmail.c -- main driver module for fetchmail
4 * For license terms, see the file COPYING in this directory.
11 #if defined(STDC_HEADERS)
14 #if defined(HAVE_UNISTD_H)
17 #if defined(HAVE_ALLOCA_H)
22 #if defined(HAVE_SYSLOG)
28 #include <sys/types.h>
32 #ifdef HAVE_GETHOSTBYNAME
34 #endif /* HAVE_GETHOSTBYNAME */
40 #include "fetchmail.h"
46 #define DROPDEAD 6 /* maximum bad socket opens */
48 /* prototypes for internal functions */
49 static int load_params(int, char **, int);
50 static void dump_params (struct query *);
51 static int query_host(struct query *);
53 /* controls the detail level of status/progress messages written to stderr */
54 int outlevel; /* see the O_.* constants above */
56 /* daemon mode control */
57 flag nodetach; /* if TRUE, don't detach daemon process */
58 flag quitmode; /* if --quit was set */
59 flag check_only; /* if --probe was set */
60 char *cmd_logfile; /* if --logfile was set */
61 int cmd_daemon; /* if --daemon was set */
63 /* miscellaneous global controls */
64 char *idfile; /* UID list file */
65 flag versioninfo; /* emit only version info */
66 char *user; /* the name of the invoking user */
67 char *fetchmailhost; /* the name of the host running fetchmail */
68 char *program_name; /* the name to prefix error messages with */
70 static char *lockfile; /* name of lockfile */
71 static int querystatus; /* status of query */
72 static int successes; /* count number of successful polls */
73 static int lastsig; /* last signal received */
75 static void termhook(); /* forward declaration of exit hook */
77 RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing); lastsig = sig;}
80 static void unlockit(void)
81 #else /* use on_exit(), e.g. on SunOS */
82 static void unlockit(int n, void *p)
84 /* must-do actions for exit (but we can't count on being able to do malloc) */
89 int main (int argc, char **argv)
92 int parsestatus, implicitmode = FALSE;
96 netrc_entry *netrc_list;
97 char *netrc_file, tmpbuf[BUFSIZ];
100 envquery(argc, argv);
102 #define IDFILE_NAME ".fetchids"
103 idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
104 strcpy(idfile, home);
106 strcat(idfile, IDFILE_NAME);
110 if ((parsestatus = parsecmdline(argc,argv,&cmd_opts)) < 0)
113 /* this hint to stdio should help messages come out in the right order */
114 setvbuf(stdout, NULL, _IOLBF, POPBUFSIZE);
117 printf("This is fetchmail release %s\n", RELEASE_ID);
119 /* avoid parsing the config file if all we're doing is killing a daemon */
121 implicitmode = load_params(argc, argv, optind);
123 /* set up to do lock protocol */
125 strcpy(tmpbuf, "/var/run/fetchmail.pid");
127 strcpy(tmpbuf, home);
128 strcat(tmpbuf, "/.fetchmail");
131 /* perhaps we just want to check options? */
133 printf("Taking options from command line");
134 if (access(rcfile, 0))
137 printf(" and %s\n", rcfile);
139 printf("Poll interval is %d seconds\n", poll_interval);
140 if (outlevel == O_VERBOSE)
141 printf("Lockfile at %s\n", tmpbuf);
143 printf("Logfile is %s\n", logfile);
144 for (ctl = querylist; ctl; ctl = ctl->next) {
145 if (ctl->active && !(implicitmode && ctl->server.skip))
148 if (querylist == NULL)
149 (void) fprintf(stderr,
150 "No mailservers set up -- perhaps %s is missing?\n", rcfile);
154 /* check for another fetchmail running concurrently */
156 if ((lockfile = (char *) malloc(strlen(tmpbuf) + 1)) == NULL)
158 fprintf(stderr,"fetchmail: cannot allocate memory for lock name.\n");
162 (void) strcpy(lockfile, tmpbuf);
163 if ((lockfp = fopen(lockfile, "r")) != NULL )
165 bkgd = (fscanf(lockfp,"%d %d", &pid, &st) == 2);
167 if (kill(pid, 0) == -1) {
168 fprintf(stderr,"fetchmail: removing stale lockfile\n");
176 /* if no mail servers listed and nothing in background, we're done */
177 if (!quitmode && pid == -1 && querylist == NULL) {
178 (void)fputs("fetchmail: no mailservers have been specified.\n",stderr);
182 /* perhaps user asked us to kill the other fetchmail */
187 fprintf(stderr,"fetchmail: no other fetchmail is running\n");
190 else if (kill(pid, SIGTERM) < 0)
192 fprintf(stderr,"fetchmail: error killing %s fetchmail at %d.\n",
193 bkgd ? "background" : "foreground", pid);
198 fprintf(stderr,"fetchmail: %s fetchmail at %d killed.\n",
199 bkgd ? "background" : "foreground", pid);
205 /* another fetchmail is running -- wake it up or die */
211 "fetchmail: can't check mail while another fetchmail to same host is running.\n");
214 else if (!implicitmode)
217 "fetchmail: can't poll specified hosts with another fetchmail running at %d.\n",
224 "fetchmail: another foreground fetchmail is running at %d.\n",
231 "fetchmail: can't accept options while a background fetchmail is running.\n");
234 else if (kill(pid, SIGUSR1) == 0)
237 "fetchmail: background fetchmail at %d awakened.\n",
244 * Should never happen -- possible only if a background fetchmail
245 * croaks after the first kill probe above but before the
246 * SIGUSR1/SIGHUP transmission.
249 "fetchmail: elder sibling at %d died mysteriously.\n",
251 return(PS_UNDEFINED);
255 /* parse the ~/.netrc file (if present) for future password lookups. */
256 netrc_file = (char *) xmalloc (strlen (home) + 8);
257 strcpy (netrc_file, home);
258 strcat (netrc_file, "/.netrc");
259 netrc_list = parse_netrc(netrc_file);
261 /* pick up interactively any passwords we need but don't have */
262 for (ctl = querylist; ctl; ctl = ctl->next)
263 if (ctl->active && !(implicitmode && ctl->server.skip)&&!ctl->password)
265 if (ctl->server.preauthenticate == A_KERBEROS_V4 || ctl->server.protocol == P_IMAP_K4)
266 /* Server won't care what the password is, but there
267 must be some non-null string here. */
268 ctl->password = ctl->remotename;
271 /* look up the host and account in the .netrc file. */
272 netrc_entry *p = search_netrc(netrc_list,ctl->server.pollname);
273 while (p && strcmp(p->account, ctl->remotename))
274 p = search_netrc(p->next, ctl->remotename);
276 /* if we find a matching entry with a password, use it */
277 if (p && p->password)
278 ctl->password = xstrdup(p->password);
281 if (ctl->server.protocol != P_ETRN && ctl->server.protocol != P_IMAP_K4 && !ctl->password)
283 (void) sprintf(tmpbuf, "Enter password for %s@%s: ",
284 ctl->remotename, ctl->server.pollname);
285 ctl->password = xstrdup((char *)getpassword(tmpbuf));
290 * Maybe time to go to demon mode...
292 #if defined(HAVE_SYSLOG)
294 openlog(program_name, LOG_PID, LOG_MAIL);
300 daemonize(logfile, termhook);
301 error( 0, 0, "starting fetchmail %s daemon ", RELEASE_ID);
304 /* beyond here we don't want more than one fetchmail running per user */
306 signal(SIGABRT, termhook);
307 signal(SIGINT, termhook);
308 signal(SIGTERM, termhook);
309 signal(SIGALRM, termhook);
310 signal(SIGPIPE, termhook);
311 signal(SIGQUIT, termhook);
314 * With this simple hack, we make it possible for a foreground
315 * fetchmail to wake up one in daemon mode. What we want is the
316 * side effect of interrupting any sleep that may be going on,
317 * forcing fetchmail to re-poll its hosts.
319 signal(SIGUSR1, donothing);
321 /* pacify people who think all system daemons wake up on SIGHUP */
322 if (poll_interval && !getuid())
323 signal(SIGHUP, donothing);
325 /* here's the exclusion lock */
326 if ( (lockfp = fopen(lockfile,"w")) != NULL ) {
327 fprintf(lockfp,"%d",getpid());
329 fprintf(lockfp," %d", poll_interval);
335 on_exit(unlockit, (char *)NULL);
340 * Query all hosts. If there's only one, the error return will
341 * reflect the status of that transaction.
344 #ifdef HAVE_RES_SEARCH
345 sethostent(TRUE); /* use TCP/IP for mailserver queries */
346 #endif /* HAVE_RES_SEARCH */
349 for (ctl = querylist; ctl; ctl = ctl->next)
351 if (ctl->active && !(implicitmode && ctl->server.skip))
354 /* interface_approve() does its own error logging */
355 if (!interface_approve(&ctl->server))
361 * Compute the true name of the mailserver host.
362 * There are two clashing cases here:
364 * (1) The poll name is a label, possibly on one of several
365 * poll configurations for the same host. In this case
366 * the `via' option will be present and give the true name.
368 * (2) The poll name is the true one, the via name is
369 * localhost. This is going to be typical for ssh-using
372 * We're going to assume the via name is true unless it's
375 * Then, if we've got DNS, we'll try to canonicalize the name.
377 if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
378 ctl->server.truename = xstrdup(ctl->server.via);
380 ctl->server.truename = xstrdup(ctl->server.pollname);
382 #ifdef HAVE_GETHOSTBYNAME
384 * This functions partly as a probe to make sure our
385 * nameserver is still up. The multidrop case
386 * (especially) needs it.
388 if (ctl->server.preauthenticate==A_KERBEROS_V4 || MULTIDROP(ctl))
390 struct hostent *namerec;
392 /* compute the canonical name of the host */
394 namerec = gethostbyname(ctl->server.truename);
395 if (namerec == (struct hostent *)NULL)
398 "skipping %s poll, ",
399 ctl->server.pollname);
402 if (errno == ENETUNREACH)
403 break; /* go to sleep */
405 #ifdef HAVE_HERROR /* NEXTSTEP doesn't */
408 #endif /* HAVE_HERROR */
413 free(ctl->server.truename);
414 ctl->server.truename=xstrdup((char *)namerec->h_name);
417 #endif /* HAVE_GETHOSTBYNAME */
419 querystatus = query_host(ctl);
421 if (querystatus == PS_SUCCESS)
425 update_str_lists(ctl);
427 if (ctl->server.monitor)
429 /* Allow some time for the link to quiesce. One
430 * second is usually sufficient, three is safe.
431 * Note: this delay is important - don't remove!
434 interface_note_activity(&ctl->server);
440 #ifdef HAVE_RES_SEARCH
441 endhostent(); /* release TCP/IP connection to nameserver */
442 #endif /* HAVE_RES_SEARCH */
445 * Close all SMTP delivery sockets. For optimum performance
446 * we'd like to hold them open til end of run, but (1) this
447 * loses if our poll interval is longer than the MTA's inactivity
448 * timeout, and (2) some MTAs (like smail) don't deliver after
449 * each message, but rather queue up mail and wait to actually
450 * deliver it until the input socket is closed.
452 for (ctl = querylist; ctl; ctl = ctl->next)
453 if (ctl->smtp_socket != -1)
455 SMTP_quit(ctl->smtp_socket);
456 close(ctl->smtp_socket);
457 ctl->smtp_socket = -1;
461 * OK, we've polled. Now sleep.
465 if (outlevel == O_VERBOSE)
470 fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now));
474 * We can't use sleep(3) here because we need an alarm(3)
475 * equivalent in order to implement server nonresponse timeout.
476 * We'll just assume setitimer(2) is available since fetchmail
477 * has to have a BSDoid socket layer to work at all.
480 struct itimerval ntimeout;
482 ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_usec = 0;
483 ntimeout.it_value.tv_sec = poll_interval;
484 ntimeout.it_value.tv_usec = 0;
486 setitimer(ITIMER_REAL,&ntimeout,NULL);
487 signal(SIGALRM, donothing);
489 signal(SIGALRM, SIG_IGN);
490 if (lastsig == SIGUSR1
491 || ((poll_interval && !getuid()) && lastsig == SIGHUP))
493 #ifdef SYS_SIGLIST_DECLARED
494 error(0, 0, "awakened by %s", sys_siglist[lastsig]);
496 error(0, 0, "awakened by signal %d", lastsig);
501 if (outlevel == O_VERBOSE)
506 fprintf(stderr, "fetchmail: awakened at %s", ctime(&now));
512 if (outlevel == O_VERBOSE)
513 fprintf(stderr,"fetchmail: normal termination, status %d\n",
514 successes ? PS_SUCCESS : querystatus);
517 exit(successes ? PS_SUCCESS : querystatus);
520 static int load_params(int argc, char **argv, int optind)
522 int implicitmode, st;
524 struct query def_opts, *ctl, *mp;
526 memset(&def_opts, '\0', sizeof(struct query));
527 def_opts.smtp_socket = -1;
529 def_opts.server.protocol = P_AUTO;
530 def_opts.server.timeout = CLIENT_TIMEOUT;
531 def_opts.remotename = user;
532 save_str(&def_opts.smtphunt, -1, fetchmailhost);
534 /* this builds the host list */
535 if (prc_parse_file(rcfile, !versioninfo) != 0)
538 if ((implicitmode = (optind >= argc)))
540 for (ctl = querylist; ctl; ctl = ctl->next)
544 for (; optind < argc; optind++)
547 * If hostname corresponds to a host known from the rc file,
548 * simply declare it active. Otherwise synthesize a host
549 * record from command line and defaults
551 for (ctl = querylist; ctl; ctl = ctl->next)
552 if (!strcmp(ctl->server.pollname, argv[optind])
553 || str_in_list(&ctl->server.akalist, argv[optind]))
556 ctl = hostalloc(&cmd_opts);
557 ctl->server.pollname = xstrdup(argv[optind]);
563 /* if there's a defaults record, merge it and lose it */
564 if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
566 for (ctl = querylist->next; ctl; ctl = ctl->next)
567 optmerge(ctl, querylist);
568 querylist = querylist->next;
571 /* don't allow a defaults record after the first */
572 for (ctl = querylist; ctl; ctl = ctl->next)
573 if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
576 /* merge in wired defaults, do sanity checks and prepare internal fields */
577 for (ctl = querylist; ctl; ctl = ctl->next)
579 if (ctl->active && !(implicitmode && ctl->server.skip))
581 /* merge in defaults */
582 optmerge(ctl, &def_opts);
584 /* keep lusers from shooting themselves in the foot :-) */
585 if (poll_interval && ctl->limit)
587 fprintf(stderr,"fetchmail: you'd never see large messages!\n");
591 /* make sure delivery will default to a real local user */
592 if ((pw = getpwnam(user)) == (struct passwd *)NULL)
595 "fetchmail: can't set up default delivery to %s\n", user);
596 exit(PS_SYNTAX); /* has to be from bad rc file */
600 ctl->uid = pw->pw_uid; /* for local delivery via MDA */
601 if (!ctl->localnames) /* for local delivery via SMTP */
602 save_str_pair(&ctl->localnames, user, NULL);
605 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
606 /* can't handle multidrop mailboxes unless we can do DNS lookups */
607 if (ctl->localnames && ctl->localnames->next)
609 fputs("fetchmail: can't handle multidrop mailboxes without DNS\n",
613 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
615 /* this code enables flags to be turned off */
616 #define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
618 else if (flag == FLAG_FALSE)\
622 DEFAULT(ctl->keep, FALSE);
623 DEFAULT(ctl->fetchall, FALSE);
624 DEFAULT(ctl->flush, FALSE);
625 DEFAULT(ctl->rewrite, TRUE);
626 DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
627 DEFAULT(ctl->forcecr, FALSE);
628 DEFAULT(ctl->pass8bits, FALSE);
629 DEFAULT(ctl->dropstatus, FALSE);
630 DEFAULT(ctl->server.dns, TRUE);
631 DEFAULT(ctl->server.uidl, FALSE);
634 /* plug in the semi-standard way of indicating a mail address */
635 if (ctl->server.envelope == (char *)NULL)
636 ctl->server.envelope = "X-Envelope-To:";
638 /* if no folders were specified, set up the null one as default */
640 save_str(&ctl->mailboxes, -1, (char *)NULL);
642 /* maybe user overrode timeout on command line? */
643 if (ctl->server.timeout == -1)
644 ctl->server.timeout = CLIENT_TIMEOUT;
647 if (ctl->server.port < 0)
649 (void) fprintf(stderr,
650 "%s configuration invalid, port number cannot be negative",
651 ctl->server.pollname);
654 if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
656 (void) fprintf(stderr,
657 "%s configuration invalid, RPOP requires a privileged port",
658 ctl->server.pollname);
664 /* initialize UID handling */
665 if (!versioninfo && (st = prc_filecheck(idfile)) != 0)
668 initialize_saved_lists(querylist, idfile);
670 /* if cmd_logfile was explicitly set, use it to override logfile */
672 logfile = cmd_logfile;
674 /* likewise for poll_interval */
676 poll_interval = cmd_daemon;
678 /* check and daemon options are not compatible */
679 if (check_only && poll_interval)
682 return(implicitmode);
685 void termhook(int sig)
686 /* to be executed on normal or signal-induced termination */
691 * Craig Metz, the RFC1938 one-time-password guy, points out:
692 * "Remember that most kernels don't zero pages before handing them to the
693 * next process and many kernels share pages between user and kernel space.
694 * You'd be very surprised what you can find from a short program to do a
695 * malloc() and then dump the contents of the pages you got. By zeroing
696 * the secrets at end of run (earlier if you can), you make sure the next
697 * guy can't get the password/pass phrase."
699 * Right you are, Craig!
701 for (ctl = querylist; ctl; ctl = ctl->next)
703 memset(ctl->password, '\0', strlen(ctl->password));
706 * Sending SMTP QUIT on signal is theoretically nice, but led to a
707 * subtle bug. If fetchmail was terminated by signal while it was
708 * shipping message text, it would hang forever waiting for a
709 * command acknowledge. In theory we could enable the QUIT
710 * only outside of the message send. In practice, we don't
711 * care. All mailservers hang up on a dropped TCP/IP connection
716 error(0, 0, "terminated with signal %d", sig);
718 /* terminate all SMTP connections cleanly */
719 for (ctl = querylist; ctl; ctl = ctl->next)
720 if (ctl->smtp_socket != -1)
721 SMTP_quit(ctl->smtp_socket);
724 write_saved_lists(querylist, idfile);
726 exit(successes ? PS_SUCCESS : querystatus);
730 * Sequence of protocols to try when autoprobing, most capable to least.
733 static const int autoprobe[] = {P_IMAP, P_POP3, P_POP2};
735 static const int autoprobe[] = {P_IMAP, P_POP3};
736 #endif /* POP2_ENABLE */
738 static int query_host(struct query *ctl)
739 /* perform fetch transaction with single host */
743 if (poll_interval && ctl->server.interval)
745 if (ctl->server.poll_count++ % ctl->server.interval)
747 if (outlevel == O_VERBOSE)
749 "fetchmail: interval not reached, not querying %s\n",
750 ctl->server.pollname);
755 if (outlevel == O_VERBOSE)
760 fprintf(stderr, "fetchmail: %s querying %s (protocol %s) at %s",
762 ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now));
764 switch (ctl->server.protocol) {
766 for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
768 ctl->server.protocol = autoprobe[i];
769 if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY)
772 ctl->server.protocol = P_AUTO;
779 fprintf(stderr, "POP2 support is not configured.\n");
781 #endif /* POP2_ENABLE */
793 #ifdef HAVE_GETHOSTBYNAME
796 fprintf(stderr, "Cannot support ETRN without gethostbyname(2).\n");
798 #endif /* HAVE_GETHOSTBYNAME */
800 error(0, 0, "unsupported protocol selected.");
805 void dump_params (struct query *ctl)
806 /* display query parameters in English */
808 printf("Options for retrieving from %s@%s:\n",
809 ctl->remotename, visbuf(ctl->server.pollname));
812 printf(" Mail will be retrieved via %s\n", ctl->server.via);
814 if (ctl->server.interval)
815 printf(" Poll of this server will occur every %d intervals.\n",
816 ctl->server.interval);
817 if (ctl->server.truename)
818 printf(" True name of server is %s.\n", ctl->server.truename);
819 if (ctl->server.akalist)
823 printf(" Predeclared mailserver aliases:");
824 for (idp = ctl->server.akalist; idp; idp = idp->next)
825 printf(" %s", idp->id);
828 if (ctl->server.skip || outlevel == O_VERBOSE)
829 printf(" This host will%s be queried when no host is specified.\n",
830 ctl->server.skip ? " not" : "");
832 printf(" Password will be prompted for.\n");
833 else if (outlevel == O_VERBOSE)
834 if (ctl->server.protocol == P_APOP)
835 printf(" APOP secret = '%s'.\n", visbuf(ctl->password));
836 else if (ctl->server.protocol == P_RPOP)
837 printf(" RPOP id = '%s'.\n", visbuf(ctl->password));
839 printf(" Password = '%s'.\n", visbuf(ctl->password));
840 if (ctl->server.protocol == P_POP3
841 && ctl->server.port == KPOP_PORT
842 && ctl->server.preauthenticate == A_KERBEROS_V4)
843 printf(" Protocol is KPOP");
845 printf(" Protocol is %s", showproto(ctl->server.protocol));
846 if (ctl->server.port)
847 printf(" (using port %d)", ctl->server.port);
848 else if (outlevel == O_VERBOSE)
849 printf(" (using default port)");
850 if (ctl->server.uidl)
851 printf(" (forcing UIDL use)");
854 if (ctl->server.preauthenticate == A_KERBEROS_V4)
855 printf(" Kerberos V4 preauthentication enabled.\n");
856 if (ctl->server.timeout > 0)
857 printf(" Server nonresponse timeout is %d seconds", ctl->server.timeout);
858 if (ctl->server.timeout == CLIENT_TIMEOUT)
859 printf(" (default).\n");
862 if (ctl->server.localdomains)
866 printf(" Local domains:");
867 for (idp = ctl->server.localdomains; idp; idp = idp->next)
868 printf(" %s", idp->id);
872 if (!ctl->mailboxes->id)
873 printf(" Default mailbox selected.\n");
878 printf(" Selected mailboxes are:");
879 for (idp = ctl->mailboxes; idp; idp = idp->next)
880 printf(" %s", idp->id);
883 printf(" %s messages will be retrieved (--all %s).\n",
884 ctl->fetchall ? "All" : "Only new",
885 ctl->fetchall ? "on" : "off");
886 printf(" Fetched messages will%s be kept on the server (--keep %s).\n",
887 ctl->keep ? "" : " not",
888 ctl->keep ? "on" : "off");
889 printf(" Old messages will%s be flushed before message retrieval (--flush %s).\n",
890 ctl->flush ? "" : " not",
891 ctl->flush ? "on" : "off");
892 printf(" Rewrite of server-local addresses is %sabled (--norewrite %s).\n",
893 ctl->rewrite ? "en" : "dis",
894 ctl->rewrite ? "off" : "on");
895 printf(" Carriage-return stripping is %sabled (stripcr %s).\n",
896 ctl->stripcr ? "en" : "dis",
897 ctl->stripcr ? "on" : "off");
898 printf(" Carriage-return forcing is %sabled (forcecr %s).\n",
899 ctl->forcecr ? "en" : "dis",
900 ctl->forcecr ? "on" : "off");
901 printf(" Interpretation of Content-Transfer-Encoding is %sabled (pass8bits %s).\n",
902 ctl->pass8bits ? "dis" : "en",
903 ctl->pass8bits ? "on" : "off");
904 printf(" Nonempty Status lines will be %s (dropstatus %s)\n",
905 ctl->dropstatus ? "discarded" : "kept",
906 ctl->dropstatus ? "on" : "off");
908 printf(" Message size limit is %d bytes (--limit %d).\n",
909 ctl->limit, ctl->limit);
910 else if (outlevel == O_VERBOSE)
911 printf(" No message size limit (--limit 0).\n");
912 if (ctl->fetchlimit > 0)
913 printf(" Received-message limit is %d (--fetchlimit %d).\n",
914 ctl->fetchlimit, ctl->fetchlimit);
915 else if (outlevel == O_VERBOSE)
916 printf(" No received-message limit (--fetchlimit 0).\n");
917 if (ctl->batchlimit > 0)
918 printf(" SMTP message batch limit is %d.\n", ctl->batchlimit);
919 else if (outlevel == O_VERBOSE)
920 printf(" No SMTP message batch limit.\n");
922 printf(" Messages will be delivered with '%s.'\n", visbuf(ctl->mda));
927 printf(" Messages will be SMTP-forwarded to:");
928 for (idp = ctl->smtphunt; idp; idp = idp->next)
929 printf(" %s", idp->id);
933 printf(" Server connection will be preinitialized with '%s.'\n", visbuf(ctl->preconnect));
934 else if (outlevel == O_VERBOSE)
935 printf(" No preinitialization command.\n");
936 if (!ctl->localnames)
937 printf(" No localnames declared for this host.\n");
943 for (idp = ctl->localnames; idp; idp = idp->next)
946 printf(" %d local name(s) recognized.\n", count);
947 if (outlevel == O_VERBOSE)
949 for (idp = ctl->localnames; idp; idp = idp->next)
951 printf("\t%s -> %s\n", idp->id, idp->val.id2);
953 printf("\t%s\n", idp->id);
955 fputs("*\n", stdout);
958 printf(" DNS lookup for multidrop addresses is %sabled.\n",
959 ctl->server.dns ? "en" : "dis");
962 if (ctl->server.envelope == STRING_DISABLED)
963 printf(" Envelope-address routing is disabled\n");
965 printf(" Envelope header is assumed to be: %s\n", ctl->server.envelope);
968 if (ctl->server.interface)
969 printf(" Connection must be through interface %s.\n", ctl->server.interface);
970 else if (outlevel == O_VERBOSE)
971 printf(" No interface requirement specified.\n");
972 if (ctl->server.monitor)
973 printf(" Polling loop will monitor %s.\n", ctl->server.monitor);
974 else if (outlevel == O_VERBOSE)
975 printf(" No monitor interface specified.\n");
978 if (ctl->server.protocol > P_POP2)
980 printf(" No UIDs saved from this host.\n");
986 for (idp = ctl->oldsaved; idp; idp = idp->next)
989 printf(" %d UIDs saved.\n", count);
990 if (outlevel == O_VERBOSE)
991 for (idp = ctl->oldsaved; idp; idp = idp->next)
992 fprintf(stderr, "\t%s\n", idp->id);
996 /* fetchmail.c ends here */