[639] in Kerberos

home help back first fref pref prev next nref lref last post

making things work under SunOS 3.x

daemon@TELECOM.MIT.EDU (Paul M. Aoki)
Mon Jan 30 20:08:12 1989

From: aoki@POSTGRES.BERKELEY.EDU (Paul M. Aoki)
To: kerberos@ATHENA.MIT.EDU


> From: aoki@faerie.berkeley.edu
> To: kerberos@athena.mit.edu
> Subject: release 1.0: random comments and questions
> 
>    I mention this only because this was the *only* code I had to
>    change in the entire system.

OK, this is now a lie.  [ I *said* I didn't have everything working,
didn't I? ]  The SunOS gethostid(2) appears to be mildly hosed, since it 
returns something other than an Internet address.  To make kadmind work, I 
just added a file lib/krb/k_gethostid.c (containing the following trivial
routine) and replaced the call to gethostid() in kadmin/kadm_ser_wrap.c with 
k_gethostid().

I am still pounding on the 4.4BSD r-commands.  I may just give up and wait
until Kevin gets back from Usenix.  [ For that matter, half of you out there 
are probably in San Diego right now, listening to the lady who used to lead
all this.  I wish someone would pay *my* way there. :-( ]  Anyway, like I said
before, if anyone else is having problems with the r-commands under SunOS, 
please let me know.

Should discussions of "how do I fix XXX" or "XXX is crocked on YYY" be moved 
to bug-kerberos@athena.mit.edu?

-- Paul

================================= cut here =================================
/*
 * $Source: /n/cloud9/usr/tmp/athena/kerberos/src/lib/krb/RCS/k_gethostid.c,v $
 * $Author: aoki $
 *
 * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 */

#ifndef lint
static char rcsid_k_gethostid_c[] =
"$Header: k_gethostid.c,v 1.2 89/01/30 16:20:49 aoki Exp $";
#endif /* lint */

#include <mit-copyright.h>

#include <netdb.h>
#include <sys/param.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#ifdef STANDTEST
#define	k_gethostname	gethostname
char	*hname = NULL;
int	krb_debug = 1;
long	k_gethostid(), gethostid();
main(ac, av)
	int	ac;
	char	*av[];
{
	if (ac > 2)	exit(1);
	if (ac == 2)	hname = av[1];
	printf("gethostid   = %#x = %s\n",
	       gethostid(), inet_ntoa(gethostid()));
	printf("k_gethostid = %#x = %s\n",
	       k_gethostid(), inet_ntoa(k_gethostid()));
}
#endif /* STANDTEST */

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64	/* from 4.3 */
#endif

#define	LOOPBACK_ADDR_STR	"127.0.0.1"

/*
 *	k_gethostid
 *
 *	Return the Internet address of the local host, or the loopback address
 *	(127.1) if the true Internet address cannot be found.
 *
 *	This routine is only necessary because the SunOS gethostid() does NOT 
 *	return the Internet address but instead returns some internal Sun PROM 
 *	code.  (Doesn't this kind of ruin the notion of a single hostid space 
 *	containing unique hosts??)
 */
long
k_gethostid()
{
#ifdef sun
	char			buf[MAXHOSTNAMELEN+1];
	struct hostent		*hp;
	struct in_addr		in, loopback;
	extern int		k_gethostname(), krb_debug;
	extern struct hostent	*gethostbyaddr();

	loopback.s_addr = inet_addr(LOOPBACK_ADDR_STR);
	if (k_gethostname(buf, MAXHOSTNAMELEN) < 0) {
		if (krb_debug)
			perror("gethostname");
		return loopback.s_addr;
	}
#ifdef STANDTEST
	if (hname) strncpy(buf, hname, MAXHOSTNAMELEN);
#endif
	if ((hp = gethostbyname(buf)) == (struct hostent *) NULL ||
	    hp->h_addr == (char *) NULL) {
		if (krb_debug)
			perror("gethostbyname");
		return loopback.s_addr;
	}
	/* probably ungood to just dereference hp->h_addr as a (u_long *) */
	bcopy(hp->h_addr, (char *) &in, sizeof(in));
	return in.s_addr;
#else /* !sun */
	extern long		gethostid();

	return gethostid();
#endif
}

home help back first fref pref prev next nref lref last post