]> Pileus Git - ~andy/fetchmail/blobdiff - fetchmail.c
Deal with Post Office/NT.
[~andy/fetchmail] / fetchmail.c
index 4e12868625f8004489d299045c29654f37f3ac0b..54dc45c66640782b019071ace28b48cf27b5e5d6 100644 (file)
@@ -4,7 +4,7 @@
  * For license terms, see the file COPYING in this directory.
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <stdio.h>
 #include <ctype.h>
 #include <netdb.h>
 #endif /* HAVE_GETHOSTBYNAME */
 
-#ifdef SUNOS
-#include <stdlib.h>
-#endif
-
 #include "fetchmail.h"
 #include "tunable.h"
 #include "smtp.h"
 
 #define DROPDEAD       6       /* maximum bad socket opens */
 
+#ifndef ENETUNREACH
+#define ENETUNREACH   128       /* Interactive doesn't know this */
+#endif /* ENETUNREACH */
+
 /* prototypes for internal functions */
 static int load_params(int, char **, int);
 static void dump_params (struct query *);
 static int query_host(struct query *);
-static char *visbuf(const char *);
 
 /* controls the detail level of status/progress messages written to stderr */
 int outlevel;          /* see the O_.* constants above */
-int yydebug;           /* enable parse debugging */
 
 /* daemon mode control */
-int poll_interval;     /* poll interval in seconds */
-bool nodetach;         /* if TRUE, don't detach daemon process */
-char *logfile;         /* log file for daemon mode */
-bool use_syslog;       /* if --syslog was set */
-bool quitmode;         /* if --quit was set */
-bool check_only;       /* if --probe was set */
+flag nodetach;         /* if TRUE, don't detach daemon process */
+flag quitmode;         /* if --quit was set */
+flag check_only;       /* if --probe was set */
 char *cmd_logfile;     /* if --logfile was set */
 int cmd_daemon;        /* if --daemon was set */
 
 /* miscellaneous global controls */
-char *rcfile;          /* path name of rc file */
 char *idfile;          /* UID list file */
-bool versioninfo;      /* emit only version info */
+flag versioninfo;      /* emit only version info */
 char *user;            /* the name of the invoking user */
+char *home;
 char *fetchmailhost;   /* the name of the host running fetchmail */
 char *program_name;    /* the name to prefix error messages with */
 
 static char *lockfile;         /* name of lockfile */
 static int querystatus;                /* status of query */
+static int successes;          /* count number of successful polls */
 static int lastsig;            /* last signal received */
 
 static void termhook();                /* forward declaration of exit hook */
 
 RETSIGTYPE donothing(sig) int sig; {signal(sig, donothing); lastsig = sig;}
 
-#ifdef HAVE_ATEXIT
-static void unlockit(void)
-#else  /* use on_exit(), e.g. on SunOS */
+#ifdef HAVE_ON_EXIT
 static void unlockit(int n, void *p)
