Annotation of 43BSDReno/kerberosIV/krb/get_krbrlm.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * $Source: /usr/src/kerberosIV/krb/RCS/get_krbrlm.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_get_krbrlm_c =
        !            14: "$Header: /usr/src/kerberosIV/krb/RCS/get_krbrlm.c,v 4.9 90/06/25 20:55:57 kfall Exp $";
        !            15: #endif /* lint */
        !            16: 
        !            17: #include <mit-copyright.h>
        !            18: #include <stdio.h>
        !            19: #include <des.h>
        !            20: #include <krb.h>
        !            21: #include <strings.h>
        !            22: 
        !            23: /*
        !            24:  * krb_get_lrealm takes a pointer to a string, and a number, n.  It fills
        !            25:  * in the string, r, with the name of the nth realm specified on the
        !            26:  * first line of the kerberos config file (KRB_CONF, defined in "krb.h").
        !            27:  * It returns 0 (KSUCCESS) on success, and KFAILURE on failure.  If the
        !            28:  * config file does not exist, and if n=1, a successful return will occur
        !            29:  * with r = KRB_REALM (also defined in "krb.h").
        !            30:  *
        !            31:  * NOTE: for archaic & compatibility reasons, this routine will only return
        !            32:  * valid results when n = 1.
        !            33:  *
        !            34:  * For the format of the KRB_CONF file, see comments describing the routine
        !            35:  * krb_get_krbhst().
        !            36:  */
        !            37: 
        !            38: krb_get_lrealm(r,n)
        !            39:     char *r;
        !            40:     int n;
        !            41: {
        !            42:     FILE *cnffile, *fopen();
        !            43: 
        !            44:     if (n > 1)
        !            45:        return(KFAILURE);  /* Temporary restriction */
        !            46: 
        !            47:     if ((cnffile = fopen(KRB_CONF, "r")) == NULL) {
        !            48:        if (n == 1) {
        !            49:            (void) strcpy(r, KRB_REALM);
        !            50:            return(KSUCCESS);
        !            51:        }
        !            52:        else
        !            53:            return(KFAILURE);
        !            54:     }
        !            55: 
        !            56:     if (fscanf(cnffile,"%s",r) != 1) {
        !            57:         (void) fclose(cnffile);
        !            58:         return(KFAILURE);
        !            59:     }
        !            60:     (void) fclose(cnffile);
        !            61:     return(KSUCCESS);
        !            62: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.