aboutsummaryrefslogtreecommitdiffstats
path: root/checkalias.c
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 /checkalias.c
parent074d0f372bb1300e135a4884c500ae719b8706d7 (diff)
downloadfetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.tar.gz
fetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.tar.bz2
fetchmail-7576f100c88e3c2ecdd757da18de08daadbb67a3.zip
Suffix matching in akas.
svn path=/trunk/; revision=2817
Diffstat (limited to 'checkalias.c')
-rw-r--r--checkalias.c28
1 files changed, 27 insertions, 1 deletions
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);