freebsd-dev/eBones/krb/get_krbrlm.c
Geoff Rehmet 60643d379b Initial import of eBones.
(Including all changes for FreeBSD - importing the original eBones distribution
would be too complex at this stage, since I don't have access to Piero's 
CVS.)
(If you want to include eBones in your system, don't forget to include
MAKE_EBONES in /etc/make.conf.)
(This stuff is now also suppable from braae.ru.ac.za.)

Bones originally from MIT SIPB.
Original port to FreeBSD 1.x  by Piero Serini.
Moved to FreeBSD 2.0 by Doug Rabson and Geoff Rehmet.
Nice bug fixes from Doug Rabson.
1994-09-30 14:50:09 +00:00

60 lines
1.5 KiB
C

/*
* Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
* of Technology.
* For copying and distribution information, please see the file
* <Copyright.MIT>.
*
* from: get_krbrlm.c,v 4.8 89/01/22 20:02:54 rfrench Exp $
* $Id: get_krbrlm.c,v 1.2 1994/07/19 19:25:19 g89r4222 Exp $
*/
#ifndef lint
static char *rcsid =
"$Id: get_krbrlm.c,v 1.2 1994/07/19 19:25:19 g89r4222 Exp $";
#endif /* lint */
#include <stdio.h>
#include <krb.h>
#include <strings.h>
/*
* krb_get_lrealm takes a pointer to a string, and a number, n. It fills
* in the string, r, with the name of the nth realm specified on the
* first line of the kerberos config file (KRB_CONF, defined in "krb.h").
* It returns 0 (KSUCCESS) on success, and KFAILURE on failure. If the
* config file does not exist, and if n=1, a successful return will occur
* with r = KRB_REALM (also defined in "krb.h").
*
* NOTE: for archaic & compatibility reasons, this routine will only return
* valid results when n = 1.
*
* For the format of the KRB_CONF file, see comments describing the routine
* krb_get_krbhst().
*/
krb_get_lrealm(r,n)
char *r;
int n;
{
FILE *cnffile, *fopen();
if (n > 1)
return(KFAILURE); /* Temporary restriction */
if ((cnffile = fopen(KRB_CONF, "r")) == NULL) {
if (n == 1) {
(void) strcpy(r, KRB_REALM);
return(KSUCCESS);
}
else
return(KFAILURE);
}
if (fscanf(cnffile,"%s",r) != 1) {
(void) fclose(cnffile);
return(KFAILURE);
}
(void) fclose(cnffile);
return(KSUCCESS);
}