Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site rochester.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!floyd!cmcl2!seismo!rochester!bukys
From: bukys@rochester.UUCP (Liudvikas Bukys)
Newsgroups: net.bugs.4bsd
Subject: 4.2 sendmail myhostname fixes
Message-ID: <7288@rochester.UUCP>
Date: Wed, 6-Jun-84 18:15:05 EDT
Article-I.D.: rochester.7288
Posted: Wed Jun  6 18:15:05 1984
Date-Received: Thu, 7-Jun-84 19:44:58 EDT
Organization: U. of Rochester, CS Dept.
Lines: 49

Index:	usr.lib/sendmail/src/daemon.c 4.2 Fix

Description:
	The myhostname() generated if DAEMON is defined has two problems:
	(1) it calls gethostname() incorrectly (a holdover from pre-4.1a?);
	(2) it assumes that hp->h_name is the same as `hostname`.

Repeat-By:
	Go to a machine for which `hostname` is not the first name in
	the /etc/hosts line.  For example, on ur-seneca, whose
	/etc/hosts line looks like
		192.5.37.83	ur-seneca seneca sen
	`hostname` is "seneca", not "ur-seneca".
	Without this fix, sendmail's $w is (seneca) and $=w is (seneca sen).
	With this fix, $w is (ur-seneca) and $=w is (ur-seneca seneca sen).

Fix:
------- OLD CODE ------- ------- ------- ------- ------- ------- ------- -------
{
	extern struct hostent *gethostbyname();
	struct hostent *hp;
	auto int i = size;

	gethostname(hostbuf, &i);
	hp = gethostbyname(hostbuf);
	if (hp != NULL)
		return (hp->h_aliases);
	else
		return (NULL);
}
------- NEW CODE ------- ------- ------- ------- ------- ------- ------- -------
{
	extern struct hostent *gethostbyname();
	struct hostent *hp;

	gethostname(hostbuf, size);
	hp = gethostbyname(hostbuf);
	if (hp != NULL) {
		strncpy(hostbuf, hp->h_name, size);
		return (hp->h_aliases);
	} else
		return (NULL);
}
------- -------- ------- ------- ------- ------- ------- ------- ------- -------

Brought to you by:
	Liudvikas Bukys
	rochester!bukys (uucp) via allegra, decvax, seismo
	bukys@rochester (arpa)