home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / kntoln.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-05  |  1.8 KB  |  64 lines

  1. /*
  2.  * $Source: /usr/src/kerberosIV/krb/RCS/kntoln.c,v $
  3.  * $Author: kfall $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_kntoln_c =
  14. "$Header: /usr/src/kerberosIV/krb/RCS/kntoln.c,v 4.9 90/06/25 20:56:40 kfall Exp Locker: kfall $";
  15. #endif /* lint */
  16.  
  17. #include <mit-copyright.h>
  18. #include <des.h>
  19. #include <krb.h>
  20. #include <strings.h>
  21.  
  22. /*
  23.  * krb_kntoln converts an auth name into a local name by looking up
  24.  * the auth name in the /etc/aname file.  The format of the aname
  25.  * file is:
  26.  *
  27.  * +-----+-----+-----+-----+------+----------+-------+-------+
  28.  * | anl | inl | rll | lnl | name | instance | realm | lname |
  29.  * +-----+-----+-----+-----+------+----------+-------+-------+
  30.  * | 1by | 1by | 1by | 1by | name | instance | realm | lname |
  31.  * +-----+-----+-----+-----+------+----------+-------+-------+
  32.  *
  33.  * If the /etc/aname file can not be opened it will set the
  34.  * local name to the auth name.  Thus, in this case it performs as
  35.  * the identity function.
  36.  *
  37.  * The name instance and realm are passed to krb_kntoln through
  38.  * the AUTH_DAT structure (ad).
  39.  *
  40.  * Now here's what it *really* does:
  41.  *
  42.  * Given a Kerberos name in an AUTH_DAT structure, check that the
  43.  * instance is null, and that the realm is the same as the local
  44.  * realm, and return the principal's name in "lname".  Return
  45.  * KSUCCESS if all goes well, otherwise KFAILURE.
  46.  */
  47.  
  48. krb_kntoln(ad,lname)
  49.     AUTH_DAT *ad;
  50.     char *lname;
  51. {
  52.     static char lrealm[REALM_SZ] = "";
  53.  
  54.     if (!(*lrealm) && (krb_get_lrealm(lrealm,0) == KFAILURE))
  55.         return(KFAILURE);
  56.  
  57.     if (strcmp(ad->pinst,""))
  58.         return(KFAILURE);
  59.     if (strcmp(ad->prealm,lrealm))
  60.         return(KFAILURE);
  61.     (void) strcpy(lname,ad->pname);
  62.     return(KSUCCESS);
  63. }
  64.