diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-09-16 23:24:18 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-09-16 23:24:18 +0000 |
commit | 763d1ace340134df6a237469bb5b76bc86cbbbec (patch) | |
tree | 35e2807b4c60c9e7719a5635c48780fea1d14e64 | |
parent | 54f14b712e3e8f6007192dfdc2c94d6aec369946 (diff) | |
download | fetchmail-763d1ace340134df6a237469bb5b76bc86cbbbec.tar.gz fetchmail-763d1ace340134df6a237469bb5b76bc86cbbbec.tar.bz2 fetchmail-763d1ace340134df6a237469bb5b76bc86cbbbec.zip |
improved ETRN handling.
svn path=/trunk/; revision=1358
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | driver.c | 3 | ||||
-rw-r--r-- | env.c | 18 | ||||
-rw-r--r-- | etrn.c | 135 | ||||
-rw-r--r-- | fetchmail.c | 4 | ||||
-rw-r--r-- | fetchmail.h | 9 | ||||
-rw-r--r-- | fetchmail.man | 3 | ||||
-rw-r--r-- | rcfile_y.y | 4 |
8 files changed, 80 insertions, 97 deletions
@@ -16,6 +16,7 @@ fetchmail-4.2.2 () * Re-enable --limit under IMAP (bug introduced in 4.2.0). * Autoconfigure root-mode PID-file directory to /etc if no /var/run. +* ETRN mode no longer tries to flush queue for "localhost". There are 285 people on the fetchmail-friends list. @@ -1800,6 +1800,9 @@ const struct method *proto; /* protocol method table */ case PS_SMTP: msg = "SMTP transaction"; break; + case PS_DNS: + msg = "DNS lookup"; + break; case PS_UNDEFINED: error(0, 0, "undefined"); break; @@ -16,6 +16,9 @@ #include <pwd.h> #include <string.h> #include <ctype.h> +#ifdef HAVE_GETHOSTBYNAME +#include <netdb.h> +#endif /* HAVE_GETHOSTBYNAME */ extern char *getenv(); /* needed on sysV68 R3V7.1. */ @@ -60,6 +63,21 @@ void envquery(int argc, char **argv) fprintf(stderr, "%s: can't determine your host!", program_name); exit(PS_IOERR); } +#ifdef HAVE_GETHOSTBYNAME + { + struct hostent *hp; + + /* in case we got a basename (as we do in Linux) make a FQDN of it */ + hp = gethostbyname(tmpbuf); + if (hp == (struct hostent *) NULL) + { + /* exit with error message */ + fprintf(stderr, "gethostbyname failed for %s", tmpbuf); + exit(PS_DNS); + } + strcpy(tmpbuf, hp->h_name); + } +#endif /* HAVE_GETHOSTBYNAME */ fetchmailhost = xstrdup(tmpbuf); #define RCFILE_NAME ".fetchmailrc" @@ -30,10 +30,9 @@ static int etrn_getrange(int sock, struct query *ctl, char *id, int *countp, int *newp) /* send ETRN and interpret the response */ { - int ok, opts, qdone = 0; + int ok, opts; char buf [POPBUFSIZE+1], hname[256]; - const char *qname; struct idlist *qnp; /* pointer to Q names */ struct hostent *hp; @@ -52,98 +51,56 @@ static int etrn_getrange(int sock, struct query *ctl, char *id, int *countp, *countp = *newp = -1; /* make sure we don't enter the fetch loop */ - /*** This is a sort of horrible HACK because the ETRN protocol - *** does not fit very well into the mailbox concept used in - *** this program (IMHO). The last element of ctl->smtphunt - *** turned out to be the host being queried (i.e., the smtp server). - *** for that reason the rather "funny" condition in the for loop. - *** Isn't it sort of unreasonable to add the server to the ETRN - *** hunt list? (Concerning ETRN I'm sure! In case I want a Q-run of - *** my SMTP-server I can always specify -Smyserver, and this is only - *** resonable if I start sendmail without -qtime and in Q-only mode.) - *** - *** -- 1997-06-22 Guenther Leber - ***/ - /* do it for all queues in the smtphunt list except the last one - which is the SMTP-server itself */ - for (qnp = ctl->smtphunt; ( (qnp != (struct idlist *) NULL) && - (qnp->next != (struct idlist *) NULL) ) || (qdone == 0); - qnp = qnp->next, qdone++) - { - - /* extract name of Q */ - if ( (qnp != (struct idlist *) NULL) && - (qnp->next != (struct idlist *) NULL) ) + /* + * Do it for all nondefault queues in the smtphunt list. + * We can tell the nondefault ones because they have a TRUE num field. + */ + for (qnp = ctl->smtphunt; qnp; qnp = qnp->next) + if (qnp->val.num) { - /* take Q-name given in smtp hunt list */ - qname = qnp->id; - } else { - assert(qdone == 0); - /*** use fully qualified host name as Q name ***/ - /* get hostname */ - if (gethostname(hname, sizeof hname) != 0) - { - /* exit with error message */ - error(0, errno, "gethostname failed: "); - return PS_UNDEFINED; - } - /* in case we got a host basename (as we do in Linux), - make a FQDN of it */ - hp = gethostbyname(hname); - if (hp == (struct hostent *) NULL) + /* ship the actual poll and get the response */ + gen_send(sock, "ETRN %s", qnp->id); + if ((ok = gen_recv(sock, buf, sizeof(buf)))) + return(ok); + + /* this switch includes all response codes described in RFC1985 */ + switch(atoi(buf)) { - /* exit with error message */ - error(0, 0, "gethostbyname failed for %s", hname); - return PS_TRANSIENT; + case 250: /* OK, queuing for node <x> started */ + error(0, 0, "Queuing for %s started", qnp->id); + break; + + case 251: /* OK, no messages waiting for node <x> */ + error(0, 0, "No messages waiting for %s", qnp->id); + return(PS_NOMAIL); + + case 252: /* OK, pending messages for node <x> started */ + case 253: /* OK, <n> pending messages for node <x> started */ + error(0, 0, "Pending messages for %s started", qnp->id); + break; + + case 458: /* Unable to queue messages for node <x> */ + error(0, -1, "Unable to queue messages for node %s",qnp->id); + return(PS_PROTOCOL); + + case 459: /* Node <x> not allowed: <reason> */ + error(0, -1, "Node %s not allowed: %s", qnp->id, buf); + return(PS_AUTHFAIL); + + case 500: /* Syntax Error */ + error(0, -1, "ETRN syntax error"); + return(PS_PROTOCOL); + + case 501: /* Syntax Error in Parameters */ + error(0, -1, "ETRN syntax error in parameters"); + return(PS_PROTOCOL); + + default: + error(0, -1, "Unknown ETRN error %d", atoi(buf)); + return(PS_PROTOCOL); } - /* here it is */ - qname = hp->h_name; } - - /* ship the actual poll and get the response */ - gen_send(sock, "ETRN %s", qname); - if ((ok = gen_recv(sock, buf, sizeof(buf)))) - return(ok); - - /* this switch includes all the response codes described in RFC1985 */ - switch(atoi(buf)) - { - case 250: /* OK, queuing for node <x> started */ - error(0, 0, "Queuing for %s started", qname); - break; - - case 251: /* OK, no messages waiting for node <x> */ - error(0, 0, "No messages waiting for %s", qname); - return(PS_NOMAIL); - - case 252: /* OK, pending messages for node <x> started */ - case 253: /* OK, <n> pending messages for node <x> started */ - error(0, 0, "Pending messages for %s started", qname); - break; - - case 458: /* Unable to queue messages for node <x> */ - error(0, -1, "Unable to queue messages for node %s", qname); - return(PS_PROTOCOL); - - case 459: /* Node <x> not allowed: <reason> */ - error(0, -1, "Node %s not allowed: %s", qname, buf); - return(PS_AUTHFAIL); - - case 500: /* Syntax Error */ - error(0, -1, "ETRN syntax error"); - return(PS_PROTOCOL); - - case 501: /* Syntax Error in Parameters */ - error(0, -1, "ETRN syntax error in parameters"); - return(PS_PROTOCOL); - - default: - error(0, -1, "Unknown ETRN error %d", atoi(buf)); - return(PS_PROTOCOL); - } - } - return(0); } diff --git a/fetchmail.c b/fetchmail.c index fea23f37..883a1b8e 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -529,8 +529,8 @@ 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, -1, "localhost"); + save_str(&def_opts.smtphunt, TRUE, fetchmailhost); + save_str(&def_opts.smtphunt, FALSE, "localhost"); /* this builds the host list */ if (prc_parse_file(rcfile, !versioninfo) != 0) diff --git a/fetchmail.h b/fetchmail.h index fb2f085e..9b1695e7 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -39,10 +39,11 @@ #define PS_EXCLUDE 8 /* client-side exclusion error */ #define PS_LOCKBUSY 9 /* server responded lock busy */ #define PS_SMTP 10 /* SMTP error */ -#define PS_UNDEFINED 11 /* something I hadn't thought of */ -#define PS_TRANSIENT 12 /* transient failure (internal use) */ -#define PS_REFUSED 13 /* mail refused (internal use) */ -#define PS_RETAINED 24 /* message retained (internal use) */ +#define PS_DNS 11 /* fatal DNS error */ +#define PS_UNDEFINED 12 /* something I hadn't thought of */ +#define PS_TRANSIENT 13 /* transient failure (internal use) */ +#define PS_REFUSED 14 /* mail refused (internal use) */ +#define PS_RETAINED 15 /* message retained (internal use) */ /* output noise level */ #define O_SILENT 0 /* mute, max squelch, etc. */ diff --git a/fetchmail.man b/fetchmail.man index 28275407..c627fdce 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -1278,6 +1278,9 @@ The .I fetchmail. run failed while trying to do an SMTP port open or transaction. .IP 11 +Fatal DNS error. Fetchmail encountered an error while performing +a DNS lookup at startup and could not proceed. +.IP 11 Internal error. You should see a message on standard error with details. .PP @@ -191,8 +191,8 @@ folder_list : STRING {save_str(¤t.mailboxes,-1,$1);} | folder_list STRING {save_str(¤t.mailboxes,-1,$2);} ; -smtp_list : STRING {save_str(¤t.smtphunt, -1, $1);} - | smtp_list STRING {save_str(¤t.smtphunt, -1, $2);} +smtp_list : STRING {save_str(¤t.smtphunt, TRUE,$1);} + | smtp_list STRING {save_str(¤t.smtphunt, TRUE,$2);} ; user_option : TO localnames HERE |