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>
11 #include <afs/param.h>
16 #include <afs/pthread_glock.h>
17 #include <afs/cellconfig.h>
24 /* This is a utility routine that many parts of kauth use but it invokes the
25 afsconf package so its best to have it in a separate .o file to make the
28 static struct afsconf_dir
*conf
= 0;
29 static char cell_name
[MAXCELLCHARS
];
32 ka_CellConfig(const char *dir
)
39 conf
= afsconf_Open(dir
);
44 code
= afsconf_GetLocalCell(conf
, cell_name
, sizeof(cell_name
));
59 if ((conf
= afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH
))) {
60 code
= afsconf_GetLocalCell(conf
, cell_name
, sizeof(cell_name
));
61 /* leave conf open so we can lookup other cells */
62 /* afsconf_Close (conf); */
65 printf("** Can't determine local cell name!\n");
75 ka_ExpandCell(char *cell
, char *fullCell
, int *alocal
)
79 char cellname
[MAXKTCREALMLEN
];
80 struct afsconf_cell cellinfo
; /* storage for cell info */
83 ka_LocalCell(); /* initialize things */
89 if ((cell
== 0) || (strlen(cell
) == 0)) {
93 cell
= lcstring(cellname
, cell
, sizeof(cellname
));
94 code
= afsconf_GetCellInfo(conf
, cell
, 0, &cellinfo
);
101 if (strcmp(cell
, cell_name
) == 0)
105 strcpy(fullCell
, cell
);
113 ka_CellToRealm(char *cell
, char *realm
, int *local
)
118 code
= ka_ExpandCell(cell
, realm
, local
);
119 ucstring(realm
, realm
, MAXKTCREALMLEN
);