diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-07-24 20:56:44 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-07-24 20:56:44 +0000 |
commit | 10af4f205182e3acd6654d4997e2351e7860849a (patch) | |
tree | 5e7560b2a2f555b6a9bbfa861ff13ef18796b70b | |
parent | 5a4181c31df9e925f3e6c0b978bf54e66629ee52 (diff) | |
download | fetchmail-10af4f205182e3acd6654d4997e2351e7860849a.tar.gz fetchmail-10af4f205182e3acd6654d4997e2351e7860849a.tar.bz2 fetchmail-10af4f205182e3acd6654d4997e2351e7860849a.zip |
Added the via option.
svn path=/trunk/; revision=1179
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | driver.c | 79 | ||||
-rw-r--r-- | fetchmail-FAQ.html | 6 | ||||
-rw-r--r-- | fetchmail.c | 11 | ||||
-rw-r--r-- | fetchmail.h | 1 | ||||
-rw-r--r-- | fetchmail.man | 24 | ||||
-rw-r--r-- | rcfile_l.l | 1 | ||||
-rw-r--r-- | rcfile_y.y | 5 | ||||
-rw-r--r-- | sample.rcfile | 5 |
9 files changed, 107 insertions, 26 deletions
@@ -17,6 +17,7 @@ ------------------------------------------------------------------------------ fetchmail 4.0.3 () * Replace vsprintf with vnsprintf to avoid buffer-overrun screws. +* Added via option to make ssh configuration cleaner. There are 257 people on the fetchmail-friends list. @@ -114,23 +114,32 @@ static int is_host_alias(const char *name, struct query *ctl) ctl->server.lead_server ? ctl->server.lead_server : &ctl->server; /* - * The first two checks are optimizations that will catch a good - * many cases. (1) check against the hostname the user - * specified. Odds are good this will either be the mailserver's - * FQDN or a suffix of it with the mailserver's domain's default - * host name omitted. Then check the rest of the `also known as' + * The first three checks are optimizations that will catch a good + * many cases. + * + * (1) check against the poll name the user specified. Odds are + * good this will either be the mailserver's FQDN or a suffix of + * it with the mailserver's domain's default host name omitted. + * + * (2) Check the `via' or true host name if present, just in case + * the poll name is a label for one of a couple of different + * configurations and the real server name is here. + * + * (3) Then check the rest of the `also known as' * cache accumulated by previous DNS checks. This cache is primed * by the aka list option. * - * (2) check against the mailserver's FQDN, in case + * (4) Finally check against the mailserver's FQDN, in case * it's not the same as the declared hostname. * - * Either of these on a mail address is definitive. Only if the - * name doesn't match either is it time to call the bind library. + * Any of these on a mail address is definitive. Only if the + * name doesn't match any is it time to call the bind library. * If this happens odds are good we're looking at an MX name. */ if (str_in_list(&lead_server->names, name)) return(TRUE); + else if (ctl->server.via && strcmp(name, ctl->server.via) == 0) + return(TRUE); else if (strcmp(name, ctl->server.canonical_name) == 0) return(TRUE); else if (!ctl->server.dns) @@ -391,11 +400,48 @@ int smtp_open(struct query *ctl) /* if no socket to this host is already set up, try to open ESMTP */ if (ctl->smtp_socket == -1) { +#ifndef HAVE_RES_SEARCH + char *fakename; +#endif /* HAVE_RES_SEARCH */ + if ((ctl->smtp_socket = SockOpen(idp->id,SMTP_PORT)) == -1) continue; - else if (SMTP_ok(ctl->smtp_socket) != SM_OK + +#ifndef HAVE_RES_SEARCH + /* + * How we compute the fake client name to pass to the + * listener doesn't affect behavior on RFC1123- violating + * listener that check for name match; we're going to lose + * on those anyway because we can never give them a name + * that matches the local machine fetchmail is running on. + * What it will affect is the listener's logging. + * + * If we have the mailserver's canonical FQDN that is clearly + * the right thing to log. If we don't life is more complicated. + * The problem is there are two clashing cases: + * + * (1) The poll name is a label. In that case we want the + * log to show the via or true mailserver 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. + */ + if (ctrl->server.via && strcmp(ctrl->server.via, "localhost")) + fakename = ctrl->server.via; + else + fakename = ctrl->server->names.id; +#endif /* HAVE_RES_SEARCH */ + + if (SMTP_ok(ctl->smtp_socket) != SM_OK || SMTP_ehlo(ctl->smtp_socket, - ctl->server.names->id, +#ifdef HAVE_RES_SEARCH + ctl->server.canonical_name, +#else + fakename, +#endif /* HAVE_RES_SEARCH */ &ctl->server.esmtp_options) != SM_OK) { /* @@ -418,7 +464,13 @@ int smtp_open(struct query *ctl) if ((ctl->smtp_socket = SockOpen(idp->id,SMTP_PORT)) == -1) continue; else if (SMTP_ok(ctl->smtp_socket) != SM_OK - || SMTP_helo(ctl->smtp_socket, ctl->server.names->id) != SM_OK) + || SMTP_helo(ctl->smtp_socket, +#ifdef HAVE_RES_SEARCH + ctl->server.canonical_name +#else + fakename +#endif /* HAVE_RES_SEARCH */ + ) != SM_OK) { close(ctl->smtp_socket); ctl->smtp_socket = -1; @@ -1242,7 +1294,7 @@ const struct method *proto; /* protocol method table */ } else { - char buf [POPBUFSIZE+1], *sp; + char buf [POPBUFSIZE+1], *sp, *realhost; int *msgsizes, len, num, count, new, deletions = 0; int port, fetches; struct idlist *idp; @@ -1258,7 +1310,8 @@ const struct method *proto; /* protocol method table */ /* open a socket to the mail server */ port = ctl->server.port ? ctl->server.port : protocol->port; - if ((sock = SockOpen(ctl->server.names->id, port)) == -1) + realhost = ctl->server.via ? ctl->server.via : ctl->server.names->id; + if ((sock = SockOpen(realhost, port)) == -1) { #ifndef EHOSTUNREACH #define EHOSTUNREACH (-1) diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html index bbf1d34c..d2788233 100644 --- a/fetchmail-FAQ.html +++ b/fetchmail-FAQ.html @@ -480,14 +480,14 @@ but only supports one user at a time.<P> First, a lightly edited version of a recipe from Masafumi NAKANE:<p> 1. You must have ssh (the ssh client) on the local host and sshd (ssh -server) on the remote mail server. And, you have to configure ssh so +server) on the remote mail server. And you have to configure ssh so you can login to the sshd server host without a password. (Refer to ssh man page for several authentication methods.)<p> 2. Add something like following to your .fetchmailrc file: <p> <pre> -poll localhost port 1234 with pop3: +poll mailhost port 1234 via localhost with pop3: preconnect "ssh -f -L 1234:mailhost:110 mailhost sleep 20 </dev/null >/dev/null"; </pre> @@ -1200,7 +1200,7 @@ biff n to solve the problem system-wide.<P> -$Id: fetchmail-FAQ.html,v 1.47 1997/07/24 08:22:49 esr Exp $<p> +$Id: fetchmail-FAQ.html,v 1.48 1997/07/24 20:56:41 esr Exp $<p> <HR> <ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com"><esr@snark.thyrsus.com></A></ADDRESS> diff --git a/fetchmail.c b/fetchmail.c index 7810ec9b..dfd0c300 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -135,8 +135,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); @@ -779,10 +783,9 @@ void dump_params (struct query *ctl) printf("Options for retrieving from %s@%s:\n", ctl->remotename, visbuf(ctl->server.names->id)); - if (logfile) - printf(" Logfile is %s\n", logfile); - if (poll_interval) - printf(" Poll interval is %d seconds\n", poll_interval); + if (ctl->server.via) + printf(" Mail will be retrieved via %s\n", ctl->server.via); + if (ctl->server.interval) printf(" Poll of this server will occur every %d intervals.\n", ctl->server.interval); diff --git a/fetchmail.h b/fetchmail.h index a9775c70..24ef5ee0 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -78,6 +78,7 @@ typedef char flag; struct hostdata /* shared among all user connections to given server */ { /* rc file data */ + char *via; /* "true" server name if non-NULL */ struct idlist *names; /* server name first, then akas */ struct idlist *localdomains; /* list of pass-through domains */ int protocol; /* protocol type */ diff --git a/fetchmail.man b/fetchmail.man index e2b4ce62..792093fb 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -657,6 +657,7 @@ safely, or easily disable entries for hosts that are temporarily down.) .PP Legal server options are: + via protocol (or proto) port authenticate (or auth) @@ -704,9 +705,26 @@ The 'folder' and 'smtphost' options can take a space- or comma-separated list of names following them. .PP All options correspond to the obvious command-line arguments, except -the following: `interval', `aka', `is', `to', `dns'/`no dns', `password', -\&`preconnect', `localdomains', `stripcr'/`no stripcr' , -\&`forcecr'/`no forcecr', `pass8bits'/`no pass8bits' and `no received'. +the following: `via', `interval', `aka', `is', `to', `dns'/`no dns', +\&`password', \&`preconnect', `localdomains', `stripcr'/`no stripcr' , +\&`forcecr'/`no forcecr', `pass8bits'/`no pass8bits' and `no +received'. +.PP +The `via' option is for use with ssh, or if you want to have more +than one configuration pointing at the same site. If it is present, +the string argument will be taken as the actual DNS name of the +mailserver host to query. So, for example, you can say: + +.nf +poll mailhost.net via localhost port 1234 with pop3: + preconnect "ssh -f -L 1234:mailhost.net:110 mailhost.net sleep 20 </dev/null >/dev/null"; +.fi + +This will override the argument of poll, which can simply be a +distinct label for the configuration. The poll name will still be the +one you would give on the command line to explicitly query this host. +It will also still be used as a possible match in multidrop mode, in +case it is (as in this case) the real host name. .PP The `interval' option (which takes a numeric argument) allows you to poll a server less frequently than the basic poll interval. If you say @@ -30,6 +30,7 @@ defaults { return DEFAULTS; } server { return POLL; } poll { return POLL; } skip { return SKIP; } +via { return VIA; } aka { return AKA; } local(domains) { return LOCALDOMAINS; } proto(col)? { return PROTOCOL; } @@ -54,7 +54,7 @@ extern char * yytext; char *sval; } -%token DEFAULTS POLL SKIP AKA LOCALDOMAINS PROTOCOL +%token DEFAULTS POLL SKIP VIA AKA LOCALDOMAINS PROTOCOL %token AUTHENTICATE TIMEOUT KPOP KERBEROS4 %token ENVELOPE USERNAME PASSWORD FOLDER SMTPHOST MDA PRECONNECT LIMIT %token IS HERE THERE TO MAP WILDCARD @@ -126,6 +126,7 @@ domain_list : STRING {save_str(¤t.server.localdomains,-1,$1);} ; serv_option : AKA alias_list + | VIA STRING {current.server.via = xstrdup($2);} | LOCALDOMAINS domain_list | PROTOCOL PROTO {current.server.protocol = $2;} | PROTOCOL KPOP { @@ -398,6 +399,7 @@ static void record_current(void) /* register current parameters and append to the host list */ { #define FLAG_FORCE(fld) if (cmd_opts.fld) current.fld = cmd_opts.fld + FLAG_FORCE(server.via); FLAG_FORCE(server.protocol); FLAG_FORCE(server.port); FLAG_FORCE(server.interval); @@ -449,6 +451,7 @@ void optmerge(struct query *h2, struct query *h1) append_str_list(&h2->smtphunt, &h1->smtphunt); #define FLAG_MERGE(fld) if (!h2->fld) h2->fld = h1->fld + FLAG_MERGE(server.via); FLAG_MERGE(server.protocol); FLAG_MERGE(server.port); FLAG_MERGE(server.interval); diff --git a/sample.rcfile b/sample.rcfile index 9f0fa62b..fd648fc6 100644 --- a/sample.rcfile +++ b/sample.rcfile @@ -19,8 +19,9 @@ # arguments in this file, the command-line arguments take precedence. # # Legal keywords are -# poll -- must be followed by a mailserver name -# skip -- must be followed by a mailserver name +# poll -- must be followed by a mailserver name or label +# skip -- must be followed by a mailserver name or label +# via -- must be followed by true name of host to poll # interval -- must be followed by an interval skip count # protocol (or proto) -- must be followed by a protocol ID # uidl |