]> Pileus Git - ~andy/fetchmail/commitdiff
Enrico Musio's IP-checkalias patch.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 29 Jun 1998 21:32:04 +0000 (21:32 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 29 Jun 1998 21:32:04 +0000 (21:32 -0000)
svn path=/trunk/; revision=1944

Makefile.in
NEWS
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
rcfile_l.l
rcfile_y.y

index 1173a8bc0fe3ec8c3e1a6d82959a0201911dfdd6..bd238c4487895a70f2f27c4235e4275fdc39650b 100644 (file)
@@ -81,7 +81,7 @@ CTAGS = ctags
 protobjs = rcfile_y.o rcfile_l.o socket.o getpass.o pop2.o pop3.o imap.o \
        etrn.o fetchmail.o env.o options.o daemon.o driver.o rfc822.o smtp.o \
        xmalloc.o uid.o mxget.o md5c.o md5ify.o rpa.o interface.o netrc.o \
-       base64.o error.o unmime.o conf.o
+       base64.o error.o unmime.o conf.o is_ip_alias.o
 
 objs = $(protobjs) $(extras) $(EXTRAOBJ)
 
@@ -93,7 +93,8 @@ srcs = $(srcdir)/socket.c $(srcdir)/getpass.c $(srcdir)/pop2.c                \
        $(srcdir)/xmalloc.c $(srcdir)/uid.c $(srcdir)/mxget.c           \
        $(srcdir)/md5c.c $(srcdir)/md5ify.c $(srcdir)/rpa.c             \
        $(srcdir)/interface.c $(srcdir)/netrc.c $(srcdir)/base64.c      \
-       $(srcdir)/error.c $(srcdir)/unmime.c $(srcdir)/conf.c
+       $(srcdir)/error.c $(srcdir)/unmime.c $(srcdir)/conf.c           \
+       $(srcdir)/is_ip_alias.c
 
 .SUFFIXES:
 .SUFFIXES: .o .c .h .y .l .ps .dvi .info .texi
diff --git a/NEWS b/NEWS
index 7f5ef2342997f439650db849a0d490c53dcbea5c..788c95e0cc82188e7470717368a5f07f25af1ad1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@
                                Release Notes:
 
 ------------------------------------------------------------------------------
+fetchmail-4.5.1 ():
+* Checkalias option from Enrico Musio <enrico.musio@spaziozerouno.it>.
+
 fetchmail-4.5.0bis (Sat Jun 20 10:55:52 EDT 1998):
 
 One-line fix for an embarrassing bug in the `gold' version; command-line
index 50e1e833557e0316f9d0dc6a977a07a95ff97d88..8bec7414ef78fae9ba4eb461f97cd54431354346 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -140,10 +140,12 @@ static int accept_count, reject_count;
 
 #define MX_RETRIES     3
 
+extern int is_ip_alias();
+
 static int is_host_alias(const char *name, struct query *ctl)
 /* determine whether name is a DNS alias of the hostname */
 {
-    struct hostent     *he;
+    struct hostent     *he,*he_st;
     struct mxentry     *mxp, *mxrecords;
 
     struct hostdata *lead_server = 
@@ -189,6 +191,19 @@ static int is_host_alias(const char *name, struct query *ctl)
     {
        if (strcasecmp(ctl->server.truename, he->h_name) == 0)
            goto match;
+        else if (((he_st = gethostbyname(ctl->server.truename)) != (struct hostent *)NULL) && ctl->server.checkalias)
+                       {
+                               if (outlevel == O_VERBOSE)
+                                       error(0, 0, "Checking if %s is really the same node as %s",ctl->server.truename,name);
+                               if (is_ip_alias(ctl->server.truename,name) == TRUE)
+                                       {
+                                       if (outlevel == O_VERBOSE)
+                                       error(0, 0, "Yes, their IP addresses match");
+                                       goto match;
+                                       }
+                               if (outlevel == O_VERBOSE)
+                                       error(0, 0, "No, their IP addresses don't match");
+                       }
        else
            return(FALSE);
     }
index a90c833b67a4fccd3b57b1da5707789cfbec1e8d..a15a5328dbf1da1fe0793ccc60cbd61208443e86 100644 (file)
@@ -733,6 +733,7 @@ static void optmerge(struct query *h2, struct query *h1, int force)
     FLAG_MERGE(server.qvirtual);
     FLAG_MERGE(server.skip);
     FLAG_MERGE(server.dns);
+    FLAG_MERGE(server.checkalias);
     FLAG_MERGE(server.uidl);
 
 #ifdef linux
@@ -893,6 +894,7 @@ static int load_params(int argc, char **argv, int optind)
            DEFAULT(ctl->mimedecode, FALSE);
            DEFAULT(ctl->server.dns, TRUE);
            DEFAULT(ctl->server.uidl, FALSE);
+           DEFAULT(ctl->server.checkalias, FALSE);
 #undef DEFAULT
 
 #if !defined(HAVE_GETHOSTBYNAME) || !defined(HAVE_RES_SEARCH)
@@ -1335,7 +1337,14 @@ void dump_params (struct runctl *runp, struct query *querylist, flag implicit)
                    {
                        printf("  DNS lookup for multidrop addresses is %sabled.\n",
                               ctl->server.dns ? "en" : "dis");
-
+                       if (ctl->server.dns)
+                       {
+                           printf("  Server aliases will be compared with multidrop addresses by ");
+                           if (ctl->server.checkalias)
+                               printf("IP address.");
+                           else
+                               printf("name.");
+                       }
                        if (ctl->server.envelope == STRING_DISABLED)
                            printf("  Envelope-address routing is disabled\n");
                        else
index e57f4c32d2851ebf6033b91f2b4ba65054e61cfc..5f9eef5a8396b6de3b114699da37e153bc524157 100644 (file)
@@ -141,6 +141,8 @@ struct hostdata             /* shared among all user connections to given server */
     flag skip;                         /* suppress poll in implicit mode? */
     flag dns;                          /* do DNS lookup on multidrop? */
     flag uidl;                         /* use RFC1725 UIDLs? */
+    flag checkalias;                  /* try to resolve aliases by comparing IPs ?*/
+
 
 #ifdef linux
     char *interface;
index 11c01026f4221d54cf83a6027773a96fc526ee25..d7a174c07788f39188358ea47fcdfef1bb474f5a 100644 (file)
@@ -867,6 +867,12 @@ T}
 no dns         \&      T{
 Disable DNS lookup for multidrop
 T}
+checkalias     \&      T{
+Do comparison by IP address for multidrop
+T}
+no checkalias  \&      T{
+Do comparison by name for multidrop (default)
+T}
 uidl           -U      T{
 Force POP3 to use client-side UIDLs
 T}
@@ -1002,6 +1008,7 @@ following them.
 .PP
 All options correspond to the obvious command-line arguments, except
 the following: `via', `interval', `aka', `is', `to', `dns'/`no dns',
