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>
19 #include "afs/pthread_glock.h"
20 #include "afs/sysincludes.h"
21 #include "afsincludes.h"
22 #include "afs_usrops.h"
23 #include "afs/cellconfig.h"
24 #include "afs/pthread_glock.h"
27 #include "afs/kauth.h"
28 #include "afs/kautils.h"
29 #include "afs/afsutil.h"
30 #else /* defined(UKERNEL) */
31 #include <afs/pthread_glock.h>
32 #include <sys/types.h>
36 #include <netinet/in.h>
39 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
45 #endif /* defined(UKERNEL) */
47 /* This is a utility routine that many parts of kauth use but it invokes the
48 afsconf package so its best to have it in a separate .o file to make the
51 static struct afsconf_dir *conf = 0;
52 static char cell_name[MAXCELLCHARS];
55 ka_CellConfig(const char *dir)
59 strcpy(cell_name, afs_LclCellName);
67 conf = afsconf_Open(dir);
72 code = afsconf_GetLocalCell(conf, cell_name, sizeof(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");
111 ka_ExpandCell(char *cell, char *fullCell, int *alocal)
115 char cellname[MAXKTCREALMLEN];
116 struct afsconf_cell cellinfo; /* storage for cell info */
119 ka_LocalCell(); /* initialize things */
125 if ((cell == 0) || (strlen(cell) == 0)) {
129 cell = lcstring(cellname, cell, sizeof(cellname));
130 code = afsconf_GetCellInfo(conf, cell, 0, &cellinfo);
135 cell = cellinfo.name;
137 if (strcmp(cell, cell_name) == 0)
141 strcpy(fullCell, cell);
149 ka_CellToRealm(char *cell, char *realm, int *local)
154 code = ka_ExpandCell(cell, realm, local);
155 ucstring(realm, realm, MAXKTCREALMLEN);