a62e8711e815a753a41c99e1270d906d9b8f9fa5
[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 #ifndef lint
13 static char rcsid_send_to_kdc_c[] =
14 "$Id$";
15 #endif /* lint */
16
17 #if 0
18 #include <kerberosIV/mit-copyright.h>
19 #endif
20 #include <afs/stds.h>
21 #include "aklog.h"
22 #include <krb5.h>
23
24 #ifndef MAX_HSTNM
25 #define MAX_HSTNM 100
26 #endif
27
28 #ifdef WINDOWS
29
30 #include "aklog.h"              /* for struct afsconf_cell */
31
32 #else /* !WINDOWS */
33
34 #include <afs/param.h>
35 #include <afs/cellconfig.h>
36
37 #endif /* WINDOWS */
38
39 #define S_AD_SZ sizeof(struct sockaddr_in)
40
41 char *afs_realm_of_cell(context, cellconfig)
42     krb5_context context;
43     struct afsconf_cell *cellconfig;
44 {
45     char krbhst[MAX_HSTNM];
46     static char krbrlm[REALM_SZ+1];
47         char **hrealms = 0;
48         krb5_error_code retval;
49
50     if (!cellconfig)
51         return 0;
52     if (retval = krb5_get_host_realm(context,
53                                 cellconfig->hostName[0], &hrealms))
54                 return 0; 
55         if(!hrealms[0]) return 0;
56         strcpy(krbrlm, hrealms[0]);
57
58         if (hrealms) krb5_free_host_realm(context, hrealms);
59     
60     return krbrlm;
61 }