]> Pileus Git - ~andy/fetchmail/commitdiff
Suffix matching in akas.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 13 Mar 2000 19:48:24 +0000 (19:48 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 13 Mar 2000 19:48:24 +0000 (19:48 -0000)
svn path=/trunk/; revision=2817

NEWS
checkalias.c

diff --git a/NEWS b/NEWS
index 663e01df6185ec2e43d2a61ec5929b8565d594be..c82f456b4bc26ac44f12e22e6271cf5c19ba569d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@
 * Configure now supports SOCKS5, thanks to Alan Schmitt.
 * Fix a minor bug in preauthenticated IMAP, thanks to Urban Boquist 
   <boquist@crt.se>.
+* Try to support suffix matching in aka lists.
 
 fetchmail-5.3.2 (Mon Mar  6 21:41:23 EST 2000), 18695 lines:
 
index d3d1cb07b18bde7152697ae67028298089cd9b24..7b377eb22b645734a4da1326d33cff5abab001f4 100644 (file)
@@ -90,6 +90,8 @@ int is_host_alias(const char *name, struct query *ctl)
 {
     struct hostent     *he,*he_st;
     struct mxentry     *mxp, *mxrecords;
+    struct idlist      *idl;
+    int                        namelen;
 
     struct hostdata *lead_server = 
        ctl->server.lead_server ? ctl->server.lead_server : &ctl->server;
@@ -118,6 +120,29 @@ int is_host_alias(const char *name, struct query *ctl)
     else if (!ctl->server.dns)
        return(FALSE);
 
+    /*
+     * Now check for a suffix match on the akalist.  The theory here is
+     * that if the user says `aka netaxs.com', we actually want to match
+     * foo.netaxs.com and bar.netaxs.com.
+     */
+    namelen = strlen(name);
+    for (idl = lead_server->akalist; idl; idl = idl->next)
+    {
+       char    *ep;
+
+       /*
+        * Test is <= here because str_in_list() should have caught the
+        * equal-length case above.  Doing it this way guarantees that
+        * ep[-1] is a valid reference.
+        */
+       if (strlen(idl->id) <= namelen)
+           break;
+       ep = idl->id + (strlen(idl->id) - namelen);
+       /* a suffix led by . must match */
+       if (ep[-1] == '.' && !strcmp(ep, name))
+           return(TRUE);
+    }
+
 #ifndef HAVE_RES_SEARCH
     return(FALSE);
 #else
@@ -130,7 +155,7 @@ int is_host_alias(const char *name, struct query *ctl)
      * delivering the current message or anything else from the
      * current server until it's back up.
      */
-    else if ((he = gethostbyname(name)) != (struct hostent *)NULL)
+    if ((he = gethostbyname(name)) != (struct hostent *)NULL)
     {
        if (strcasecmp(ctl->server.truename, he->h_name) == 0)
            goto match;
@@ -146,6 +171,7 @@ int is_host_alias(const char *name, struct query *ctl)
            }
            if (outlevel >= O_DEBUG)
                report(stdout, _("No, their IP addresses don't match\n"));
+           return(FALSE);
        }
        else
            return(FALSE);