aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2000-03-13 19:48:24 +0000
committerEric S. Raymond <esr@thyrsus.com>2000-03-13 19:48:24 +0000
commit7576f100c88e3c2ecdd757da18de08daadbb67a3 (patch)
tree471472b7faf97cec32b8d0280e567c17c198767a
parent074d0f372bb1300e135a4884c500ae719b8706d7 (diff)
downloadfetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.tar.gz
fetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.tar.bz2
fetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.zip
Suffix matching in akas.
svn path=/trunk/; revision=2817
-rw-r--r--NEWS1
-rw-r--r--checkalias.c28
2 files changed, 28 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 663e01df..c82f456b 100644
--- 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:
diff --git a/checkalias.c b/checkalias.c
index d3d1cb07..7b377eb2 100644
--- a/checkalias.c
+++ b/checkalias.c
@@ -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);