[370] in Zephyr_Bugs

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

using zephyr without kerberos, but with hesiod

daemon@ATHENA.MIT.EDU (John Sellens)
Mon Jun 8 01:04:57 1992

Date: Mon, 8 Jun 92 01:04:36 -0400
From: John Sellens <jmsellen@math.waterloo.edu>
To: bug-zephyr@MIT.EDU

We're not using kerberos here (yet), but I wanted to use zephyr.
Originally I changed src/lib/ZInitialize.c to use the fully
qualified hostname as the realm name.  It worked, but it meant
that you had to know which machine a person was on.  So, since
we have a bunch of machines that have the same userids on them,
I hit on the idea of using hesiod to provide a common "realm name"
for hosts that share the same user space.  Seems to work just
fine, I'm not sure how secure it is (probably not too).

The idea is to query hesiod with (hostname,zephyr) and if that succeeds,
use that, otherwise use the full hostname.  Since my source is fairly
old, I'm just sending the whole src/lib/ZInitialize.c file - my hesiod
hacks are marked with UWHESIOD.  Hope you find this interesting.

John Sellens
jmsellens@math.uwaterloo.ca



/* This file is part of the Project Athena Zephyr Notification System.
 * It contains source for the ZInitialize function.
 *
 *	Created by:	Robert French
 *
 *	$Source: /fsys/source6/zephyr/zephyr/src/lib/RCS/ZInitialize.c,v $
 *	$Author: jmsellens $
 *
 *	Copyright (c) 1987 by the Massachusetts Institute of Technology.
 *	For copying and distribution information, see the file
 *	"mit-copyright.h". 
 */
/* $Header: /fsys/source6/zephyr/zephyr/src/lib/RCS/ZInitialize.c,v 1.2 1992/05/13 19:30:50 jmsellens Exp jmsellens $ */

#ifndef lint
static char rcsid_ZInitialize_c[] = "$Header: /fsys/source6/zephyr/zephyr/src/lib/RCS/ZInitialize.c,v 1.2 1992/05/13 19:30:50 jmsellens Exp jmsellens $";
#endif lint

#include <zephyr/mit-copyright.h>

#include <zephyr/zephyr_internal.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/param.h>
#ifdef KERBEROS
#include "krb_err.h"
#endif
#ifdef UWHESIOD
#include <hesiod/hesiod.h>
#endif

Code_t ZInitialize()
{
    struct servent *hmserv;
    char addr[4];
#ifdef KERBEROS
    int krbval;
#endif
    
    initialize_zeph_error_table();
#ifdef KERBEROS
    initialize_krb_error_table();
#endif
    
    bzero((char *)&__HM_addr, sizeof(__HM_addr));

    __HM_addr.sin_family = AF_INET;

    /* Set up local loopback address for HostManager */
    addr[0] = 127;
    addr[1] = 0;
    addr[2] = 0;
    addr[3] = 1;

    hmserv = (struct servent *)getservbyname(HM_SVCNAME, "udp");
    if (!hmserv)
	return (ZERR_HMPORT);

    __HM_addr.sin_port = hmserv->s_port;

    bcopy(addr, (char *)&__HM_addr.sin_addr, 4);

    __HM_set = 0;

#ifdef KERBEROS    
    if ((krbval = krb_get_lrealm(__Zephyr_realm, 1)) != KSUCCESS)
	return (krbval);
#else
    {
#ifdef UWHESIOD
	char **pp;
#endif
	char hbuf[MAXHOSTNAMELEN+1];
	struct hostent *hp;
	/* assume it won't fail for a bad hbuf address - not a bad assumption */
	(void) gethostname( hbuf, sizeof(hbuf) );
#ifdef UWHESIOD
	pp = hes_resolve( hbuf, "zephyr" );
	/* use only the first one returned */
	if ( pp != NULL && *pp != NULL ) {
	    (void) strcpy(__Zephyr_realm, *pp);
	} else	/* oh well - didn't work - use hostname thing */
#endif
	{
	    hp = gethostbyname( hbuf );
	    if ( hp )
		(void) strcpy(__Zephyr_realm, hp->h_name);
	    else	/* prob. a bad idea */
		(void) strcpy(__Zephyr_realm, KRB_REALM);
	}
    }
#endif

    /* Get the sender so we can cache it */
    (void) ZGetSender();

    /* Initialize the input queue */
    __Q_Tail = NULL;
    __Q_Head = NULL;
    
    return (ZERR_NONE);
}

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