[6748] in Kerberos

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

krb4 random key patch for HPs

daemon@ATHENA.MIT.EDU (Dean Guenther - Systems Staff)
Fri Feb 23 12:04:16 1996

To: kerberos@MIT.EDU
Date: Fri, 23 Feb 1996 15:25:48 GMT
From: guenther@unicorn.it.wsu.edu (Dean Guenther - Systems Staff)


Hi, I've just finished updating krb4 on a Hewlett Packard KDC. There was
a problem in that des_init_random_number_generator in         
lib/des/new_rnd_key.c makes a call to gethostid. Under HPUX 9.x and
earlier this results in a bad system call. Many thanks to Tai Jin at HP for
providing a fix for HPs! In new_rnd_key.c immediately after the:

#ifndef BSDUNIX
  you lose...   (aka, you get to implement an analog of this for your
                 system...)
#else


you should provide the following:

---------------------- cut --------------------------------------------
#ifdef hpux
/*
 * gethostid() returns the first available (non-loopback) IP address
 * or zero if no address
 */
#ifdef __STDC__
#define _HPUX_SOURCE
#endif /*__STDC__*/

#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <netinet/in.h>

#ifdef __STDC__
#define VOID void
#else
#define VOID
#endif /*__STDC__*/

unsigned long gethostid(VOID)
{
  struct ifconf ifc;
  struct ifreq ifreq, *ifr;
  unsigned long addr = 0;
  int s, n;
  char buf[1024];

  if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
    return -1;

  ifc.ifc_len = sizeof(buf);
  ifc.ifc_buf = buf;

  if (ioctl(s, SIOCGIFCONF, &ifc) == -1)
    return -1;

  n = ifc.ifc_len / sizeof(struct ifreq);

  for (ifr = ifc.ifc_req; n > 0; --n, ifr++) {
    if (ifr->ifr_addr.sa_family != AF_INET)
      continue;

    ifreq = *ifr;
#if defined(IFF_LOOPBACK)
#define LOOPBACK IFF_LOOPBACK
#else
# if defined(IFF_LOCAL_LOOPBACK)
# define LOOPBACK IFF_LOCAL_LOOPBACK
#endif
#endif
    if (ioctl(s, SIOCGIFFLAGS, &ifreq) == 0) {
      if (ifreq.ifr_flags & LOOPBACK)
        continue;
    }

    if (ioctl(s, SIOCGIFADDR, &ifreq) == 0) {
      addr = ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
      break;
    }
  }

  close(s);
  return addr;
} /* gethostid */

#endif /* if hpux */
--------------------------- paste -------------------------------


and then inside of des_init_random_number_generator change the 
definition of gethostid to this:

#ifndef hpux
    int32 gethostid();
#endif

  	-- Dean





-- 
Dean Guenther          		Internet: guenther@wsu.edu
Washington State University     AT&T:     509 335-0433
Pullman, WA. 99164-1222         fax:      509 335-0540

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