+#else
+static void unlockit(void)
 #endif
 /* must-do actions for exit (but we can't count on being able to do malloc) */
 {
@@ -95,58 +91,13 @@ int main (int argc, char **argv)
 {
     int st, bkgd = FALSE;
     int parsestatus, implicitmode = FALSE;
-    char *home, *tmpdir, tmpbuf[BUFSIZ]; 
-    struct passwd *pw;
     struct query *ctl;
     FILE       *lockfp;
     netrc_entry *netrc_list;
-    char *netrc_file;
+    char *netrc_file, tmpbuf[BUFSIZ];
     pid_t pid;
 
-    if ((program_name = strrchr(argv[0], '/')) != NULL)
-       ++program_name;
-    else
-       program_name = argv[0];
-
-    if ((user = getenv("USER")) == (char *)NULL)
-        user = getenv("LOGNAME");
-
-    if ((user == (char *)NULL) || (home = getenv("HOME")) == (char *)NULL)
-    {
-       if ((pw = getpwuid(getuid())) != NULL)
-       {
-           user = pw->pw_name;
-           home = pw->pw_dir;
-       }
-       else
-       {
-           fprintf(stderr,"fetchmail: can't find your name and home directory!\n");
-           exit(PS_UNDEFINED);
-       }
-    }
-
-    /* we'll need this for the SMTP forwarding target and error messages */
-    if (gethostname(tmpbuf, sizeof(tmpbuf)))
-    {
-       fprintf(stderr, "fetchmail: can't determine fetchmail's host!");
-       exit(PS_IOERR);
-    }
-    fetchmailhost = xstrdup(tmpbuf);
-
-    /*
-     * Backward-compatibility hack.  If we're called by the name of the
-     * ancestral popclient, look for .poprc.  This will actually work 
-     * for popclient files that don't use the removed keywords.
-     */
-    if (strcmp("popclient", argv[0]) == 0)
-       tmpdir = ".poprc";
-    else
-       tmpdir = ".fetchmailrc";
-
-    rcfile = (char *) xmalloc(strlen(home)+strlen(tmpdir)+2);
-    strcpy(rcfile, home);
-    strcat(rcfile, "/");
-    strcat(rcfile, tmpdir);
+    envquery(argc, argv);
 
 #define IDFILE_NAME    ".fetchids"
     idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
@@ -163,15 +114,20 @@ int main (int argc, char **argv)
     setvbuf(stdout, NULL, _IOLBF, POPBUFSIZE);
 
     if (versioninfo)
+    {
        printf("This is fetchmail release %s\n", RELEASE_ID);
 
+       /* this is an attempt to help remote debugging */
+       system("uname -a");
+    }
+
     /* avoid parsing the config file if all we're doing is killing a daemon */ 
     if (!quitmode)
        implicitmode = load_params(argc, argv, optind);
 
     /* set up to do lock protocol */
     if (!getuid())
-       strcpy(tmpbuf, "/var/run/fetchmail.pid");
+       sprintf(tmpbuf, "%s/fetchmail.pid", PID_DIR);
     else {
        strcpy(tmpbuf, home);
        strcat(tmpbuf, "/.fetchmail");
@@ -184,8 +140,12 @@ int main (int argc, char **argv)
            printf("\n");
        else
            printf(" and %s\n", rcfile);
+       if (poll_interval)
+           printf("Poll interval is %d seconds\n", poll_interval);
        if (outlevel == O_VERBOSE)
            printf("Lockfile at %s\n", tmpbuf);
+       if (logfile)
+           printf("Logfile is %s\n", logfile);
        for (ctl = querylist; ctl; ctl = ctl->next) {
            if (ctl->active && !(implicitmode && ctl->server.skip))
                dump_params(ctl);
@@ -195,10 +155,6 @@ int main (int argc, char **argv)
                "No mailservers set up -- perhaps %s is missing?\n", rcfile);
        exit(0);
     }
-    else if (!quitmode && querylist == NULL) {
-       (void) fputs("fetchmail: no mailservers have been specified.\n", stderr);
-       exit(PS_SYNTAX);
-    }
 
     /* check for another fetchmail running concurrently */
     pid = -1;
@@ -222,6 +178,12 @@ int main (int argc, char **argv)
        fclose(lockfp);
     }
 
+    /* if no mail servers listed and nothing in background, we're done */
+    if (!quitmode && pid == -1 && querylist == NULL) {
+       (void)fputs("fetchmail: no mailservers have been specified.\n",stderr);
+       exit(PS_SYNTAX);
+    }
+
     /* perhaps user asked us to kill the other fetchmail */
     if (quitmode)
     {
@@ -285,8 +247,8 @@ int main (int argc, char **argv)
        {
            /*
             * Should never happen -- possible only if a background fetchmail
-            * croaks after the first kill probe above but before the SIGUSR1/SIGHUP
-            * transmission.
+            * croaks after the first kill probe above but before the
+            * SIGUSR1/SIGHUP transmission.
             */
            fprintf(stderr,
                    "fetchmail: elder sibling at %d died mysteriously.\n",
@@ -312,7 +274,7 @@ int main (int argc, char **argv)
            else
            {
                /* look up the host and account in the .netrc file. */
-               netrc_entry *p = search_netrc(netrc_list,ctl->server.names->id);
+               netrc_entry *p = search_netrc(netrc_list,ctl->server.pollname);
                while (p && strcmp(p->account, ctl->remotename))
                    p = search_netrc(p->next, ctl->remotename);
 
@@ -324,7 +286,7 @@ int main (int argc, char **argv)
            if (ctl->server.protocol != P_ETRN && ctl->server.protocol != P_IMAP_K4 && !ctl->password)
            {
                (void) sprintf(tmpbuf, "Enter password for %s@%s: ",
-                              ctl->remotename, ctl->server.names->id);
+                              ctl->remotename, ctl->server.pollname);
                ctl->password = xstrdup((char *)getpassword(tmpbuf));
            }
        }
@@ -374,7 +336,8 @@ int main (int argc, char **argv)
 
 #ifdef HAVE_ATEXIT
        atexit(unlockit);
-#else
+#endif
+#ifdef HAVE_ON_EXIT
        on_exit(unlockit, (char *)NULL);
 #endif
     }
@@ -393,6 +356,19 @@ int main (int argc, char **argv)
        {
            if (ctl->active && !(implicitmode && ctl->server.skip))
            {
+               /* check skip interval first so that it counts all polls */
+               if (poll_interval && ctl->server.interval) 
+               {
+                   if (ctl->server.poll_count++ % ctl->server.interval) 
+                   {
+                       if (outlevel == O_VERBOSE)
+                           fprintf(stderr,
+                                   "fetchmail: interval not reached, not querying %s\n",
+                                   ctl->server.pollname);
+                       continue;
+                   }
+               }
+
 #ifdef linux
                /* interface_approve() does its own error logging */
                if (!interface_approve(&ctl->server))
@@ -401,9 +377,9 @@ int main (int argc, char **argv)
 
 #ifdef HAVE_GETHOSTBYNAME
                /*
-                * This functions partly as an optimization and partly
-                * as a probe to make sure our nameserver is still up.
-                * The multidrop case (especially) needs it.
+                * This functions partly as a probe to make sure our
+                * nameserver is still up.  The multidrop case
+                * (especially) needs it.
                 */
                if (ctl->server.preauthenticate==A_KERBEROS_V4 || MULTIDROP(ctl))
                {
@@ -411,12 +387,12 @@ int main (int argc, char **argv)
 
                    /* compute the canonical name of the host */
                    errno = 0;
-                   namerec = gethostbyname(ctl->server.names->id);
+                   namerec = gethostbyname(ctl->server.queryname);
                    if (namerec == (struct hostent *)NULL)
                    {
                        error(0, errno,
                                "skipping %s poll, ",
-                               ctl->server.names->id);
+                               ctl->server.pollname);
                        if (errno)
                        {
                            if (errno == ENETUNREACH)
@@ -430,15 +406,19 @@ int main (int argc, char **argv)
                    }
                    else
                    {
-                       free(ctl->server.canonical_name);
-                       ctl->server.canonical_name = xstrdup((char *)namerec->h_name);
+                       free(ctl->server.truename);
+                       ctl->server.truename=xstrdup((char *)namerec->h_name);
                    }
                }
 #endif /* HAVE_GETHOSTBYNAME */
 
                querystatus = query_host(ctl);
-               if (!check_only)
-                   update_str_lists(ctl);
+
+               if (querystatus == PS_SUCCESS) {
+                   successes++;
+                   if (!check_only)
+                     update_str_lists(ctl);
+               }
 #ifdef linux
                if (ctl->server.monitor)
                    {
@@ -526,17 +506,18 @@ int main (int argc, char **argv)
        (poll_interval);
 
     if (outlevel == O_VERBOSE)
-       fprintf(stderr,"fetchmail: normal termination, status %d\n",querystatus);
+       fprintf(stderr,"fetchmail: normal termination, status %d\n",
+               successes ? PS_SUCCESS : querystatus);
 
     termhook(0);
-    exit(querystatus);
+    exit(successes ? PS_SUCCESS : querystatus);
 }
 
 static int load_params(int argc, char **argv, int optind)
 {
     int        implicitmode, st;
     struct passwd *pw;
-    struct query def_opts, *ctl, *mp;
+    struct query def_opts, *ctl;
 
     memset(&def_opts, '\0', sizeof(struct query));
     def_opts.smtp_socket = -1;
@@ -544,10 +525,11 @@ static int load_params(int argc, char **argv, int optind)
     def_opts.server.protocol = P_AUTO;
     def_opts.server.timeout = CLIENT_TIMEOUT;
     def_opts.remotename = user;
-    save_str(&def_opts.smtphunt, -1, fetchmailhost);
+    save_str(&def_opts.smtphunt, TRUE, fetchmailhost);
+    save_str(&def_opts.smtphunt, FALSE, "localhost");
 
     /* this builds the host list */
-    if (prc_parse_file(rcfile) != 0)
+    if (prc_parse_file(rcfile, !versioninfo) != 0)
        exit(PS_SYNTAX);
 
     if ((implicitmode = (optind >= argc)))
@@ -564,18 +546,19 @@ static int load_params(int argc, char **argv, int optind)
             * record from command line and defaults
             */
            for (ctl = querylist; ctl; ctl = ctl->next)
-               if (str_in_list(&ctl->server.names, argv[optind]))
+               if (!strcmp(ctl->server.pollname, argv[optind])
+                       || str_in_list(&ctl->server.akalist, argv[optind]))
                    goto foundit;
 
            ctl = hostalloc(&cmd_opts);
-           save_str(&ctl->server.names, -1, argv[optind]);
+           ctl->server.pollname = xstrdup(argv[optind]);
 
        foundit:
            ctl->active = TRUE;
        }
 
     /* if there's a defaults record, merge it and lose it */ 
-    if (querylist && strcmp(querylist->server.names->id, "defaults") == 0)
+    if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
     {
        for (ctl = querylist->next; ctl; ctl = ctl->next)
            optmerge(ctl, querylist);
@@ -584,7 +567,7 @@ static int load_params(int argc, char **argv, int optind)
 
     /* don't allow a defaults record after the first */
     for (ctl = querylist; ctl; ctl = ctl->next)
-       if (ctl != querylist && strcmp(ctl->server.names->id, "defaults") == 0)
+       if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
            exit(PS_SYNTAX);
 
     /* merge in wired defaults, do sanity checks and prepare internal fields */
@@ -626,16 +609,6 @@ static int load_params(int argc, char **argv, int optind)
            }
 #endif /* !HAVE_GETHOSTBYNAME || !HAVE_RES_SEARCH */
 
-           /* compute server leaders for queries */
-           for (mp = querylist; mp && mp != ctl; mp = mp->next)
-               if (strcmp(mp->server.names->id, ctl->server.names->id) == 0)
-               {
-                   ctl->server.lead_server = mp->server.lead_server;
-                   goto no_new_server;
-               }
-           ctl->server.lead_server = &(ctl->server);
-       no_new_server:;
-
            /* this code enables flags to be turned off */
 #define DEFAULT(flag, dflt)    if (flag == FLAG_TRUE)\
                                        flag = TRUE;\
@@ -644,43 +617,71 @@ static int load_params(int argc, char **argv, int optind)
                                else\
                                        flag = (dflt)
            DEFAULT(ctl->keep, FALSE);
-           DEFAULT(ctl->flush, FALSE);
            DEFAULT(ctl->fetchall, FALSE);
+           DEFAULT(ctl->flush, FALSE);
            DEFAULT(ctl->rewrite, TRUE);
            DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL)); 
            DEFAULT(ctl->forcecr, FALSE);
+           DEFAULT(ctl->pass8bits, FALSE);
+           DEFAULT(ctl->dropstatus, FALSE);
            DEFAULT(ctl->server.dns, TRUE);
            DEFAULT(ctl->server.uidl, FALSE);
 #undef DEFAULT
 
-           /* plug in the semi-standard way of indicating a mail address */
-           if (ctl->server.envelope == (char *)NULL)
-               ctl->server.envelope = "X-Envelope-To:";
+           /*
+            *
+            * Compute the true name of the mailserver host.  
+            * There are two clashing cases here:
+            *
+            * (1) The poll name is a label, possibly on one of several
+            *     poll configurations for the same host.  In this case 
+            *     the `via' option will be present and give the true name.
+            *
+            * (2) The poll name is the true one, the via name is 
+            *     localhost.   This is going to be typical for ssh-using
+            *     configurations.
+            *
+            * We're going to assume the via name is true unless it's
+            * localhost.
+            *
+            * Each poll cycle, if we've got DNS, we'll try to canonicalize
+            * the name.  This will function as a probe to ensure the
+            * host's nameserver is up.
+            */
+           if (ctl->server.via && strcmp(ctl->server.via, "localhost"))
+               ctl->server.queryname = xstrdup(ctl->server.via);
+           else
+               ctl->server.queryname = xstrdup(ctl->server.pollname);
+           ctl->server.truename = xstrdup(ctl->server.queryname);
 
            /* if no folders were specified, set up the null one as default */
            if (!ctl->mailboxes)
                save_str(&ctl->mailboxes, -1, (char *)NULL);
 
+           /* maybe user overrode timeout on command line? */
+           if (ctl->server.timeout == -1)      
+               ctl->server.timeout = CLIENT_TIMEOUT;
+
            /* sanity checks */
            if (ctl->server.port < 0)
            {
                (void) fprintf(stderr,
                               "%s configuration invalid, port number cannot be negative",
-                              ctl->server.names->id);
+                              ctl->server.pollname);
                exit(PS_SYNTAX);
            }
            if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
            {
                (void) fprintf(stderr,
                               "%s configuration invalid, RPOP requires a privileged port",
-                              ctl->server.names->id);
+                              ctl->server.pollname);
                exit(PS_SYNTAX);
            }
        }
     }
 
     /* initialize UID handling */
