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"
47 #define ENETUNREACH 128 /* Interactive doesn't know this */
48 #endif /* ENETUNREACH */
50 /* prototypes for internal functions */
51 static int load_params(int, char **, int);
52 static void dump_params (struct query *);
53 static int query_host(struct query *);
55 /* controls the detail level of status/progress messages written to stderr */
56 int outlevel; /* see the O_.* constants above */
58 /* daemon mode control */
59 flag nodetach; /* if TRUE, don't detach daemon process */
60 flag quitmode; /* if --quit was set */
61 flag check_only; /* if --probe was set */
62 char *cmd_logfile; /* if --logfile was set */
63 int cmd_daemon; /* if --daemon was set */
65 /* miscellaneous global controls */
66 char *idfile; /* UID list file */
67 flag versioninfo; /* emit only version info */
68 char *user; /* the name of the invoking user */
70 char *fetchmailhost; /* the name of the host running fetchmail */
71 char *program_name; /* the name to prefix error messages with */
73 static char *lockfile; /* name of lockfile */
74 static int querystatus; /* status of query */
75 static int successes; /* count number of successful polls */
76 static int lastsig; /* last signal received */
78 static void termhook(); /* forward declaration of exit hook */
80 RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing); lastsig = sig;}
83 static void unlockit(int n, void *p)
85 static void unlockit(void)
87 /* must-do actions for exit (but we can't count on being able to do malloc) */
92 int main (int argc, char **argv)
95 int parsestatus, implicitmode = FALSE;
98 netrc_entry *netrc_list;
99 char *netrc_file, tmpbuf[BUFSIZ];
102 envquery(argc, argv);
104 #define IDFILE_NAME ".fetchids"
105 idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
106 strcpy(idfile, home);
108 strcat(idfile, IDFILE_NAME);
112 if ((parsestatus = parsecmdline(argc,argv,&cmd_opts)) < 0)
115 /* this hint to stdio should help messages come out in the right order */
116 setvbuf(stdout, NULL, _IOLBF, POPBUFSIZE);
120 printf("This is fetchmail release %s", RELEASE_ID);
123 #endif /* POP2_ENABLE */
126 #endif /* POP3_ENABLE */
129 #endif /* IMAP_ENABLE */
132 #endif /* RPA_ENABLE */
135 #endif /* ETRN_ENABLE */
138 /* this is an attempt to help remote debugging */
142 /* avoid parsing the config file if all we're doing is killing a daemon */
143 if (!(quitmode && argc == 2))
144 implicitmode = load_params(argc, argv, optind);
146 /* set up to do lock protocol */
148 sprintf(tmpbuf, "%s/fetchmail.pid", PID_DIR);
150 strcpy(tmpbuf, home);
151 strcat(tmpbuf, "/.fetchmail");
154 /* perhaps we just want to check options? */
156 printf("Taking options from command line");
157 if (access(rcfile, 0))
160 printf(" and %s\n", rcfile);
162 printf("Poll interval is %d seconds\n", poll_interval);
163 if (outlevel == O_VERBOSE)
164 printf("Lockfile at %s\n", tmpbuf);
166 printf("Logfile is %s\n", logfile);
167 #if defined(HAVE_SYSLOG)
168 if (errors_to_syslog)
169 printf("Progress messages will be logged via syslog\n");
172 printf("Fetchmail will masquerade and will not generate Received\n");
173 for (ctl = querylist; ctl; ctl = ctl->next) {
174 if (ctl->active && !(implicitmode && ctl->server.skip))
177 if (querylist == NULL)
178 (void) fprintf(stderr,
179 "No mailservers set up -- perhaps %s is missing?\n", rcfile);
183 /* check for another fetchmail running concurrently */
185 if ((lockfile = (char *) malloc(strlen(tmpbuf) + 1)) == NULL)
187 fprintf(stderr,"fetchmail: cannot allocate memory for lock name.\n");
191 (void) strcpy(lockfile, tmpbuf);
192 if ((lockfp = fopen(lockfile, "r")) != NULL )
194 bkgd = (fscanf(lockfp,"%d %d", &pid, &st) == 2);
196 if (kill(pid, 0) == -1) {
197 fprintf(stderr,"fetchmail: removing stale lockfile\n");
205 /* if no mail servers listed and nothing in background, we're done */
206 if (!(quitmode && argc == 2) && pid == -1 && querylist == NULL) {
207 (void)fputs("fetchmail: no mailservers have been specified.\n",stderr);
211 /* perhaps user asked us to kill the other fetchmail */
216 fprintf(stderr,"fetchmail: no other fetchmail is running\n");
220 else if (kill(pid, SIGTERM) < 0)
222 fprintf(stderr,"fetchmail: error killing %s fetchmail at %d; bailing out.\n",
223 bkgd ? "background" : "foreground", pid);
228 fprintf(stderr,"fetchmail: %s fetchmail at %d killed.\n",
229 bkgd ? "background" : "foreground", pid);
238 /* another fetchmail is running -- wake it up or die */
244 "fetchmail: can't check mail while another fetchmail to same host is running.\n");
247 else if (!implicitmode)
250 "fetchmail: can't poll specified hosts with another fetchmail running at %d.\n",
257 "fetchmail: another foreground fetchmail is running at %d.\n",
264 "fetchmail: can't accept options while a background fetchmail is running.\n");
267 else if (kill(pid, SIGUSR1) == 0)
270 "fetchmail: background fetchmail at %d awakened.\n",
277 * Should never happen -- possible only if a background fetchmail
278 * croaks after the first kill probe above but before the
279 * SIGUSR1/SIGHUP transmission.
282 "fetchmail: elder sibling at %d died mysteriously.\n",
284 return(PS_UNDEFINED);
288 /* parse the ~/.netrc file (if present) for future password lookups. */
289 netrc_file = (char *) xmalloc (strlen (home) + 8);
290 strcpy (netrc_file, home);
291 strcat (netrc_file, "/.netrc");
292 netrc_list = parse_netrc(netrc_file);
294 /* pick up interactively any passwords we need but don't have */
295 for (ctl = querylist; ctl; ctl = ctl->next)
296 if (ctl->active && !(implicitmode && ctl->server.skip)&&!ctl->password)
298 if (ctl->server.preauthenticate == A_KERBEROS_V4 || ctl->server.protocol == P_IMAP_K4)
299 /* Server won't care what the password is, but there
300 must be some non-null string here. */
301 ctl->password = ctl->remotename;
304 /* look up the host and account in the .netrc file. */
305 netrc_entry *p = search_netrc(netrc_list,ctl->server.pollname);
306 while (p && strcmp(p->account, ctl->remotename))
307 p = search_netrc(p->next, ctl->remotename);
309 /* if we find a matching entry with a password, use it */
310 if (p && p->password)
311 ctl->password = xstrdup(p->password);
314 if (ctl->server.protocol != P_ETRN && ctl->server.protocol != P_IMAP_K4 && !ctl->password)
316 (void) sprintf(tmpbuf, "Enter password for %s@%s: ",
317 ctl->remotename, ctl->server.pollname);
318 ctl->password = xstrdup((char *)getpassword(tmpbuf));
323 * Maybe time to go to demon mode...
325 #if defined(HAVE_SYSLOG)
326 if (errors_to_syslog)
328 openlog(program_name, LOG_PID, LOG_MAIL);
333 error_init(poll_interval == 0 && !logfile);
338 daemonize(logfile, termhook);
339 error( 0, 0, "starting fetchmail %s daemon ", RELEASE_ID);
342 * We'll set up a handler for these when we're sleeping,
343 * but ignore them otherwise so as not to interrupt a poll.
345 signal(SIGUSR1, SIG_IGN);
346 if (poll_interval && !getuid())
347 signal(SIGHUP, SIG_IGN);
350 /* beyond here we don't want more than one fetchmail running per user */
352 signal(SIGABRT, termhook);
353 signal(SIGINT, termhook);
354 signal(SIGTERM, termhook);
355 signal(SIGALRM, termhook);
356 signal(SIGPIPE, termhook);
357 signal(SIGQUIT, termhook);
359 /* here's the exclusion lock */
360 if ((lockfp = fopen(lockfile,"w")) != NULL) {
361 fprintf(lockfp,"%d",getpid());
363 fprintf(lockfp," %d", poll_interval);
370 on_exit(unlockit, (char *)NULL);
375 * Query all hosts. If there's only one, the error return will
376 * reflect the status of that transaction.
379 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
381 * This was an efficiency hack that backfired. The theory
382 * was that using TCP/IP for DNS queries would get us better
383 * reliability and shave off some per-UDP-packet costs.
384 * Unfortunately it interacted badly with diald, which effectively
385 * filters out DNS queries over TCP/IP for reasons having to do
386 * with some obscure kernel problem involving bootstrapping of
387 * dynamically-addressed links. I don't understand this mess
388 * and don't want to, so it's "See ya!" to this hack.
390 sethostent(TRUE); /* use TCP/IP for mailserver queries */
391 #endif /* HAVE_RES_SEARCH */
394 for (ctl = querylist; ctl; ctl = ctl->next)
396 if (ctl->active && !(implicitmode && ctl->server.skip))
398 /* check skip interval first so that it counts all polls */
399 if (poll_interval && ctl->server.interval)
401 if (ctl->server.poll_count++ % ctl->server.interval)
403 if (outlevel == O_VERBOSE)
405 "fetchmail: interval not reached, not querying %s\n",
406 ctl->server.pollname);
412 /* interface_approve() does its own error logging */
413 if (!interface_approve(&ctl->server))
417 #ifdef HAVE_GETHOSTBYNAME
419 * This functions partly as a probe to make sure our
420 * nameserver is still up. The multidrop case
421 * (especially) needs it.
423 if (ctl->server.preauthenticate==A_KERBEROS_V4 || MULTIDROP(ctl))
425 struct hostent *namerec;
427 /* compute the canonical name of the host */
429 namerec = gethostbyname(ctl->server.queryname);
430 if (namerec == (struct hostent *)NULL)
433 "skipping %s poll, ",
434 ctl->server.pollname);
437 if (errno == ENETUNREACH)
438 break; /* go to sleep */
440 #ifdef HAVE_HERROR /* NEXTSTEP doesn't */
443 #endif /* HAVE_HERROR */
448 free(ctl->server.truename);
449 ctl->server.truename=xstrdup((char *)namerec->h_name);
452 #endif /* HAVE_GETHOSTBYNAME */
454 querystatus = query_host(ctl);
456 if (querystatus == PS_SUCCESS) {
460 update_str_lists(ctl);
461 #endif /* POP3_ENABLE */
464 if (ctl->server.monitor)
466 /* Allow some time for the link to quiesce. One
467 * second is usually sufficient, three is safe.
468 * Note: this delay is important - don't remove!
471 interface_note_activity(&ctl->server);
477 #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS)
478 endhostent(); /* release TCP/IP connection to nameserver */
479 #endif /* HAVE_RES_SEARCH */
482 * Close all SMTP delivery sockets. For optimum performance
483 * we'd like to hold them open til end of run, but (1) this
484 * loses if our poll interval is longer than the MTA's inactivity
485 * timeout, and (2) some MTAs (like smail) don't deliver after
486 * each message, but rather queue up mail and wait to actually
487 * deliver it until the input socket is closed.
489 for (ctl = querylist; ctl; ctl = ctl->next)
490 if (ctl->smtp_socket != -1)
492 SMTP_quit(ctl->smtp_socket);
493 close(ctl->smtp_socket);
494 ctl->smtp_socket = -1;
498 * OK, we've polled. Now sleep.
502 if (outlevel == O_VERBOSE)
507 fprintf(stderr, "fetchmail: sleeping at %s", ctime(&now));
511 * With this simple hack, we make it possible for a foreground
512 * fetchmail to wake up one in daemon mode. What we want is the
513 * side effect of interrupting any sleep that may be going on,
514 * forcing fetchmail to re-poll its hosts. The second line is
515 * for people who think all system daemons wake up on SIGHUP.
517 signal(SIGUSR1, donothing);
519 signal(SIGHUP, donothing);
522 * We can't use sleep(3) here because we need an alarm(3)
523 * equivalent in order to implement server nonresponse timeout.
524 * We'll just assume setitimer(2) is available since fetchmail
525 * has to have a BSDoid socket layer to work at all.
528 struct itimerval ntimeout;
530 ntimeout.it_interval.tv_sec = ntimeout.it_interval.tv_usec = 0;
531 ntimeout.it_value.tv_sec = poll_interval;
532 ntimeout.it_value.tv_usec = 0;
534 setitimer(ITIMER_REAL,&ntimeout,NULL);
535 signal(SIGALRM, donothing);
537 signal(SIGALRM, SIG_IGN);
538 if (lastsig == SIGUSR1
539 || ((poll_interval && !getuid()) && lastsig == SIGHUP))
541 #ifdef SYS_SIGLIST_DECLARED
542 error(0, 0, "awakened by %s", sys_siglist[lastsig]);
544 error(0, 0, "awakened by signal %d", lastsig);
549 /* now lock out interrupts again */
550 signal(SIGUSR1, SIG_IGN);
552 signal(SIGHUP, SIG_IGN);
554 if (outlevel == O_VERBOSE)
559 fprintf(stderr, "fetchmail: awakened at %s", ctime(&now));
565 if (outlevel == O_VERBOSE)
566 fprintf(stderr,"fetchmail: normal termination, status %d\n",
567 successes ? PS_SUCCESS : querystatus);
570 exit(successes ? PS_SUCCESS : querystatus);
573 static int load_params(int argc, char **argv, int optind)
575 int implicitmode, st;
577 struct query def_opts, *ctl;
579 memset(&def_opts, '\0', sizeof(struct query));
580 def_opts.smtp_socket = -1;
582 def_opts.server.protocol = P_AUTO;
583 def_opts.server.timeout = CLIENT_TIMEOUT;
584 def_opts.remotename = user;
585 def_opts.expunge = 1;
587 /* this builds the host list */
588 if (prc_parse_file(rcfile, !versioninfo) != 0)
591 if ((implicitmode = (optind >= argc)))
593 for (ctl = querylist; ctl; ctl = ctl->next)
597 for (; optind < argc; optind++)
600 * If hostname corresponds to a host known from the rc file,
601 * simply declare it active. Otherwise synthesize a host
602 * record from command line and defaults
604 for (ctl = querylist; ctl; ctl = ctl->next)
605 if (!strcmp(ctl->server.pollname, argv[optind])
606 || str_in_list(&ctl->server.akalist, argv[optind]))
609 ctl = hostalloc(&cmd_opts);
610 ctl->server.pollname = xstrdup(argv[optind]);
616 /* if there's a defaults record, merge it and lose it */
617 if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
619 for (ctl = querylist->next; ctl; ctl = ctl->next)
620 optmerge(ctl, querylist);
621 querylist = querylist->next;
624 /* don't allow a defaults record after the first */
625 for (ctl = querylist; ctl; ctl = ctl->next)
626 if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
629 /* merge in wired defaults, do sanity checks and prepare internal fields */
630 for (ctl = querylist; ctl; ctl = ctl->next)
632 if (ctl->active && !(implicitmode && ctl->server.skip))
634 /* merge in defaults */
635 optmerge(ctl, &def_opts);
637 /* make sure we have a nonempty host list to forward to */
639 save_str(&ctl->smtphunt, FALSE, fetchmailhost);
641 /* keep lusers from shooting themselves in the foot :-) */
642 if (poll_interval && ctl->limit)
644 fprintf(stderr,"fetchmail: you'd never see large messages!\n");
648 /* make sure delivery will default to a real local user */
649 if ((pw = getpwnam(user)) == (struct passwd *)NULL)
652 "fetchmail: can't set up default delivery to %s\n", user);
653 exit(PS_SYNTAX); /* has to be from bad rc file */
657 ctl->uid = pw->pw_uid; /* for local delivery via MDA */
658 if (!ctl->localnames) /* for local delivery via SMTP */
659 save_str_pair(&ctl->localnames, user, NULL);
662 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
663 /* can't handle multidrop mailboxes unless we can do DNS lookups */
664 if (ctl->localnames && ctl->localnames->next && ctl->server.dns)
666 fputs("fetchmail: can't handle multidrop mailboxes without DNS\n",
670 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
672 /* this code enables flags to be turned off */
673 #define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
675 else if (flag == FLAG_FALSE)\
679 DEFAULT(ctl->keep, FALSE);
680 DEFAULT(ctl->fetchall, FALSE);
681 DEFAULT(ctl->flush, FALSE);
682 DEFAULT(ctl->rewrite, TRUE);
683 DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
684 DEFAULT(ctl->forcecr, FALSE);
685 DEFAULT(ctl->pass8bits, FALSE);
686 DEFAULT(ctl->dropstatus, FALSE);
687 DEFAULT(ctl->server.dns, TRUE);
688 DEFAULT(ctl->server.uidl, FALSE);
693 * Compute the true name of the mailserver host.
694 * There are two clashing cases here:
696 * (1) The poll name is a label, possibly on one of several
697 * poll configurations for the same host. In this case
698 * the `via' option will be present and give the true name.
700 * (2) The poll name is the true one, the via name is
701 * localhost. This is going to be typical for ssh-using
704 * We're going to assume the via name is true unless it's
707 * Each poll cycle, if we've got DNS, we'll try to canonicalize
708 * the name. This will function as a probe to ensure the
709 * host's nameserver is up.
711 if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
712 ctl->server.queryname = xstrdup(ctl->server.via);
714 ctl->server.queryname = xstrdup(ctl->server.pollname);
715 ctl->server.truename = xstrdup(ctl->server.queryname);
717 /* if no folders were specified, set up the null one as default */
719 save_str(&ctl->mailboxes, -1, (char *)NULL);
721 /* maybe user overrode timeout on command line? */
722 if (ctl->server.timeout == -1)
723 ctl->server.timeout = CLIENT_TIMEOUT;
726 if (ctl->server.port < 0)
728 (void) fprintf(stderr,
729 "%s configuration invalid, port number cannot be negative",
730 ctl->server.pollname);
733 if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
735 (void) fprintf(stderr,
736 "%s configuration invalid, RPOP requires a privileged port",
737 ctl->server.pollname);
743 /* initialize UID handling */
744 if (!versioninfo && (st = prc_filecheck(idfile)) != 0)
748 initialize_saved_lists(querylist, idfile);
749 #endif /* POP3_ENABLE */
751 /* if cmd_logfile was explicitly set, use it to override logfile */
753 logfile = cmd_logfile;
755 /* likewise for poll_interval */
757 poll_interval = cmd_daemon;
759 /* check and daemon options are not compatible */
760 if (check_only && poll_interval)
763 return(implicitmode);
766 void termhook(int sig)
767 /* to be executed on normal or signal-induced termination */
772 * Sending SMTP QUIT on signal is theoretically nice, but led to a
773 * subtle bug. If fetchmail was terminated by signal while it was
774 * shipping message text, it would hang forever waiting for a
775 * command acknowledge. In theory we could enable the QUIT
776 * only outside of the message send. In practice, we don't
777 * care. All mailservers hang up on a dropped TCP/IP connection
782 error(0, 0, "terminated with signal %d", sig);
784 /* terminate all SMTP connections cleanly */
785 for (ctl = querylist; ctl; ctl = ctl->next)
786 if (ctl->smtp_socket != -1)
787 SMTP_quit(ctl->smtp_socket);
791 write_saved_lists(querylist, idfile);
792 #endif /* POP3_ENABLE */
795 * Craig Metz, the RFC1938 one-time-password guy, points out:
796 * "Remember that most kernels don't zero pages before handing them to the
797 * next process and many kernels share pages between user and kernel space.
798 * You'd be very surprised what you can find from a short program to do a
799 * malloc() and then dump the contents of the pages you got. By zeroing
800 * the secrets at end of run (earlier if you can), you make sure the next
801 * guy can't get the password/pass phrase."
803 * Right you are, Craig!
805 for (ctl = querylist; ctl; ctl = ctl->next)
807 memset(ctl->password, '\0', strlen(ctl->password));
809 #if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
813 exit(successes ? PS_SUCCESS : querystatus);
817 * Sequence of protocols to try when autoprobing, most capable to least.
819 static const int autoprobe[] =
823 #endif /* IMAP_ENABLE */
826 #endif /* POP3_ENABLE */
829 #endif /* POP2_ENABLE */
832 static int query_host(struct query *ctl)
833 /* perform fetch transaction with single host */
837 if (outlevel == O_VERBOSE)
842 fprintf(stderr, "fetchmail: %s querying %s (protocol %s) at %s",
844 ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now));
846 switch (ctl->server.protocol) {
848 for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
850 ctl->server.protocol = autoprobe[i];
851 if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY || st == PS_SMTP)
854 ctl->server.protocol = P_AUTO;
861 fprintf(stderr, "POP2 support is not configured.\n");
863 #endif /* POP2_ENABLE */
871 fprintf(stderr, "POP3 support is not configured.\n");
873 #endif /* POP3_ENABLE */
880 fprintf(stderr, "IMAP support is not configured.\n");
882 #endif /* IMAP_ENABLE */
886 fprintf(stderr, "ETRN support is not configured.\n");
889 #ifdef HAVE_GETHOSTBYNAME
892 fprintf(stderr, "Cannot support ETRN without gethostbyname(2).\n");
894 #endif /* HAVE_GETHOSTBYNAME */
895 #endif /* ETRN_ENABLE */
897 error(0, 0, "unsupported protocol selected.");
902 void dump_params (struct query *ctl)
903 /* display query parameters in English */
905 printf("Options for retrieving from %s@%s:\n",
906 ctl->remotename, visbuf(ctl->server.pollname));
909 printf(" Mail will be retrieved via %s\n", ctl->server.via);
911 if (ctl->server.interval)
912 printf(" Poll of this server will occur every %d intervals.\n",
913 ctl->server.interval);
914 if (ctl->server.truename)
915 printf(" True name of server is %s.\n", ctl->server.truename);
916 if (ctl->server.skip || outlevel == O_VERBOSE)
917 printf(" This host will%s be queried when no host is specified.\n",
918 ctl->server.skip ? " not" : "");
920 printf(" Password will be prompted for.\n");
921 else if (outlevel == O_VERBOSE)
922 if (ctl->server.protocol == P_APOP)
923 printf(" APOP secret = '%s'.\n", visbuf(ctl->password));
924 else if (ctl->server.protocol == P_RPOP)
925 printf(" RPOP id = '%s'.\n", visbuf(ctl->password));
927 printf(" Password = '%s'.\n", visbuf(ctl->password));
928 if (ctl->server.protocol == P_POP3
929 && ctl->server.port == KPOP_PORT
930 && ctl->server.preauthenticate == A_KERBEROS_V4)
931 printf(" Protocol is KPOP");
933 printf(" Protocol is %s", showproto(ctl->server.protocol));
934 if (ctl->server.port)
935 printf(" (using port %d)", ctl->server.port);
936 else if (outlevel == O_VERBOSE)
937 printf(" (using default port)");
938 if (ctl->server.uidl)
939 printf(" (forcing UIDL use)");
942 if (ctl->server.preauthenticate == A_KERBEROS_V4)
943 printf(" Kerberos V4 preauthentication enabled.\n");
944 if (ctl->server.timeout > 0)
945 printf(" Server nonresponse timeout is %d seconds", ctl->server.timeout);
946 if (ctl->server.timeout == CLIENT_TIMEOUT)
947 printf(" (default).\n");
951 if (!ctl->mailboxes->id)
952 printf(" Default mailbox selected.\n");
957 printf(" Selected mailboxes are:");
958 for (idp = ctl->mailboxes; idp; idp = idp->next)
959 printf(" %s", idp->id);
962 printf(" %s messages will be retrieved (--all %s).\n",
963 ctl->fetchall ? "All" : "Only new",
964 ctl->fetchall ? "on" : "off");
965 printf(" Fetched messages will%s be kept on the server (--keep %s).\n",
966 ctl->keep ? "" : " not",
967 ctl->keep ? "on" : "off");
968 printf(" Old messages will%s be flushed before message retrieval (--flush %s).\n",
969 ctl->flush ? "" : " not",
970 ctl->flush ? "on" : "off");
971 printf(" Rewrite of server-local addresses is %sabled (--norewrite %s).\n",
972 ctl->rewrite ? "en" : "dis",
973 ctl->rewrite ? "off" : "on");
974 printf(" Carriage-return stripping is %sabled (stripcr %s).\n",
975 ctl->stripcr ? "en" : "dis",
976 ctl->stripcr ? "on" : "off");
977 printf(" Carriage-return forcing is %sabled (forcecr %s).\n",
978 ctl->forcecr ? "en" : "dis",
979 ctl->forcecr ? "on" : "off");
980 printf(" Interpretation of Content-Transfer-Encoding is %sabled (pass8bits %s).\n",
981 ctl->pass8bits ? "dis" : "en",
982 ctl->pass8bits ? "on" : "off");
983 printf(" Nonempty Status lines will be %s (dropstatus %s)\n",
984 ctl->dropstatus ? "discarded" : "kept",
985 ctl->dropstatus ? "on" : "off");
987 printf(" Message size limit is %d bytes (--limit %d).\n",
988 ctl->limit, ctl->limit);
989 else if (outlevel == O_VERBOSE)
990 printf(" No message size limit (--limit 0).\n");
991 if (ctl->fetchlimit > 0)
992 printf(" Received-message limit is %d (--fetchlimit %d).\n",
993 ctl->fetchlimit, ctl->fetchlimit);
994 else if (outlevel == O_VERBOSE)
995 printf(" No received-message limit (--fetchlimit 0).\n");
996 if (ctl->batchlimit > 0)
997 printf(" SMTP message batch limit is %d.\n", ctl->batchlimit);
998 else if (outlevel == O_VERBOSE)
999 printf(" No SMTP message batch limit (--batchlimit 0).\n");
1000 if (ctl->server.protocol == P_IMAP)
1001 if (ctl->expunge > 0)
1002 printf(" Deletion interval between expunges is %d (--expunge %d).\n", ctl->expunge, ctl->expunge);
1003 else if (outlevel == O_VERBOSE)
1004 printf(" No expunges (--expunge 0).\n");
1006 printf(" Messages will be delivered with '%s.'\n", visbuf(ctl->mda));
1011 printf(" Messages will be SMTP-forwarded to:");
1012 for (idp = ctl->smtphunt; idp; idp = idp->next)
1013 if (ctl->server.protocol != P_ETRN || idp->val.num)
1015 printf(" %s", idp->id);
1017 printf(" (default)");
1021 if (ctl->preconnect)
1022 printf(" Server connection will be brought up with '%s.'\n",
1023 visbuf(ctl->preconnect));
1024 else if (outlevel == O_VERBOSE)
1025 printf(" No pre-connection command.\n");
1026 if (ctl->postconnect)
1027 printf(" Server connection will be taken down with '%s.'\n",
1028 visbuf(ctl->postconnect));
1029 else if (outlevel == O_VERBOSE)
1030 printf(" No post-connection command.\n");
1031 if (!ctl->localnames)
1032 printf(" No localnames declared for this host.\n");
1038 for (idp = ctl->localnames; idp; idp = idp->next)
1041 if (count > 1 || ctl->wildcard)
1042 printf(" Multi-drop mode: ");
1044 printf(" Single-drop mode: ");
1046 printf("%d local name(s) recognized.\n", count);
1047 if (outlevel == O_VERBOSE)
1049 for (idp = ctl->localnames; idp; idp = idp->next)
1051 printf("\t%s -> %s\n", idp->id, idp->val.id2);
1053 printf("\t%s\n", idp->id);
1055 fputs("*\n", stdout);
1058 if (count > 1 || ctl->wildcard)
1060 printf(" DNS lookup for multidrop addresses is %sabled.\n",
1061 ctl->server.dns ? "en" : "dis");
1063 if (ctl->server.envelope == STRING_DISABLED)
1064 printf(" Envelope-address routing is disabled\n");
1067 printf(" Envelope header is assumed to be: %s\n",
1068 ctl->server.envelope ? ctl->server.envelope:"Received");
1069 if (ctl->server.envskip > 1 || outlevel >= O_VERBOSE)
1070 printf(" Number of envelope header to be parsed: %d\n",
1071 ctl->server.envskip);
1072 if (ctl->server.qvirtual)
1073 printf(" Prefix %s will be removed from user id\n",
1074 ctl->server.qvirtual);
1075 else if (outlevel >= O_VERBOSE)
1076 printf(" No prefix stripping\n");
1079 if (ctl->server.akalist)
1083 printf(" Predeclared mailserver aliases:");
1084 for (idp = ctl->server.akalist; idp; idp = idp->next)
1085 printf(" %s", idp->id);
1088 if (ctl->server.localdomains)
1092 printf(" Local domains:");
1093 for (idp = ctl->server.localdomains; idp; idp = idp->next)
1094 printf(" %s", idp->id);
1100 if (ctl->server.interface)
1101 printf(" Connection must be through interface %s.\n", ctl->server.interface);
1102 else if (outlevel == O_VERBOSE)
1103 printf(" No interface requirement specified.\n");
1104 if (ctl->server.monitor)
1105 printf(" Polling loop will monitor %s.\n", ctl->server.monitor);
1106 else if (outlevel == O_VERBOSE)
1107 printf(" No monitor interface specified.\n");
1110 if (ctl->server.protocol > P_POP2)
1112 printf(" No UIDs saved from this host.\n");
1118 for (idp = ctl->oldsaved; idp; idp = idp->next)
1121 printf(" %d UIDs saved.\n", count);
1122 if (outlevel == O_VERBOSE)
1123 for (idp = ctl->oldsaved; idp; idp = idp->next)
1124 fprintf(stderr, "\t%s\n", idp->id);
1128 /* fetchmail.c ends here */