summaryrefslogtreecommitdiff
path: root/usr.sbin/sendmail/src/domain.c
diff options
context:
space:
mode:
authorglass <glass@NetBSD.org>1994-01-31 02:38:08 +0000
committerglass <glass@NetBSD.org>1994-01-31 02:38:08 +0000
commitf1cb96b2ca44e4aa70b57abc58ffc615af6b0583 (patch)
treea6ebcdd285462a08f65dcae64a1b57567dd129ea /usr.sbin/sendmail/src/domain.c
parentf12eaca826e8750987e7055165cd38313cb63b46 (diff)
upgrade to version 8.6.5
Diffstat (limited to 'usr.sbin/sendmail/src/domain.c')
-rw-r--r--usr.sbin/sendmail/src/domain.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/usr.sbin/sendmail/src/domain.c b/usr.sbin/sendmail/src/domain.c
index 496859aaa65..ab2f7ff5c4d 100644
--- a/usr.sbin/sendmail/src/domain.c
+++ b/usr.sbin/sendmail/src/domain.c
@@ -36,9 +36,9 @@
#ifndef lint
#ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c 8.8 (Berkeley) 9/29/93 (with name server)";
+static char sccsid[] = "@(#)domain.c 8.10 (Berkeley) 12/21/93 (with name server)";
#else
-static char sccsid[] = "@(#)domain.c 8.8 (Berkeley) 9/29/93 (without name server)";
+static char sccsid[] = "@(#)domain.c 8.10 (Berkeley) 12/21/93 (without name server)";
#endif
#endif /* not lint */
@@ -158,6 +158,12 @@ getmxrr(host, mxhosts, droplocalhost, rcode)
case HOST_NOT_FOUND:
/* the host just doesn't exist */
*rcode = EX_NOHOST;
+
+ if (!UseNameServer)
+ {
+ /* might exist in /etc/hosts */
+ goto punt;
+ }
break;
case TRY_AGAIN:
@@ -419,8 +425,10 @@ getcanonname(host, hbsize, trymx)
bool gotmx;
int qtype;
int loopcnt;
+ char *xp;
char nbuf[MAX(PACKETSZ, MAXDNAME*2+2)];
char *searchlist[MAXDNSRCH+2];
+ extern char *gethostalias();
if (tTd(8, 2))
printf("getcanonname(%s)\n", host);
@@ -444,6 +452,20 @@ cnameloop:
if (*cp == '.')
n++;
+ if (n == 0 && (xp = gethostalias(host)) != NULL)
+ {
+ if (loopcnt++ > MAXCNAMEDEPTH)
+ {
+ syserr("loop in ${HOSTALIASES} file");
+ }
+ else
+ {
+ strncpy(host, xp, hbsize);
+ host[hbsize - 1] = '\0';
+ goto cnameloop;
+ }
+ }
+
dp = searchlist;
if (n > 0)
*dp++ = "";
@@ -637,6 +659,54 @@ cnameloop:
return TRUE;
}
+
+char *
+gethostalias(host)
+ char *host;
+{
+ char *fname;
+ FILE *fp;
+ register char *p;
+ char buf[MAXLINE];
+ static char hbuf[MAXDNAME];
+
+ fname = getenv("HOSTALIASES");
+ if (fname == NULL || (fp = fopen(fname, "r")) == NULL)
+ return NULL;
+ while (fgets(buf, sizeof buf, fp) != NULL)
+ {
+ for (p = buf; p != '\0' && !(isascii(*p) && isspace(*p)); p++)
+ continue;
+ if (*p == 0)
+ {
+ /* syntax error */
+ continue;
+ }
+ *p++ = '\0';
+ if (strcasecmp(buf, host) == 0)
+ break;
+ }
+
+ if (feof(fp))
+ {
+ /* no match */
+ fclose(fp);
+ return NULL;
+ }
+
+ /* got a match; extract the equivalent name */
+ while (*p != '\0' && isascii(*p) && isspace(*p))
+ p++;
+ host = p;
+ while (*p != '\0' && !(isascii(*p) && isspace(*p)))
+ p++;
+ *p = '\0';
+ strncpy(hbuf, host, sizeof hbuf - 1);
+ hbuf[sizeof hbuf - 1] = '\0';
+ return hbuf;
+}
+
+
#else /* not NAMED_BIND */
#include <netdb.h>