-    if ((st = prc_filecheck(idfile)) != 0)
+    if (!versioninfo && (st = prc_filecheck(idfile)) != 0)
        exit(st);
     else
        initialize_saved_lists(querylist, idfile);
@@ -709,7 +710,7 @@ void termhook(int sig)
      * Sending SMTP QUIT on signal is theoretically nice, but led to a 
      * subtle bug.  If fetchmail was terminated by signal while it was 
      * shipping message text, it would hang forever waiting for a
-     * command acknowledge.  In theory we could disable the QUIT
+     * command acknowledge.  In theory we could enable the QUIT
      * only outside of the message send.  In practice, we don't
      * care.  All mailservers hang up on a dropped TCP/IP connection
      * anyway.
@@ -726,26 +727,26 @@ void termhook(int sig)
     if (!check_only)
        write_saved_lists(querylist, idfile);
 
-    exit(querystatus);
-}
+    /* 
+     * Craig Metz, the RFC1938 one-time-password guy, points out:
+     * "Remember that most kernels don't zero pages before handing them to the
+     * next process and many kernels share pages between user and kernel space.
+     * You'd be very surprised what you can find from a short program to do a
+     * malloc() and then dump the contents of the pages you got. By zeroing
+     * the secrets at end of run (earlier if you can), you make sure the next
+     * guy can't get the password/pass phrase."
+     *
+     * Right you are, Craig!
+     */
+    for (ctl = querylist; ctl; ctl = ctl->next)
+       if (ctl->password)
+         memset(ctl->password, '\0', strlen(ctl->password));
 
