bos-mrafs-support-20010212
[openafs.git] / src / util / get_krbrlm.c
1 /*
2  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute of Technology.
3  * For copying and distribution information, please see the file <mit-copyright.h>.
4  */
5
6 #include <afs/param.h>
7 #include <stdio.h>
8 #include "afsutil.h"
9
10 /*
11  * Specialized version of the kerberos krb_get_lrealm function.
12  * krb_get_lrealm takes a pointer to a string, and a number, n.  It fills
13  * in the string, r, with the name of the nth realm specified on the
14  * first line of the kerberos config file (KRB_CONF, defined in "krb.h").
15  * It returns 0 (KSUCCESS) on success, and KFAILURE on failure. 
16  *
17  * On the kerberos version if the config file does not exist, and if n=1, a 
18  * successful return will occur with r = KRB_REALM (also defined in "krb.h").
19  *
20  */
21 #define KSUCCESS        0
22 #define KFAILURE        -1
23
24 afs_krb_get_lrealm(r,n)
25     char *r;
26     int n;
27 {
28     FILE *cnffile, *fopen();
29
30     if (n > 1)
31         return(KFAILURE);  /* Temporary restriction */
32
33     if ((cnffile = fopen(AFSDIR_SERVER_KCONF_FILEPATH, "r")) == NULL) {
34         return(KFAILURE);
35     }
36     if (fscanf(cnffile,"%s",r) != 1) {
37         (void) fclose(cnffile);
38         return(KFAILURE);
39     }
40     (void) fclose(cnffile);
41     return(KSUCCESS);
42 }