2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
12 #include "afs/param.h"
14 #include <afs/param.h>
21 #include "afs/pthread_glock.h"
22 #include "afs/sysincludes.h"
23 #include "afsincludes.h"
24 #include "afs_usrops.h"
25 #include "afs/cellconfig.h"
26 #include "afs/pthread_glock.h"
29 #include "afs/kauth.h"
30 #include "afs/kautils.h"
31 #include "afs/afsutil.h"
32 #else /* defined(UKERNEL) */
33 #include <afs/pthread_glock.h>
34 #include <sys/types.h>
38 #include <netinet/in.h>
47 #include <afs/cellconfig.h>
52 #include <afs/afsutil.h>
53 #endif /* defined(UKERNEL) */
55 /* This is a utility routine that many parts of kauth use but it invokes the
56 afsconf package so its best to have it in a separate .o file to make the
59 static struct afsconf_dir *conf = 0;
60 static char cell_name[MAXCELLCHARS];
63 ka_CellConfig(const char *dir)
68 strcpy(cell_name, afs_LclCellName);
71 LOCK_GLOBAL_MUTEX if (conf)
73 conf = afsconf_Open(dir);
75 UNLOCK_GLOBAL_MUTEX return KANOCELLS;
77 code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name));
78 UNLOCK_GLOBAL_MUTEX return code;
87 LOCK_GLOBAL_MUTEX if (conf) {
88 UNLOCK_GLOBAL_MUTEX return cell_name;
92 strcpy(cell_name, afs_LclCellName);
94 if (conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH)) {
95 code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name));
96 /* leave conf open so we can lookup other cells */
97 /* afsconf_Close (conf); */
100 printf("** Can't determine local cell name!\n");
102 UNLOCK_GLOBAL_MUTEX return 0;
105 UNLOCK_GLOBAL_MUTEX return cell_name;
109 ka_ExpandCell(char *cell, char *fullCell, int *alocal)
113 char cellname[MAXKTCREALMLEN];
114 struct afsconf_cell cellinfo; /* storage for cell info */
116 LOCK_GLOBAL_MUTEX ka_LocalCell(); /* initialize things */
118 UNLOCK_GLOBAL_MUTEX return KANOCELLS;
121 if ((cell == 0) || (strlen(cell) == 0)) {
125 cell = lcstring(cellname, cell, sizeof(cellname));
126 code = afsconf_GetCellInfo(conf, cell, 0, &cellinfo);
128 UNLOCK_GLOBAL_MUTEX return KANOCELL;
130 cell = cellinfo.name;
132 if (strcmp(cell, cell_name) == 0)
136 strcpy(fullCell, cell);
139 UNLOCK_GLOBAL_MUTEX return 0;
143 ka_CellToRealm(char *cell, char *realm, int *local)
147 LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, realm, local);
148 ucstring(realm, realm, MAXKTCREALMLEN);
149 UNLOCK_GLOBAL_MUTEX return code;