-static char *showproto(int proto)
-/* protocol index to protocol name mapping */
-{
-    switch (proto)
-    {
-    case P_AUTO: return("auto"); break;
-#ifdef POP2_ENABLE
-    case P_POP2: return("POP2"); break;
-#endif /* POP2_ENABLE */
-    case P_POP3: return("POP3"); break;
-    case P_IMAP: return("IMAP"); break;
-    case P_IMAP_K4: return("IMAP-K4"); break;
-    case P_APOP: return("APOP"); break;
-    case P_RPOP: return("RPOP"); break;
-    case P_ETRN: return("ETRN"); break;
-    default: return("unknown?!?"); break;
-    }
+#if !defined(HAVE_ATEXIT) && !defined(HAVE_ON_EXIT)
+    unlockit();
+#endif
+
+    exit(successes ? PS_SUCCESS : querystatus);
 }
 
 /*
@@ -762,18 +763,6 @@ static int query_host(struct query *ctl)
 {
     int i, st;
 
-    if (poll_interval && ctl->server.interval) 
-    {
-       if (ctl->server.poll_count++ % ctl->server.interval) 
-       {
-           if (outlevel == O_VERBOSE)
-               fprintf(stderr,
-                   "fetchmail: interval not reached, not querying %s\n",
-                   ctl->server.names->id);
-           return PS_NOMAIL;
-       }
-    }
-
     if (outlevel == O_VERBOSE)
     {
        time_t now;
@@ -781,14 +770,14 @@ static int query_host(struct query *ctl)
        time(&now);
        fprintf(stderr, "fetchmail: %s querying %s (protocol %s) at %s",
            RELEASE_ID,
-           ctl->server.names->id, showproto(ctl->server.protocol), ctime(&now));
+           ctl->server.pollname, showproto(ctl->server.protocol), ctime(&now));
     }
     switch (ctl->server.protocol) {
     case P_AUTO:
        for (i = 0; i < sizeof(autoprobe)/sizeof(autoprobe[0]); i++)
        {
            ctl->server.protocol = autoprobe[i];
-           if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL)
+           if ((st = query_host(ctl)) == PS_SUCCESS || st == PS_NOMAIL || st == PS_AUTHFAIL || st == PS_LOCKBUSY || st == PS_SMTP)
                break;
        }
        ctl->server.protocol = P_AUTO;
@@ -812,7 +801,12 @@ static int query_host(struct query *ctl)
        return(doIMAP(ctl));
        break;
     case P_ETRN:
+#ifdef HAVE_GETHOSTBYNAME
        return(doETRN(ctl));
+#else
+       fprintf(stderr, "Cannot support ETRN without gethostbyname(2).\n");
+       return(PS_PROTOCOL);
+#endif /* HAVE_GETHOSTBYNAME */
     default:
        error(0, 0, "unsupported protocol selected.");
        return(PS_PROTOCOL);