+`checkalias'/`no checkalias', 
 \&`password', \&`preconnect', \&`postconnect', `localdomains',
 \&`stripcr'/`no stripcr', \&`forcecr'/`no forcecr', `pass8bits'/`no
 pass8bits' `dropstatus/no dropstatus', `mimedecode/no mimedecode',
@@ -1042,7 +1049,7 @@ headers of retrieved mail (this is `multidrop mode').  It looks for
 addresses with hostname parts that match your poll name or your `via',
 `aka' or `localdomains' options, and usually also for hostname parts
 which DNS tells it are aliases of the mailserver.  See the discussion
-of `dns', `localdomains', and `aka' for details on how matching
+of `dns', `checkalias', `localdomains', and `aka' for details on how matching
 addresses are handled.  If \fIfetchmail\fR cannot match any mailserver
 usernames or localdomain addresses, the default recipient is the
 calling user (as set by the USER or LOGNAME variable in the
@@ -1055,6 +1062,24 @@ by looking it up with DNS.  When a mailserver username is recognized
 attached to a matching hostname part, its local mapping is added to
 the list of local recipients.
 .PP
+The `checkalias' option (normally off) extends the lookups performed
+by the `dns' keyword in multidrop mode, providing a way to cope with
+remote MTAs that identify themselves using their canonical name, while
+they're polled using an alias.
+When such a server is polled, checks to extract the envelope address
+fail, and
+.IR fetchmail 
+reverts to delivery using the To/Cc/Bcc headers (See below 
+`Header vs. Envelope addresses'). 
+Specifying this option instructs
+.IR fetchmail 
+to retrieve all the IP addresses associated with both the poll name
+and the name used by the remote MTA and to do a comparison of the IP
+addresses.  This comes in handy in situations where the remote server
+undergoes frequent canonical name changes, that would otherwise
+require modifications to the rcfile.  `checkalias' has no effect if
+`no dns' is specified in the rcfile.
+.PP
 The `aka' option is for use with multidrop mailboxes.  It allows you
 to pre-declare a list of DNS aliases for a server.  This is an
 optimization hack that allows you to trade space for speed.  When
index 58fe10a0b2fd21c42d7c01b597eaba9191b28e1e..6bdff96d196ddd194766abd19e232993b9414862 100644 (file)
@@ -70,7 +70,7 @@ to            { return TO; }
 =              { return MAP; }
 "*"            { return WILDCARD; }
 
-no/[kfrsdu \t].*       { return NO;}
+no/[kfrsduc \t].*      { return NO;}
 
 keep           { return KEEP; }
 flush          { return FLUSH; }
@@ -83,6 +83,7 @@ dropstatus?   { return DROPSTATUS; }
 mimedec(ode)?   { return MIMEDECODE; }
 dns            { return DNS; }
 uidl           { return UIDL; }
+checkalias     { return CHECKALIAS; }
 
 limit          { return LIMIT; }
 
index 5c4f43b775980d6a37810df203377fcc0381ecc0..d08ef8639844f4aa7670f4fda8784e0bafcea8eb 100644 (file)
@@ -72,7 +72,7 @@ extern char * yytext;
 %token <sval>  STRING
 %token <number> NUMBER
 %token NO KEEP FLUSH FETCHALL REWRITE FORCECR STRIPCR PASS8BITS DROPSTATUS
-%token DNS SERVICE PORT UIDL INTERVAL MIMEDECODE
+%token DNS SERVICE PORT UIDL INTERVAL MIMEDECODE CHECKALIAS
 
 %%
 
@@ -143,6 +143,8 @@ serv_option : AKA alias_list
                                        }
                | UIDL                  {current.server.uidl = FLAG_TRUE;}
                | NO UIDL               {current.server.uidl  = FLAG_FALSE;}
+               | CHECKALIAS            {current.server.checkalias = FLAG_TRUE;}
+               | NO CHECKALIAS         {current.server.checkalias  = FLAG_FALSE;}
                | SERVICE STRING        {
 #if INET6
                                        current.server.service = $2;