Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!charon!piet From: piet@cwi.nl (Piet Beertema) Newsgroups: comp.mail.sendmail Subject: Re: Local Configuration Error Message-ID: <2223@charon.cwi.nl> Date: 24 Sep 90 19:07:56 GMT References: <1990Sep19.002139.32095@mp.cs.niu.edu> <2199@charon.cwi.nl> <1990Sep20.182739.29113@mp.cs.niu.edu> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 60 In both cases only the local MX record is discarded (but marked) and all other MX records are stored and sorted. You must be looking at different source code to mine. In the 5.64 release from Berkeley, as soon as an MX record pointing to the local host is found its preference is recorded, and any further MX records are only stored into an array for sorting if they have a lower preference. I'm using sendmail-5.64+IDA. But here's the relevant part of the original Berkeley version: ...... while (--ancount >= 0 && cp < eom && nmx < MAXMXHOSTS) { if ((n = dn_expand((char *)&answer, eom, cp, bp, buflen)) < 0) break; ...... if (!strcasecmp(bp, localhost)) { if (seenlocal == 0 || pref < localpref) localpref = pref; seenlocal = 1; continue; } prefer[nmx] = pref; mxhosts[nmx++] = bp; n = strlen(bp) + 1; bp += n; buflen -= n; } if (nmx == 0) { punt: mxhosts[0] = strcpy(hostbuf, host); return(1); } /* sort the records */ for (i = 0; i < nmx; i++) { The !strcasecmp() matches only for the MX record pointing to the local host; that record is discarded, but marked in seenlocal. All other (previous or later) MX records are stored in mxhosts[] and sorted later on. Care is taken of multiple MX records pointing to the local host: only the one with the lowest value (highest priority) is taken into account. If the above is wrong, please tell me where it is wrong. As Brian Kantor pointed out, the match on localhost fails if for one reason or another $w has not been set to the fully qualified domain name of the local host (which can be useful if e.g. the unqualified name is the uucp name). This can easily be corrected by using `gethostbyname(localhost)->h_name' in the comparison instead of localhost itself. This is in line with how localhost is obtained elsewhere (via myhostname() which uses gethostbyname()). It is also correct in the sense that, since $w defines the local host, it by definition resides in the local domain and thus can be made fully qualified with the local domain. -- Piet Beertema, CWI, Amsterdam (piet@cwi.nl)