@@ -823,25 +817,22 @@ void dump_params (struct query *ctl)
 /* display query parameters in English */
 {
     printf("Options for retrieving from %s@%s:\n",
-          ctl->remotename, visbuf(ctl->server.names->id));
+          ctl->remotename, visbuf(ctl->server.pollname));
+
+    if (ctl->server.via)
+       printf("  Mail will be retrieved via %s\n", ctl->server.via);
 
-    if (logfile)
-       printf("  Logfile is %s\n", logfile);
-    if (poll_interval)
-       printf("  Poll interval is %d seconds\n", poll_interval);
     if (ctl->server.interval)
        printf("  Poll of this server will occur every %d intervals.\n",
               ctl->server.interval);
-#ifdef HAVE_GETHOSTBYNAME
-    if (ctl->server.canonical_name)
-       printf("  Canonical DNS name of server is %s.\n", ctl->server.canonical_name);
-#endif /* HAVE_GETHOSTBYNAME */
-    if (ctl->server.names->next)
+    if (ctl->server.truename)
+       printf("  True name of server is %s.\n", ctl->server.truename);
+    if (ctl->server.akalist)
     {
        struct idlist *idp;
 
        printf("  Predeclared mailserver aliases:");
-       for (idp = ctl->server.names->next; idp; idp = idp->next)
+       for (idp = ctl->server.akalist; idp; idp = idp->next)
            printf(" %s", idp->id);
        putchar('\n');
     }
