3 * hosts.c -- find out the official name of a host
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 * In the SendMail world, we really don't know what the valid
12 * hosts are. We could poke around in the sendmail.cf file, but
13 * that still isn't a guarantee. As a result, we'll say that
14 * everything is a valid host, and let SendMail worry about it.
23 OfficialName (char *name)
26 char *q, site[BUFSIZ];
27 struct addrinfo hints, *res;
29 static char buffer[BUFSIZ];
31 for (p = name, q = site; *p && (q - site < sizeof(site) - 1); p++, q++)
32 *q = isupper (*p) ? tolower (*p) : *p;
36 if (!mh_strcasecmp (LocalName(), site))
39 memset(&hints, 0, sizeof(hints));
40 hints.ai_flags = AI_CANONNAME;
41 hints.ai_family = PF_UNSPEC;
43 if (getaddrinfo(q, NULL, &hints, &res) == 0) {
44 strncpy (buffer, res->ai_canonname, sizeof(buffer));
45 buffer[sizeof(buffer) - 1] = '\0';
50 strncpy (buffer, site, sizeof(buffer));