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)
26 #if defined(HAVE_SYSLOG)
32 #include <sys/types.h>
36 #ifdef HAVE_GETHOSTBYNAME
38 #endif /* HAVE_GETHOSTBYNAME */
40 #include "fetchmail.h"
46 #define DROPDEAD 6 /* maximum bad socket opens */
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 query *);
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 /* daemon mode control */
61 flag nodetach; /* if TRUE, don't detach daemon process */
62 flag quitmode; /* if --quit was set */
63 flag check_only; /* if --probe was set */
64 char *cmd_logfile; /* if --logfile was set */
65 int cmd_daemon; /* if --daemon was set */
67 /* miscellaneous global controls */
68 char *idfile; /* UID list file */
69 flag versioninfo; /* emit only version info */
70 char *user; /* the name of the invoking user */
72 char *fetchmailhost; /* the name of the host running fetchmail */
73 char *program_name; /* the name to prefix error messages with */
75 static char *lockfile; /* name of lockfile */
76 static int querystatus; /* status of query */
77 static int successes; /* count number of successful polls */
78 static int lastsig; /* last signal received */
80 static void termhook(); /* forward declaration of exit hook */
82 RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing); lastsig = sig;}
85 static void unlockit(int n, void *p)
87 static void unlockit(void)
89 /* must-do actions for exit (but we can't count on being able to do malloc) */
94 int main (int argc, char **argv)
97 int parsestatus, implicitmode = FALSE;
100 netrc_entry *netrc_list;
101 char *netrc_file, tmpbuf[BUFSIZ];
104 envquery(argc, argv);
106 #define IDFILE_NAME ".fetchids"
107 idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
108 strcpy(idfile, home);
110 strcat(idfile, IDFILE_NAME);
114 if ((parsestatus = parsecmdline(argc,argv,&cmd_opts)) < 0)
117 /* this hint to stdio should help messages come out in the right order */
118 setvbuf(stdout, NULL, _IOLBF, POPBUFSIZE);
122 printf("This is fetchmail release %s", RELEASE_ID);
125 #endif /* POP2_ENABLE */
128 #endif /* POP3_ENABLE */
131 #endif /* IMAP_ENABLE */
134 #endif /* RPA_ENABLE */
137 #endif /* ETRN_ENABLE */
140 /* this is an attempt to help remote debugging */
144 /* avoid parsing the config file if all we're doing is killing a daemon */
146 implicitmode = load_params(argc, argv, optind);
148 /* set up to do lock protocol */
150 sprintf(tmpbuf, "%s/fetchmail.pid", PID_DIR);
152 strcpy(tmpbuf, home);
153 strcat(tmpbuf, "/.fetchmail");
156 /* perhaps we just want to check options? */
158 printf("Taking options from command line");
159 if (access(rcfile, 0))
162 printf(" and %s\n", rcfile);
164 printf("Poll interval is %d seconds\n", poll_interval);
165 if (outlevel == O_VERBOSE)
166 printf("Lockfile at %s\n", tmpbuf);
168 printf("Logfile is %s\n", logfile);
169 #if defined(HAVE_SYSLOG)
171 printf("Progress messages will be logged via syslog\n");
174 printf("Fetchmail will masquerade and will not generate Received\n");
175 for (ctl = querylist; ctl; ctl = ctl->next) {
176 if (ctl->active && !(implicitmode && ctl->server.skip))
179 if (querylist == NULL)
180 (void) fprintf(stderr,
181 "No mailservers set up -- perhaps %s is missing?\n", rcfile);
185 /* check for another fetchmail running concurrently */
187 if ((lockfile = (char *) malloc(strlen(tmpbuf) + 1)) == NULL)
189 fprintf(stderr,"fetchmail: cannot allocate memory for lock name.\n");
193 (void) strcpy(lockfile, tmpbuf);
194 if ((lockfp = fopen(lockfile, "r")) != NULL )
196 bkgd = (fscanf(lockfp,"%d %d", &pid, &st) == 2);
198 if (kill(pid, 0) == -1) {
199 fprintf(stderr,"fetchmail: removing stale lockfile\n");
207 /* if no mail servers listed and nothing in background, we're done */
208 if (!quitmode && pid == -1 && querylist == NULL) {
209 (void)fputs("fetchmail: no mailservers have been specified.\n",stderr);
213 /* perhaps user asked us to kill the other fetchmail */
218 fprintf(stderr,"fetchmail: no other fetchmail is running\n");
221 else if (kill(pid, SIGTERM) < 0)
223 fprintf(stderr,"fetchmail: error killing %s fetchmail at %d.\n",
224 bkgd ? "background" : "foreground", pid);
229 fprintf(stderr,"fetchmail: %s fetchmail at %d killed.\n",
230 bkgd ? "background" : "foreground", pid);
236 /* another fetchmail is running -- wake it up or die */
242 "fetchmail: can't check mail while another fetchmail to same host is running.\n");
245 else if (!implicitmode)
248 "fetchmail: can't poll specified hosts with another fetchmail running at %d.\n",
255 "fetchmail: another foreground fetchmail is running at %d.\n",
262 "fetchmail: can't accept options while a background fetchmail is running.\n");
265 else if (kill(pid, SIGUSR1) == 0)
268 "fetchmail: background fetchmail at %d awakened.\n",
275 * Should never happen -- possible only if a background fetchmail
276 * croaks after the first kill probe above but before the
277 * SIGUSR1/SIGHUP transmission.
280 "fetchmail: elder sibling at %d died mysteriously.\n",
282 return(PS_UNDEFINED);
286 /* parse the ~/.netrc file (if present) for future password lookups. */
287 netrc_file = (char *) xmalloc (strlen (home) + 8);
288 strcpy (netrc_file, home);
289 strcat (netrc_file, "/.netrc");
290 netrc_list = parse_netrc(netrc_file);
292 /* pick up interactively any passwords we need but don't have */
293 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 || ctl->server.protocol == P_IMAP_K4)
297 /* Server won't care what the password is, but there
298 must be some non-null string here. */
299 ctl->password = ctl->remotename;
302 /* look up the host and account in the .netrc file. */
303 netrc_entry *p = search_netrc(netrc_list,ctl->server.pollname);
304 while (p && strcmp(p->account, ctl->remotename))
305 p = search_netrc(p->next, ctl->remotename);
307 /* if we find a matching entry with a password, use it */
308 if (p && p->password)
309 ctl->password = xstrdup(p->password);
312 if (ctl->server.protocol != P_ETRN && ctl->server.protocol != P_IMAP_K4 && !ctl->password)
314 (void) sprintf(tmpbuf, "Enter password for %s@%s: ",
315 ctl->remotename, ctl->server.pollname);
316 ctl->password = xstrdup((char *)getpassword(tmpbuf));
321 * Maybe time to go to demon mode...
323 #if defined(HAVE_SYSLOG)
325 openlog(program_name, LOG_PID, LOG_MAIL);
331 daemonize(logfile, termhook);
332 error( 0, 0, "starting fetchmail %s daemon ", RELEASE_ID);
335 * We'll set up a handler for these when we're sleeping,
336 * but ignore them otherwise so as not to interrupt a poll.
338 signal(SIGUSR1, SIG_IGN);
339 if (poll_interval && !getuid())
340 signal(SIGHUP, SIG_IGN);
343 /* beyond here we don't want more than one fetchmail running per user */
345 signal(SIGABRT, termhook);
346 signal(SIGINT, termhook);
347 signal(SIGTERM, termhook);
348 signal(SIGALRM, termhook);
349 signal(SIGPIPE, termhook);
350 signal(SIGQUIT, termhook);
352 /* here's the exclusion lock */
353 if ((lockfp = fopen(lockfile,"w")) != NULL) {
354 fprintf(lockfp,"%d",getpid());
356 fprintf(lockfp," %d", poll_interval);
363 on_exit(unlockit, (char *)NULL);
368 * Query all hosts. If there's only one, the error return will
369 * reflect the status of that transaction.
372 #ifdef HAVE_RES_SEARCH
373 sethostent(TRUE); /* use TCP/IP for mailserver queries */
374 #endif /* HAVE_RES_SEARCH */
377 for (ctl = querylist; ctl; ctl = ctl->next)
379 if (ctl->active && !(implicitmode && ctl->server.skip))
381 /* check skip interval first so that it counts all polls */
382 if (poll_interval && ctl->server.interval)
384 if (ctl->server.poll_count++ % ctl->server.interval)
386 if (outlevel == O_VERBOSE)
388 "fetchmail: interval not reached, not querying %s\n",
389 ctl->server.pollname);
395 /* interface_approve() does its own error logging */
396 if (!interface_approve(&ctl->server))
400 #ifdef HAVE_GETHOSTBYNAME
402 * This functions partly as a probe to make sure our
403 * nameserver is still up. The multidrop case
404 * (especially) needs it.
406 if (ctl->server.preauthenticate==A_KERBEROS_V4 || MULTIDROP(ctl))
408 struct hostent *namerec;
410 /* compute the canonical name of the host */
412 namerec = gethostbyname(ctl->server.queryname);
413 if (namerec == (struct hostent *)NULL)
416 "skipping %s poll, ",
417 ctl->server.pollname);
420 if (errno == ENETUNREACH)
421 break; /* go to sleep */
423 #ifdef HAVE_HERROR /* NEXTSTEP doesn't */
426 #endif /* HAVE_HERROR */
431 free(ctl->server.truename);
432 ctl->server.truename=xstrdup((char *)namerec->h_name);
435 #endif /* HAVE_GETHOSTBYNAME */
437 querystatus = query_host(ctl);
439 if (querystatus == PS_SUCCESS) {
443 update_str_lists(ctl);
444 #endif /* POP3_ENABLE */
447 if (ctl->server.monitor)
449 /* Allow some time for the link to quiesce. One
450 * second is usually sufficient, three is safe.
451 * Note: this delay is important - don't remove!
454 interface_note_activity(&ctl->server);
460 #ifdef HAVE_RES_SEARCH
461 endhostent(); /* release TCP/IP connection to nameserver */
462 #endif /* HAVE_RES_SEARCH */
465 * Close all SMTP delivery sockets. For optimum performance
466 * we'd like to hold them open til end of run, but (1) this
467 * loses if our poll interval is longer than the MTA's inactivity
468 * timeout, and (2) some MTAs (like smail) don't deliver after
469 * each message, but rather queue up mail and wait to actually
470 * deliver it until the input socket is closed.
472 for (ctl = querylist; ctl; ctl = ctl->next)
473 if (ctl->smtp_socket != -1)
475 SMTP_quit(ctl->smtp_socket);
476 close(ctl->smtp_socket);
477 ctl->smtp_socket = -1;
481 * OK, we've polled. Now sleep.
485 if (outlevel == O_VERBOSE)
490 fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now));
494 * With this simple hack, we make it possible for a foreground
495 * fetchmail to wake up one in daemon mode. What we want is the
496 * side effect of interrupting any sleep that may be going on,
497 * forcing fetchmail to re-poll its hosts. The second line is
498 * for people who think all system daemons wake up on SIGHUP.
500 signal(SIGUSR1, donothing);
502 signal(SIGHUP, donothing);
505 * We can't use sleep(3) here because we need an alarm(3)
506 * equivalent in order to implement server nonresponse timeout.
507 * We'll just assume setitimer(2) is available since fetchmail
508 * has to have a BSDoid socket layer to work at all.
511 struct itimerval ntimeout;
513 ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_usec = 0;
514 ntimeout.it_value.tv_sec = poll_interval;
515 ntimeout.it_value.tv_usec = 0;
517 setitimer(ITIMER_REAL,&ntimeout,NULL);
518 signal(SIGALRM, donothing);
520 signal(SIGALRM, SIG_IGN);
521 if (lastsig == SIGUSR1
522 || ((poll_interval && !getuid()) && lastsig == SIGHUP))
524 #ifdef SYS_SIGLIST_DECLARED
525 error(0, 0, "awakened by %s", sys_siglist[lastsig]);
527 error(0, 0, "awakened by signal %d", lastsig);
532 /* now lock out interrupts again */
533 signal(SIGUSR1, SIG_IGN);
535 signal(SIGHUP, SIG_IGN);
537 if (outlevel == O_VERBOSE)
542 fprintf(stderr, "fetchmail: awakened at %s", ctime(&now));
548 if (outlevel == O_VERBOSE)
549 fprintf(stderr,"fetchmail: normal termination, status %d\n",
550 successes ? PS_SUCCESS : querystatus);
553 exit(successes ? PS_SUCCESS : querystatus);
556 static int load_params(int argc, char **argv, int optind)
558 int implicitmode, st;
560 struct query def_opts, *ctl;
562 memset(&def_opts, '\0', sizeof(struct query));
563 def_opts.smtp_socket = -1;
565 def_opts.server.protocol = P_AUTO;
566 def_opts.server.timeout = CLIENT_TIMEOUT;
567 def_opts.remotename = user;
568 save_str(&def_opts.smtphunt, TRUE, fetchmailhost);
569 save_str(&def_opts.smtphunt, FALSE, "localhost");
570 def_opts.expunge = 1;
572 /* this builds the host list */
573 if (prc_parse_file(rcfile, !versioninfo) != 0)
576 if ((implicitmode = (optind >= argc)))
578 for (ctl = querylist; ctl; ctl = ctl->next)
582 for (; optind < argc; optind++)
585 * If hostname corresponds to a host known from the rc file,
586 * simply declare it active. Otherwise synthesize a host
587 * record from command line and defaults
589 for (ctl = querylist; ctl; ctl = ctl->next)
590 if (!strcmp(ctl->server.pollname, argv[optind])
591 || str_in_list(&ctl->server.akalist, argv[optind]))
594 ctl = hostalloc(&cmd_opts);
595 ctl->server.pollname = xstrdup(argv[optind]);
601 /* if there's a defaults record, merge it and lose it */
602 if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
604 for (ctl = querylist->next; ctl; ctl = ctl->next)
605 optmerge(ctl, querylist);
606 querylist = querylist->next;
609 /* don't allow a defaults record after the first */
610 for (ctl = querylist; ctl; ctl = ctl->next)
611 if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
614 /* merge in wired defaults, do sanity checks and prepare internal fields */
615 for (ctl = querylist; ctl; ctl = ctl->next)
617 if (ctl->active && !(implicitmode && ctl->server.skip))
619 /* merge in defaults */
620 optmerge(ctl, &def_opts);
622 /* keep lusers from shooting themselves in the foot :-) */
623 if (poll_interval && ctl->limit)
625 fprintf(stderr,"fetchmail: you'd never see large messages!\n");
629 /* make sure delivery will default to a real local user */
630 if ((pw = getpwnam(user)) == (struct passwd *)NULL)
633 "fetchmail: can't set up default delivery to %s\n", user);
634 exit(PS_SYNTAX); /* has to be from bad rc file */
638 ctl->uid = pw->pw_uid; /* for local delivery via MDA */
639 if (!ctl->localnames) /* for local delivery via SMTP */
640 save_str_pair(&ctl->localnames, user, NULL);
643 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
644 /* can't handle multidrop mailboxes unless we can do DNS lookups */
645 if (ctl->localnames && ctl->localnames->next)
647 fputs("fetchmail: can't handle multidrop mailboxes without DNS\n",
651 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
653 /* this code enables flags to be turned off */
654 #define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
656 else if (flag == FLAG_FALSE)\
660 DEFAULT(ctl->keep, FALSE);
661 DEFAULT(ctl->fetchall, FALSE);
662 DEFAULT(ctl->flush, FALSE);
663 DEFAULT(ctl->rewrite, TRUE);
664 DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
665 DEFAULT(ctl->forcecr, FALSE);
666 DEFAULT(ctl->pass8bits, FALSE);
667 DEFAULT(ctl->dropstatus, FALSE);
668 DEFAULT(ctl->server.dns, TRUE);
669 DEFAULT(ctl->server.uidl, FALSE);
674 * Compute the true name of the mailserver host.
675 * There are two clashing cases here:
677 * (1) The poll name is a label, possibly on one of several
678 * poll configurations for the same host. In this case
679 * the `via' option will be present and give the true name.
681 * (2) The poll name is the true one, the via name is
682 * localhost. This is going to be typical for ssh-using
685 * We're going to assume the via name is true unless it's
688 * Each poll cycle, if we've got DNS, we'll try to canonicalize
689 * the name. This will function as a probe to ensure the
690 * host's nameserver is up.
692 if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
693 ctl->server.queryname = xstrdup(ctl->server.via);
695 ctl->server.queryname = xstrdup(ctl->server.pollname);
696 ctl->server.truename = xstrdup(ctl->server.queryname);
698 /* if no folders were specified, set up the null one as default */
700 save_str(&ctl->mailboxes, -1, (char *)NULL);
702 /* maybe user overrode timeout on command line? */
703 if (ctl->server.timeout == -1)
704 ctl->server.timeout = CLIENT_TIMEOUT;
707 if (ctl->server.port < 0)
709 (void) fprintf(stderr,
710 "%s configuration invalid, port number cannot be negative",
711 ctl->server.pollname);
714 if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
716 (void) fprintf(stderr,
717 "%s configuration invalid, RPOP requires a privileged port",
718 ctl->server.pollname);
724 /* initialize UID handling */
725 if (!versioninfo && (st = prc_filecheck(idfile)) != 0)
729 initialize_saved_lists(querylist, idfile);
730 #endif /* POP3_ENABLE */
732 /* if cmd_logfile was explicitly set, use it to override logfile */
734 logfile = cmd_logfile;
736 /* likewise for poll_interval */
738 poll_interval = cmd_daemon;
740 /* check and daemon options are not compatible */
741 if (check_only && poll_interval)
744 return(implicitmode);
747 void termhook(int sig)
748 /* to be executed on normal or signal-induced termination */
753 * Sending SMTP QUIT on signal is theoretically nice, but led to a
754 * subtle bug. If fetchmail was terminated by signal while it was
755 * shipping message text, it would hang forever waiting for a
756 * command acknowledge. In theory we could enable the QUIT
757 * only outside of the message send. In practice, we don't
758 * care. All mailservers hang up on a dropped TCP/IP connection
763 error(0, 0, "terminated with signal %d", sig);
765 /* terminate all SMTP connections cleanly */
766 for (ctl = querylist; ctl; ctl = ctl->next)
767 if (ctl->smtp_socket != -1)
768 SMTP_quit(ctl->smtp_socket);
772 write_saved_lists(querylist, idfile);
773 #endif /* POP3_ENABLE */
776 * Craig Metz, the RFC1938 one-time-password guy, points out:
777 * "Remember that most kernels don't zero pages before handing them to the
778 * next process and many kernels share pages between user and kernel space.
779 * You'd be very surprised what you can find from a short program to do a
780 * malloc() and then dump the contents of the pages you got. By zeroing
781 * the secrets at end of run (earlier if you can), you make sure the next
782 * guy can't get the password/pass phrase."
784 * Right you are, Craig!
786 for (ctl = querylist; ctl; ctl = ctl->next)
788 memset(ctl->password, '\0', strlen(ctl->password));
790 #if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
794 exit(successes ? PS_SUCCESS : querystatus);
798 * Sequence of protocols to try when autoprobing, most capable to least.
800 static const int autoprobe[] =
804 #endif /* IMAP_ENABLE */
807 #endif /* POP3_ENABLE */
810 #endif /* POP2_ENABLE */
813 static int query_host(struct query *ctl)
814 /* perform fetch transaction with single host */
818 if (outlevel == O_VERBOSE)
823 fprintf(stderr, "fetchmail: %s querying %s (protocol %s) at %s",
825 ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now));
827 switch (ctl->server.protocol) {
829 for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
831 ctl->server.protocol = autoprobe[i];
832 if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY || st == PS_SMTP)
835 ctl->server.protocol = P_AUTO;
842 fprintf(stderr, "POP2 support is not configured.\n");
844 #endif /* POP2_ENABLE */
852 fprintf(stderr, "POP3 support is not configured.\n");
854 #endif /* POP3_ENABLE */
861 fprintf(stderr, "IMAP support is not configured.\n");
863 #endif /* IMAP_ENABLE */
867 fprintf(stderr, "ETRN support is not configured.\n");
870 #ifdef HAVE_GETHOSTBYNAME
873 fprintf(stderr, "Cannot support ETRN without gethostbyname(2).\n");
875 #endif /* HAVE_GETHOSTBYNAME */
876 #endif /* ETRN_ENABLE */
878 error(0, 0, "unsupported protocol selected.");
883 void dump_params (struct query *ctl)
884 /* display query parameters in English */
886 printf("Options for retrieving from %s@%s:\n",
887 ctl->remotename, visbuf(ctl->server.pollname));
890 printf(" Mail will be retrieved via %s\n", ctl->server.via);
892 if (ctl->server.interval)
893 printf(" Poll of this server will occur every %d intervals.\n",
894 ctl->server.interval);
895 if (ctl->server.truename)
896 printf(" True name of server is %s.\n", ctl->server.truename);
897 if (ctl->server.skip || outlevel == O_VERBOSE)
898 printf(" This host will%s be queried when no host is specified.\n",
899 ctl->server.skip ? " not" : "");
901 printf(" Password will be prompted for.\n");
902 else if (outlevel == O_VERBOSE)
903 if (ctl->server.protocol == P_APOP)
904 printf(" APOP secret = '%s'.\n", visbuf(ctl->password));
905 else if (ctl->server.protocol == P_RPOP)
906 printf(" RPOP id = '%s'.\n", visbuf(ctl->password));
908 printf(" Password = '%s'.\n", visbuf(ctl->password));
909 if (ctl->server.protocol == P_POP3
910 && ctl->server.port == KPOP_PORT
911 && ctl->server.preauthenticate == A_KERBEROS_V4)
912 printf(" Protocol is KPOP");
914 printf(" Protocol is %s", showproto(ctl->server.protocol));
915 if (ctl->server.port)
916 printf(" (using port %d)", ctl->server.port);
917 else if (outlevel == O_VERBOSE)
918 printf(" (using default port)");
919 if (ctl->server.uidl)
920 printf(" (forcing UIDL use)");
923 if (ctl->server.preauthenticate == A_KERBEROS_V4)
924 printf(" Kerberos V4 preauthentication enabled.\n");
925 if (ctl->server.timeout > 0)
926 printf(" Server nonresponse timeout is %d seconds", ctl->server.timeout);
927 if (ctl->server.timeout == CLIENT_TIMEOUT)
928 printf(" (default).\n");
932 if (!ctl->mailboxes->id)
933 printf(" Default mailbox selected.\n");
938 printf(" Selected mailboxes are:");
939 for (idp = ctl->mailboxes; idp; idp = idp->next)
940 printf(" %s", idp->id);
943 printf(" %s messages will be retrieved (--all %s).\n",
944 ctl->fetchall ? "All" : "Only new",
945 ctl->fetchall ? "on" : "off");
946 printf(" Fetched messages will%s be kept on the server (--keep %s).\n",
947 ctl->keep ? "" : " not",
948 ctl->keep ? "on" : "off");
949 printf(" Old messages will%s be flushed before message retrieval (--flush %s).\n",
950 ctl->flush ? "" : " not",
951 ctl->flush ? "on" : "off");
952 printf(" Rewrite of server-local addresses is %sabled (--norewrite %s).\n",
953 ctl->rewrite ? "en" : "dis",
954 ctl->rewrite ? "off" : "on");
955 printf(" Carriage-return stripping is %sabled (stripcr %s).\n",
956 ctl->stripcr ? "en" : "dis",
957 ctl->stripcr ? "on" : "off");
958 printf(" Carriage-return forcing is %sabled (forcecr %s).\n",
959 ctl->forcecr ? "en" : "dis",
960 ctl->forcecr ? "on" : "off");
961 printf(" Interpretation of Content-Transfer-Encoding is %sabled (pass8bits %s).\n",
962 ctl->pass8bits ? "dis" : "en",
963 ctl->pass8bits ? "on" : "off");
964 printf(" Nonempty Status lines will be %s (dropstatus %s)\n",
965 ctl->dropstatus ? "discarded" : "kept",
966 ctl->dropstatus ? "on" : "off");
968 printf(" Message size limit is %d bytes (--limit %d).\n",
969 ctl->limit, ctl->limit);
970 else if (outlevel == O_VERBOSE)
971 printf(" No message size limit (--limit 0).\n");
972 if (ctl->fetchlimit > 0)
973 printf(" Received-message limit is %d (--fetchlimit %d).\n",
974 ctl->fetchlimit, ctl->fetchlimit);
975 else if (outlevel == O_VERBOSE)
976 printf(" No received-message limit (--fetchlimit 0).\n");
977 if (ctl->batchlimit > 0)
978 printf(" SMTP message batch limit is %d.\n", ctl->batchlimit);
979 else if (outlevel == O_VERBOSE)
980 printf(" No SMTP message batch limit (--batchlimit 0).\n");
981 if (ctl->server.protocol == P_IMAP)
982 if (ctl->expunge > 0)
983 printf(" Deletion interval between expunges is %d (--expunge %d).\n", ctl->expunge, ctl->expunge);
984 else if (outlevel == O_VERBOSE)
985 printf(" No expunges (--expunge 0).\n");
987 printf(" Messages will be delivered with '%s.'\n", visbuf(ctl->mda));
992 printf(" Messages will be SMTP-forwarded to:");
993 for (idp = ctl->smtphunt; idp; idp = idp->next)
994 printf(" %s", idp->id);
998 printf(" Server connection will be brought up with '%s.'\n",
999 visbuf(ctl->preconnect));
1000 else if (outlevel == O_VERBOSE)
1001 printf(" No pre-connection command.\n");
1002 if (ctl->postconnect)
1003 printf(" Server connection will be taken down with '%s.'\n",
1004 visbuf(ctl->postconnect));
1005 else if (outlevel == O_VERBOSE)
1006 printf(" No post-connection command.\n");
1007 if (!ctl->localnames)
1008 printf(" No localnames declared for this host.\n");
1014 for (idp = ctl->localnames; idp; idp = idp->next)
1017 if (count > 1 || ctl->wildcard)
1018 printf(" Multi-drop mode: ");
1020 printf(" Single-drop mode: ");
1022 printf("%d local name(s) recognized.\n", count);
1023 if (outlevel == O_VERBOSE)
1025 for (idp = ctl->localnames; idp; idp = idp->next)
1027 printf("\t%s -> %s\n", idp->id, idp->val.id2);
1029 printf("\t%s\n", idp->id);
1031 fputs("*\n", stdout);
1034 if (count > 1 || ctl->wildcard)
1036 printf(" DNS lookup for multidrop addresses is %sabled.\n",
1037 ctl->server.dns ? "en" : "dis");
1039 if (ctl->server.envelope == STRING_DISABLED)
1040 printf(" Envelope-address routing is disabled\n");
1042 printf(" Envelope header is assumed to be: %s\n",
1043 ctl->server.envelope ? ctl->server.envelope:"Received");
1045 if (ctl->server.akalist)
1049 printf(" Predeclared mailserver aliases:");
1050 for (idp = ctl->server.akalist; idp; idp = idp->next)
1051 printf(" %s", idp->id);
1054 if (ctl->server.localdomains)
1058 printf(" Local domains:");
1059 for (idp = ctl->server.localdomains; idp; idp = idp->next)
1060 printf(" %s", idp->id);
1066 if (ctl->server.interface)
1067 printf(" Connection must be through interface %s.\n", ctl->server.interface);
1068 else if (outlevel == O_VERBOSE)
1069 printf(" No interface requirement specified.\n");
1070 if (ctl->server.monitor)
1071 printf(" Polling loop will monitor %s.\n", ctl->server.monitor);
1072 else if (outlevel == O_VERBOSE)
1073 printf(" No monitor interface specified.\n");
1076 if (ctl->server.protocol > P_POP2)
1078 printf(" No UIDs saved from this host.\n");
1084 for (idp = ctl->oldsaved; idp; idp = idp->next)
1087 printf(" %d UIDs saved.\n", count);
1088 if (outlevel == O_VERBOSE)
1089 for (idp = ctl->oldsaved; idp; idp = idp->next)
1090 fprintf(stderr, "\t%s\n", idp->id);
1094 /* fetchmail.c ends here */