@@ -873,7 +864,8 @@ void dump_params (struct query *ctl)
     putchar('\n');
     if (ctl->server.preauthenticate == A_KERBEROS_V4)
            printf("  Kerberos V4 preauthentication enabled.\n");
-    printf("  Server nonresponse timeout is %d seconds", ctl->server.timeout);
+    if (ctl->server.timeout > 0)
+       printf("  Server nonresponse timeout is %d seconds", ctl->server.timeout);
     if (ctl->server.timeout ==  CLIENT_TIMEOUT)
        printf(" (default).\n");
     else
@@ -911,12 +903,18 @@ void dump_params (struct query *ctl)
     printf("  Rewrite of server-local addresses is %sabled (--norewrite %s).\n",
           ctl->rewrite ? "en" : "dis",
           ctl->rewrite ? "off" : "on");
-    printf("  Carriage-return stripping is %sabled (--stripcr %s).\n",
+    printf("  Carriage-return stripping is %sabled (stripcr %s).\n",
           ctl->stripcr ? "en" : "dis",
           ctl->stripcr ? "on" : "off");
-    printf("  Carriage-return forcing is %sabled (--forcecr %s).\n",
+    printf("  Carriage-return forcing is %sabled (forcecr %s).\n",
           ctl->forcecr ? "en" : "dis",
           ctl->forcecr ? "on" : "off");
+    printf("  Interpretation of Content-Transfer-Encoding is %sabled (pass8bits %s).\n",
+          ctl->pass8bits ? "dis" : "en",
+          ctl->pass8bits ? "on" : "off");
+    printf("  Nonempty Status lines will be %s (dropstatus %s)\n",
+          ctl->dropstatus ? "discarded" : "kept",
+          ctl->dropstatus ? "on" : "off");
     if (ctl->limit > 0)
        printf("  Message size limit is %d bytes (--limit %d).\n", 
               ctl->limit, ctl->limit);
@@ -943,9 +941,15 @@ void dump_params (struct query *ctl)
        printf("\n");
     }
     if (ctl->preconnect)
-       printf("  Server connection will be preinitialized with '%s.'\n", visbuf(ctl->preconnect));
+       printf("  Server connection will be brought up with '%s.'\n",
+              visbuf(ctl->preconnect));
     else if (outlevel == O_VERBOSE)
-       printf("  No preinitialization command.\n");
+       printf("  No pre-connection command.\n");
+    if (ctl->postconnect)
+       printf("  Server connection will be taken down with '%s.'\n",
+              visbuf(ctl->postconnect));
+    else if (outlevel == O_VERBOSE)
+       printf("  No post-connection command.\n");
     if (!ctl->localnames)
        printf("  No localnames declared for this host.\n");
     else
@@ -1006,90 +1010,4 @@ void dump_params (struct query *ctl)
        }
 }
 
