#include "afs/cellconfig.h"
#include "afs/afsutil.h"
#include "afs/ptclient.h"
+#include "afs/ptuser.h"
#include "afs/pterror.h"
#else /* defined(UKERNEL) */
#include <afs/stds.h>
#include <afs/cellconfig.h>
#include <afs/afsutil.h>
#include "ptclient.h"
+#include "ptuser.h"
#include "pterror.h"
#endif /* defined(UKERNEL) */
static char *whoami = "libprot";
afs_int32
-pr_Initialize(secLevel, confDir, cell)
- IN afs_int32 secLevel;
- IN char *confDir;
- IN char *cell;
+pr_Initialize(IN afs_int32 secLevel, IN char *confDir, IN char *cell)
{
afs_int32 code;
struct rx_connection *serverconns[MAXSERVERS];
struct rx_securityClass *sc[3];
- static struct afsconf_dir *tdir = 0; /* only do this once */
- static char tconfDir[100];
+ static struct afsconf_dir *tdir = (struct afsconf_dir *)0; /* only do this once */
+ static char tconfDir[100] = "";
+ static char tcell[64] = "";
struct ktc_token ttoken;
afs_int32 scIndex;
static struct afsconf_cell info;
afs_int32 i;
char cellstr[64];
+ afs_int32 gottdir = 0;
+ afs_int32 refresh = 0;
initialize_PT_error_table();
initialize_RXK_error_table();
initialize_ACFG_error_table();
initialize_KTC_error_table();
- if (strcmp(confDir, tconfDir)) {
+#if defined(UKERNEL)
+ if (!cell) {
+ cell = afs_LclCellName;
+ }
+#else /* defined(UKERNEL) */
+ if (!cell) {
+ if (!tdir)
+ tdir = afsconf_Open(confDir);
+ if (!tdir) {
+ if (confDir && strcmp(confDir, ""))
+ fprintf(stderr,
+ "libprot: Could not open configuration directory: %s.\n",
+ confDir);
+ else
+ fprintf(stderr,
+ "libprot: No configuration directory specified.\n");
+ return -1;
+ }
+ gottdir = 1;
+
+ code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
+ if (code) {
+ fprintf(stderr,
+ "libprot: Could not get local cell. [%d]\n", code);
+ return code;
+ }
+ cell = cellstr;
+ }
+#endif /* defined(UKERNEL) */
+
+ if (tdir == 0 || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) {
/*
- * Different conf dir; force re-evaluation.
+ * force re-evaluation. we either don't have an afsconf_dir,
+ * the directory has changed or the cell has changed.
*/
- tdir = (struct afsconf_dir *)0;
+ if (tdir && !gottdir) {
+ afsconf_Close(tdir);
+ tdir = (struct afsconf_dir *)0;
+ }
pruclient = (struct ubik_client *)0;
+ refresh = 1;
}
- if (tdir == 0) {
+
+ if (refresh) {
strncpy(tconfDir, confDir, sizeof(tconfDir));
+ strncpy(tcell, cell, sizeof(tcell));
+
#if defined(UKERNEL)
tdir = afs_cdir;
- if (!cell) {
- cell = afs_LclCellName;
- }
#else /* defined(UKERNEL) */
- tdir = afsconf_Open(confDir);
+ if (!gottdir)
+ tdir = afsconf_Open(confDir);
if (!tdir) {
- fprintf(stderr,
- "libprot: Could not open configuration directory: %s.\n",
- confDir);
- return -1;
- }
-
- if (!cell) {
- code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
- if (code) {
+ if (confDir && strcmp(confDir, ""))
fprintf(stderr,
- "vos: can't get local cell name - check %s/%s\n",
- confDir, AFSDIR_THISCELL_FILE);
- exit(1);
- }
- cell = cellstr;
+ "libprot: Could not open configuration directory: %s.\n",
+ confDir);
+ else
+ fprintf(stderr,
+ "libprot: No configuration directory specified.\n");
+ return -1;
}
#endif /* defined(UKERNEL) */
if (code)
scIndex = 0;
else {
- if (ttoken.kvno >= 0 && ttoken.kvno <= 255)
+ if (ttoken.kvno >= 0 && ttoken.kvno <= 256)
/* this is a kerberos ticket, set scIndex accordingly */
scIndex = 2;
else {
scIndex = 2;
}
sc[2] =
- rxkad_NewClientSecurityObject(secLevel, &ttoken.sessionKey,
+ rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
ttoken.kvno, ttoken.ticketLen,
ttoken.ticket);
}
return code;
}
-
+int
pr_End()
{
int code = 0;
-pr_CreateUser(name, id)
- char name[PR_MAXNAMELEN];
- afs_int32 *id;
+int
+pr_CreateUser(char name[PR_MAXNAMELEN], afs_int32 *id)
{
register afs_int32 code;
}
-pr_CreateGroup(name, owner, id)
- char name[PR_MAXNAMELEN];
- char owner[PR_MAXNAMELEN];
- afs_int32 *id;
+int
+pr_CreateGroup(char name[PR_MAXNAMELEN], char owner[PR_MAXNAMELEN], afs_int32 *id)
{
register afs_int32 code;
afs_int32 oid = 0;
}
}
-pr_Delete(name)
- char *name;
+int
+pr_Delete(char *name)
{
register afs_int32 code;
afs_int32 id;
return code;
}
-pr_DeleteByID(id)
- afs_int32 id;
+int
+pr_DeleteByID(afs_int32 id)
{
register afs_int32 code;
return code;
}
-pr_AddToGroup(user, group)
- char *user;
- char *group;
+int
+pr_AddToGroup(char *user, char *group)
{
register afs_int32 code;
namelist lnames;
return code;
}
-pr_RemoveUserFromGroup(user, group)
- char *user;
- char *group;
+int
+pr_RemoveUserFromGroup(char *user, char *group)
{
register afs_int32 code;
namelist lnames;
}
-pr_NameToId(names, ids)
- namelist *names;
- idlist *ids;
+int
+pr_NameToId(namelist *names, idlist *ids)
{
register afs_int32 code;
register afs_int32 i;
return code;
}
-pr_SNameToId(name, id)
- char name[PR_MAXNAMELEN];
- afs_int32 *id;
+int
+pr_SNameToId(char name[PR_MAXNAMELEN], afs_int32 *id)
{
namelist lnames;
idlist lids;
return code;
}
-
-
-pr_IdToName(ids, names)
- idlist *ids;
- namelist *names;
+int
+pr_IdToName(idlist *ids, namelist *names)
{
register afs_int32 code;
return code;
}
-pr_SIdToName(id, name)
- afs_int32 id;
- char name[PR_MAXNAMELEN];
+int
+pr_SIdToName(afs_int32 id, char name[PR_MAXNAMELEN])
{
namelist lnames;
idlist lids;
return code;
}
-
-
-pr_GetCPS(id, CPS)
- afs_int32 id;
- prlist *CPS;
+int
+pr_GetCPS(afs_int32 id, prlist *CPS)
{
register afs_int32 code;
afs_int32 over;
return 0;
}
-
-pr_GetCPS2(id, host, CPS)
- afs_int32 id;
- afs_int32 host;
- prlist *CPS;
+int
+pr_GetCPS2(afs_int32 id, afs_int32 host, prlist *CPS)
{
register afs_int32 code;
afs_int32 over;
return 0;
}
-pr_GetHostCPS(host, CPS)
- afs_int32 host;
- prlist *CPS;
+int
+pr_GetHostCPS(afs_int32 host, prlist *CPS)
{
register afs_int32 code;
afs_int32 over;
return 0;
}
-
-pr_ListMembers(group, lnames)
- char *group;
- namelist *lnames;
+int
+pr_ListMembers(char *group, namelist *lnames)
{
register afs_int32 code;
afs_int32 gid;
return code;
}
-pr_ListOwned(oid, lnames, moreP)
- afs_int32 oid;
- namelist *lnames;
- afs_int32 *moreP;
+int
+pr_ListOwned(afs_int32 oid, namelist *lnames, afs_int32 *moreP)
{
register afs_int32 code;
prlist alist;
return PRSUCCESS;
}
-pr_IDListMembers(gid, lnames)
- afs_int32 gid;
- namelist *lnames;
+int
+pr_IDListMembers(afs_int32 gid, namelist *lnames)
{
register afs_int32 code;
prlist alist;
return PRSUCCESS;
}
-
-pr_ListEntry(id, aentry)
- afs_int32 id;
- struct prcheckentry *aentry;
+int
+pr_ListEntry(afs_int32 id, struct prcheckentry *aentry)
{
register afs_int32 code;
}
afs_int32
-pr_ListEntries(flag, startindex, nentries, entries, nextstartindex)
- afs_int32 startindex;
- afs_int32 *nentries;
- struct prlistentries **entries;
- afs_int32 *nextstartindex;
+pr_ListEntries(int flag, afs_int32 startindex, afs_int32 *nentries, struct prlistentries **entries, afs_int32 *nextstartindex)
{
afs_int32 code;
prentries bulkentries;
return code;
}
-pr_CheckEntryByName(name, id, owner, creator)
- char *name;
- afs_int32 *id;
- char *owner;
- char *creator;
+int
+pr_CheckEntryByName(char *name, afs_int32 *id, char *owner, char *creator)
{
/* struct prcheckentry returns other things, which aren't useful to show at this time. */
register afs_int32 code;
return PRSUCCESS;
}
-pr_CheckEntryById(name, id, owner, creator)
- char *name;
- afs_int32 id;
- char *owner;
- char *creator;
+int
+pr_CheckEntryById(char *name, afs_int32 id, char *owner, char *creator)
{
/* struct prcheckentry returns other things, which aren't useful to show at this time. */
register afs_int32 code;
return PRSUCCESS;
}
-pr_ChangeEntry(oldname, newname, newid, newowner)
- char *oldname;
- char *newname;
- afs_int32 *newid;
- char *newowner;
+int
+pr_ChangeEntry(char *oldname, char *newname, afs_int32 *newid, char *newowner)
{
register afs_int32 code;
afs_int32 id;
return code;
}
-pr_IsAMemberOf(uname, gname, flag)
- char *uname;
- char *gname;
- afs_int32 *flag;
+int
+pr_IsAMemberOf(char *uname, char *gname, afs_int32 *flag)
{
register afs_int32 code;
namelist lnames;
return code;
}
-
-pr_ListMaxUserId(mid)
- afs_int32 *mid;
+int
+pr_ListMaxUserId(afs_int32 *mid)
{
register afs_int32 code;
afs_int32 gid;
return code;
}
-pr_SetMaxUserId(mid)
- afs_int32 mid;
+int
+pr_SetMaxUserId(afs_int32 mid)
{
register afs_int32 code;
afs_int32 flag = 0;
return code;
}
-pr_ListMaxGroupId(mid)
- afs_int32 *mid;
+int
+pr_ListMaxGroupId(afs_int32 *mid)
{
register afs_int32 code;
afs_int32 id;
return code;
}
-pr_SetMaxGroupId(mid)
- afs_int32 mid;
+int
+pr_SetMaxGroupId(afs_int32 mid)
{
register afs_int32 code;
afs_int32 flag = 0;
}
afs_int32
-pr_SetFieldsEntry(id, mask, flags, ngroups, nusers)
- afs_int32 id;
- afs_int32 mask;
- afs_int32 flags, ngroups, nusers;
+pr_SetFieldsEntry(afs_int32 id, afs_int32 mask, afs_int32 flags, afs_int32 ngroups, afs_int32 nusers)
{
register afs_int32 code;
return code;
}
-
int
-stolower(s)
- char *s;
+stolower(char *s)
{
while (*s) {
if (isupper(*s))