SCCS-vsn: usr.sbin/sendmail/src/domain.c 5.29
SCCS-vsn: usr.sbin/sendmail/src/daemon.c 5.39
#ifndef lint
#ifdef DAEMON
#ifndef lint
#ifdef DAEMON
-static char sccsid[] = "@(#)daemon.c 5.38 (Berkeley) %G% (with daemon mode)";
+static char sccsid[] = "@(#)daemon.c 5.39 (Berkeley) %G% (with daemon mode)";
-static char sccsid[] = "@(#)daemon.c 5.38 (Berkeley) %G% (without daemon mode)";
+static char sccsid[] = "@(#)daemon.c 5.39 (Berkeley) %G% (without daemon mode)";
#endif
#endif /* not lint */
#endif
#endif /* not lint */
* MAPHOSTNAME -- turn a hostname into canonical form
*
* Parameters:
* MAPHOSTNAME -- turn a hostname into canonical form
*
* Parameters:
* hbsize -- the size of hbuf.
*
* Returns:
* hbsize -- the size of hbuf.
*
* Returns:
+ * TRUE if the host name was mapped.
+ * FALSE otherwise.
*
* Side Effects:
* Looks up the host specified in hbuf. If it is not
*
* Side Effects:
* Looks up the host specified in hbuf. If it is not
* the canonical name. If the name is unknown, or it
* is already the canonical name, leave it unchanged.
*/
* the canonical name. If the name is unknown, or it
* is already the canonical name, leave it unchanged.
*/
maphostname(hbuf, hbsize)
char *hbuf;
int hbsize;
maphostname(hbuf, hbsize)
char *hbuf;
int hbsize;
* strip the brackets and to preserve hbuf if address is
* unknown.
*/
* strip the brackets and to preserve hbuf if address is
* unknown.
*/
- if (*hbuf != '[') {
- getcanonname(hbuf, hbsize);
- return;
- }
+ if (*hbuf != '[')
+ return (getcanonname(hbuf, hbsize));
if ((cp = index(strcpy(ptr, hbuf), ']')) == NULL)
if ((cp = index(strcpy(ptr, hbuf), ']')) == NULL)
*cp = '\0';
in_addr = inet_addr(&ptr[1]);
hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
if (hp == NULL)
*cp = '\0';
in_addr = inet_addr(&ptr[1]);
hp = gethostbyaddr((char *)&in_addr, sizeof(struct in_addr), AF_INET);
if (hp == NULL)
if (strlen(hp->h_name) >= hbsize)
hp->h_name[hbsize - 1] = '\0';
(void)strcpy(hbuf, hp->h_name);
if (strlen(hp->h_name) >= hbsize)
hp->h_name[hbsize - 1] = '\0';
(void)strcpy(hbuf, hp->h_name);
** hbsize -- the size of hbuf.
**
** Returns:
** hbsize -- the size of hbuf.
**
** Returns:
+** TRUE if the hostname was mapped.
+** FALSE otherwise.
**
** Side Effects:
** Looks up the host specified in hbuf. If it is not
**
** Side Effects:
** Looks up the host specified in hbuf. If it is not
maphostname(hbuf, hbsize)
char *hbuf;
int hbsize;
{
maphostname(hbuf, hbsize)
char *hbuf;
int hbsize;
{
#ifndef lint
#ifdef NAMED_BIND
#ifndef lint
#ifdef NAMED_BIND
-static char sccsid[] = "@(#)domain.c 5.28 (Berkeley) %G% (with name server)";
+static char sccsid[] = "@(#)domain.c 5.29 (Berkeley) %G% (with name server)";
-static char sccsid[] = "@(#)domain.c 5.28 (Berkeley) %G% (without name server)";
+static char sccsid[] = "@(#)domain.c 5.29 (Berkeley) %G% (without name server)";
#endif
#endif /* not lint */
#endif
#endif /* not lint */
getcanonname(host, hbsize)
char *host;
int hbsize;
getcanonname(host, hbsize)
char *host;
int hbsize;
querybuf answer;
u_short type;
int first, ancount, qdcount, loopcnt;
querybuf answer;
u_short type;
int first, ancount, qdcount, loopcnt;
char nbuf[PACKETSZ];
loopcnt = 0;
char nbuf[PACKETSZ];
loopcnt = 0;
if (tTd(8, 1))
printf("getcanonname: res_search failed (errno=%d, h_errno=%d)\n",
errno, h_errno);
if (tTd(8, 1))
printf("getcanonname: res_search failed (errno=%d, h_errno=%d)\n",
errno, h_errno);
}
/* find first satisfactory answer */
}
/* find first satisfactory answer */
if (ancount == 0) {
if (tTd(8, 1))
printf("rcode = %d, ancount=%d\n", hp->rcode, ancount);
if (ancount == 0) {
if (tTd(8, 1))
printf("rcode = %d, ancount=%d\n", hp->rcode, ancount);
}
cp = (u_char *)&answer + sizeof(HEADER);
eom = (u_char *)&answer + n;
for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
if ((n = dn_skipname(cp, eom)) < 0)
}
cp = (u_char *)&answer + sizeof(HEADER);
eom = (u_char *)&answer + n;
for (qdcount = ntohs(hp->qdcount); qdcount--; cp += n + QFIXEDSZ)
if ((n = dn_skipname(cp, eom)) < 0)
/*
* just in case someone puts a CNAME record after another record,
/*
* just in case someone puts a CNAME record after another record,
if ((n = dn_expand((u_char *)&answer,
eom, cp, (u_char *)nbuf, sizeof(nbuf))) < 0)
break;
if ((n = dn_expand((u_char *)&answer,
eom, cp, (u_char *)nbuf, sizeof(nbuf))) < 0)
break;
if (first) { /* XXX */
(void)strncpy(host, nbuf, hbsize);
host[hbsize - 1] = '\0';
if (first) { /* XXX */
(void)strncpy(host, nbuf, hbsize);
host[hbsize - 1] = '\0';
}
#else /* not NAMED_BIND */
#include <netdb.h>
}
#else /* not NAMED_BIND */
#include <netdb.h>
getcanonname(host, hbsize)
char *host;
int hbsize;
getcanonname(host, hbsize)
char *host;
int hbsize;
hp = gethostbyname(host);
if (hp == NULL)
hp = gethostbyname(host);
if (hp == NULL)
if (strlen(hp->h_name) >= hbsize)
if (strlen(hp->h_name) >= hbsize)
(void) strcpy(host, hp->h_name);
(void) strcpy(host, hp->h_name);
}
#endif /* not NAMED_BIND */
}
#endif /* not NAMED_BIND */