-/* helper functions for string interpretation and display */
-
-void escapes(cp, tp)
-/* process standard C-style escape sequences in a string */
-const char     *cp;    /* source string with escapes */
-char           *tp;    /* target buffer for digested string */
-{
-    while (*cp)
-    {
-       int     cval = 0;
-
-       if (*cp == '\\' && strchr("0123456789xX", cp[1]))
-       {
-           char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
-           int dcount = 0;
-
-           if (*++cp == 'x' || *cp == 'X')
-               for (++cp; (dp = strchr(hex, *cp)) && (dcount++ < 2); cp++)
-                   cval = (cval * 16) + (dp - hex) / 2;
-           else if (*cp == '0')
-               while (strchr("01234567",*cp) != (char*)NULL && (dcount++ < 3))
-                   cval = (cval * 8) + (*cp++ - '0');
-           else
-               while ((strchr("0123456789",*cp)!=(char*)NULL)&&(dcount++ < 3))
-                   cval = (cval * 10) + (*cp++ - '0');
-       }
-       else if (*cp == '\\')           /* C-style character escapes */
-       {
-           switch (*++cp)
-           {
-           case '\\': cval = '\\'; break;
-           case 'n': cval = '\n'; break;
-           case 't': cval = '\t'; break;
-           case 'b': cval = '\b'; break;
-           case 'r': cval = '\r'; break;
-           default: cval = *cp;
-           }
-           cp++;
-       }
-       else
-           cval = *cp++;
-       *tp++ = cval;
-    }
-    *tp = '\0';
-}
-
-static char *visbuf(const char *buf)
-/* visibilize a given string */
-{
-    static char vbuf[BUFSIZ];
-    char *tp = vbuf;
-
-    while (*buf)
-    {
-       if (isprint(*buf) || *buf == ' ')
-           *tp++ = *buf++;
-       else if (*buf == '\n')
-       {
-           *tp++ = '\\'; *tp++ = 'n';
-           buf++;
-       }
-       else if (*buf == '\r')
-       {
-           *tp++ = '\\'; *tp++ = 'r';
-           buf++;
-       }
-       else if (*buf == '\b')
-       {
-           *tp++ = '\\'; *tp++ = 'b';
-           buf++;
-       }
-       else if (*buf < ' ')
-       {
-           *tp++ = '\\'; *tp++ = '^'; *tp++ = '@' + *buf;
-           buf++;
-       }
-       else
-       {
-           (void) sprintf(tp, "\\0x%02x", *buf++);
-           tp += strlen(tp);
-       }
-    }
-    *tp++ = '\0';
-    return(vbuf);
-}
-
 /* fetchmail.c ends here */