Remove the RCSID macro
[openafs.git] / src / aklog / krb_util.c
1 /*
2  * This file replaces some of the routines in the Kerberos utilities.
3  * It is based on the Kerberos library modules:
4  *      send_to_kdc.c
5  * 
6  * Copyright 1987, 1988, 1992 by the Massachusetts Institute of Technology.
7  *
8  * For copying and distribution information, please see the file
9  * <mit-copyright.h>.
10  */
11
12 #include <afsconfig.h>
13
14 #if 0
15 #include <kerberosIV/mit-copyright.h>
16 #endif
17 #include <afs/stds.h>
18 #include "aklog.h"
19 #include <krb5.h>
20
21 #ifndef MAX_HSTNM
22 #define MAX_HSTNM 100
23 #endif
24
25 #include <afs/cellconfig.h>
26
27 #include <string.h>
28 #include <ctype.h>
29
30 #define S_AD_SZ sizeof(struct sockaddr_in)
31
32 char *afs_realm_of_cell(krb5_context context, struct afsconf_cell *cellconfig, int fallback)
33 {
34     static char krbrlm[REALM_SZ+1];
35         char **hrealms = 0;
36         krb5_error_code retval;
37
38     if (!cellconfig)
39         return 0;
40
41     if (fallback) {
42         char * p;
43         p = strchr(cellconfig->hostName[0], '.');
44         if (p++)
45             strcpy(krbrlm, p);
46         else
47             strcpy(krbrlm, cellconfig->name);
48         for (p=krbrlm; *p; p++) {
49             if (islower(*p)) 
50                 *p = toupper(*p);
51         }
52     } else {
53         if ((retval = krb5_get_host_realm(context,
54                                          cellconfig->hostName[0], &hrealms)))
55             return 0; 
56         if(!hrealms[0]) return 0;
57         strcpy(krbrlm, hrealms[0]);
58
59         if (hrealms) krb5_free_host_realm(context, hrealms);
60     }
61     return krbrlm;
62 }