Add interface to select client security objects
[openafs.git] / src / ptserver / ptuser.c
index 8df66fd..fd88933 100644 (file)
@@ -14,8 +14,6 @@
 #include <afs/param.h>
 #endif
 
-RCSID
-    ("$Header$");
 
 #if defined(UKERNEL)
 #include "afs/sysincludes.h"
@@ -24,12 +22,13 @@ RCSID
 #include "afs/stds.h"
 #include "rx/rx.h"
 #include "rx/xdr.h"
-#include "rx/rxkad.h"
 #include "afs/auth.h"
 #include "afs/cellconfig.h"
 #include "afs/afsutil.h"
 #include "afs/ptclient.h"
+#include "afs/ptuser.h"
 #include "afs/pterror.h"
+#include "afs/com_err.h"
 #else /* defined(UKERNEL) */
 #include <afs/stds.h>
 #include <ctype.h>
@@ -40,20 +39,15 @@ RCSID
 #include <netinet/in.h>
 #endif
 #include <stdio.h>
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #include <rx/rx.h>
 #include <rx/xdr.h>
-#include <rx/rxkad.h>
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
 #include <afs/afsutil.h>
+#include <afs/com_err.h>
 #include "ptclient.h"
+#include "ptuser.h"
 #include "pterror.h"
 #endif /* defined(UKERNEL) */
 
@@ -64,59 +58,91 @@ static afs_int32 lastLevel; /* security level pruclient, if any */
 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 const 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];
-    struct ktc_token ttoken;
+    struct rx_securityClass *sc;
+    static struct afsconf_dir *tdir = (struct afsconf_dir *)NULL;      /* only do this once */
+    static char tconfDir[100] = "";
+    static char tcell[64] = "";
     afs_int32 scIndex;
+    afs_int32 secFlags;
     static struct afsconf_cell info;
     afs_int32 i;
+#if !defined(UKERNEL)
     char cellstr[64];
+#endif
+    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,
+                       "%s: Could not open configuration directory: %s.\n",
+                       whoami, confDir);
+            else
+               fprintf(stderr,
+                       "%s: No configuration directory specified.\n",
+                       whoami);
+           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 == NULL || 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;
-       pruclient = (struct ubik_client *)0;
+       if (tdir && !gottdir) {
+           afsconf_Close(tdir);
+            tdir = (struct afsconf_dir *)NULL;
+        }
+       pruclient = (struct ubik_client *)NULL;
+        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,
+                       "libprot: Could not open configuration directory: %s.\n",
+                       confDir);
+            else
                fprintf(stderr,
-                       "vos: can't get local cell name - check %s/%s\n",
-                       confDir, AFSDIR_THISCELL_FILE);
-               exit(1);
-           }
-           cell = cellstr;
+                       "libprot: No configuration directory specified.\n");
+           return -1;
        }
 #endif /* defined(UKERNEL) */
 
@@ -132,8 +158,9 @@ pr_Initialize(secLevel, confDir, cell)
      * want, don't get a new one. Unless the security level is 2 in
      * which case we will get one (and re-read the key file).
      */
-    if (pruclient && (lastLevel == secLevel) && (secLevel != 2))
+    if (pruclient && (lastLevel == secLevel) && (secLevel != 2)) {
        return 0;
+    }
 
     code = rx_Init(0);
     if (code) {
@@ -141,78 +168,63 @@ pr_Initialize(secLevel, confDir, cell)
        return code;
     }
 
-    scIndex = secLevel;
-    sc[0] = 0;
-    sc[1] = 0;
-    sc[2] = 0;
     /* Most callers use secLevel==1, however, the fileserver uses secLevel==2
      * to force use of the KeyFile.  secLevel == 0 implies -noauth was
      * specified. */
-    if ((secLevel == 2) && (afsconf_GetLatestKey(tdir, 0, 0) == 0)) {
-       /* If secLevel is two assume we're on a file server and use
-        * ClientAuthSecure if possible. */
-       code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex);
-       if (code)
-           fprintf(stderr,
-                   "libprot: clientauthsecure returns %d %s"
-                   " (so trying noauth)\n", code, error_message(code));
-       if (code)
-           scIndex = 0;        /* use noauth */
-       if (scIndex != 2)
-           /* if there was a problem, an unauthenticated conn is returned */
-           sc[scIndex] = sc[2];
+    if (secLevel == 2) {
+       code = afsconf_GetLatestKey(tdir, 0, 0);
+       if (code) {
+           afs_com_err(whoami, code, "(getting key from local KeyFile)\n");
+       } else {
+           /* If secLevel is two assume we're on a file server and use
+            * ClientAuthSecure if possible. */
+           code = afsconf_ClientAuthSecure(tdir, &sc, &scIndex);
+           if (code)
+               afs_com_err(whoami, code, "(calling client secure)\n");
+        }
     } else if (secLevel > 0) {
-       struct ktc_principal sname;
-       strcpy(sname.cell, info.name);
-       sname.instance[0] = 0;
-       strcpy(sname.name, "afs");
-       code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
-       if (code)
-           scIndex = 0;
-       else {
-           if (ttoken.kvno >= 0 && ttoken.kvno <= 255)
-               /* this is a kerberos ticket, set scIndex accordingly */
-               scIndex = 2;
-           else {
-               fprintf(stderr,
-                       "libprot: funny kvno (%d) in ticket, proceeding\n",
-                       ttoken.kvno);
-               scIndex = 2;
-           }
-           sc[2] =
-               rxkad_NewClientSecurityObject(secLevel, &ttoken.sessionKey,
-                                             ttoken.kvno, ttoken.ticketLen,
-                                             ttoken.ticket);
+       secFlags = 0;
+       if (secLevel > 1)
+           secFlags |= AFSCONF_SECOPTS_ALWAYSENCRYPT;
+
+       code = afsconf_ClientAuthToken(&info, secFlags, &sc, &scIndex, NULL);
+       if (code) {
+           afs_com_err(whoami, code, "(getting token)");
+           if (secLevel > 1)
+               return code;
        }
     }
-    if (scIndex == 1)
-       return PRBADARG;
-    if ((scIndex == 0) && (sc[0] == 0))
-       sc[0] = rxnull_NewClientSecurityObject();
+
+    if (sc == NULL) {
+       sc = rxnull_NewClientSecurityObject();
+        scIndex = 0;
+    }
+
     if ((scIndex == 0) && (secLevel != 0))
-       com_err(whoami, code,
-               "Could not get afs tokens, running unauthenticated.");
+       fprintf(stderr,
+               "%s: Could not get afs tokens, running unauthenticated\n",
+               whoami);
 
     memset(serverconns, 0, sizeof(serverconns));       /* terminate list!!! */
     for (i = 0; i < info.numServers; i++)
        serverconns[i] =
            rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
-                            info.hostAddr[i].sin_port, PRSRV, sc[scIndex],
+                            info.hostAddr[i].sin_port, PRSRV, sc,
                             scIndex);
 
     code = ubik_ClientInit(serverconns, &pruclient);
     if (code) {
-       com_err(whoami, code, "ubik client init failed.");
+       afs_com_err(whoami, code, "ubik client init failed.");
        return code;
     }
     lastLevel = scIndex;
 
-    code = rxs_Release(sc[scIndex]);
+    code = rxs_Release(sc);
     return code;
 }
 
-
-pr_End()
+int
+pr_End(void)
 {
     int code = 0;
 
@@ -225,27 +237,24 @@ pr_End()
 
 
 
-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;
 
     stolower(name);
     if (*id) {
-       code = ubik_Call(PR_INewEntry, pruclient, 0, name, *id, 0);
+       code = ubik_PR_INewEntry(pruclient, 0, name, *id, 0);
        return code;
     } else {
-       code = ubik_Call(PR_NewEntry, pruclient, 0, name, 0, 0, id);
+       code = ubik_PR_NewEntry(pruclient, 0, name, 0, 0, id);
        return 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;
@@ -261,16 +270,16 @@ pr_CreateGroup(name, owner, id)
     }
     flags |= PRGRP;
     if (*id) {
-       code = ubik_Call(PR_INewEntry, pruclient, 0, name, *id, oid);
+       code = ubik_PR_INewEntry(pruclient, 0, name, *id, oid);
        return code;
     } else {
-       code = ubik_Call(PR_NewEntry, pruclient, 0, name, flags, oid, id);
+       code = ubik_PR_NewEntry(pruclient, 0, name, flags, oid, id);
        return code;
     }
 }
 
-pr_Delete(name)
-     char *name;
+int
+pr_Delete(char *name)
 {
     register afs_int32 code;
     afs_int32 id;
@@ -281,29 +290,28 @@ pr_Delete(name)
        return code;
     if (id == ANONYMOUSID)
        return PRNOENT;
-    code = ubik_Call(PR_Delete, pruclient, 0, id);
+    code = ubik_PR_Delete(pruclient, 0, id);
     return code;
 }
 
-pr_DeleteByID(id)
-     afs_int32 id;
+int
+pr_DeleteByID(afs_int32 id)
 {
     register afs_int32 code;
 
-    code = ubik_Call(PR_Delete, pruclient, 0, id);
+    code = ubik_PR_Delete(pruclient, 0, id);
     return code;
 }
 
-pr_AddToGroup(user, group)
-     char *user;
-     char *group;
+int
+pr_AddToGroup(char *user, char *group)
 {
     register afs_int32 code;
     namelist lnames;
     idlist lids;
 
     lnames.namelist_len = 2;
-    lnames.namelist_val = (prname *) malloc(2 * PR_MAXNAMELEN);
+    lnames.namelist_val = malloc(2 * PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], user, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[1], group, PR_MAXNAMELEN);
     lids.idlist_val = 0;
@@ -318,26 +326,25 @@ pr_AddToGroup(user, group)
        goto done;
     }
     code =
-       ubik_Call(PR_AddToGroup, pruclient, 0, lids.idlist_val[0],
+       ubik_PR_AddToGroup(pruclient, 0, lids.idlist_val[0],
                  lids.idlist_val[1]);
   done:
     if (lnames.namelist_val)
        free(lnames.namelist_val);
-    if (lids.idlist_val)
-       free(lids.idlist_val);
+
+    xdr_free((xdrproc_t) xdr_idlist, &lids);
     return code;
 }
 
-pr_RemoveUserFromGroup(user, group)
-     char *user;
-     char *group;
+int
+pr_RemoveUserFromGroup(char *user, char *group)
 {
     register afs_int32 code;
     namelist lnames;
     idlist lids;
 
     lnames.namelist_len = 2;
-    lnames.namelist_val = (prname *) malloc(2 * PR_MAXNAMELEN);
+    lnames.namelist_val = malloc(2 * PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], user, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[1], group, PR_MAXNAMELEN);
     lids.idlist_val = 0;
@@ -352,33 +359,31 @@ pr_RemoveUserFromGroup(user, group)
        goto done;
     }
     code =
-       ubik_Call(PR_RemoveFromGroup, pruclient, 0, lids.idlist_val[0],
+       ubik_PR_RemoveFromGroup(pruclient, 0, lids.idlist_val[0],
                  lids.idlist_val[1]);
   done:
     if (lnames.namelist_val)
        free(lnames.namelist_val);
-    if (lids.idlist_val)
-       free(lids.idlist_val);
-    return code;
 
+    xdr_free((xdrproc_t) xdr_idlist, &lids);
+
+    return code;
 }
 
-pr_NameToId(names, ids)
-     namelist *names;
-     idlist *ids;
+int
+pr_NameToId(namelist *names, idlist *ids)
 {
     register afs_int32 code;
     register afs_int32 i;
 
     for (i = 0; i < names->namelist_len; i++)
        stolower(names->namelist_val[i]);
-    code = ubik_Call(PR_NameToID, pruclient, 0, names, ids);
+    code = ubik_PR_NameToID(pruclient, 0, names, ids);
     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;
@@ -387,65 +392,61 @@ pr_SNameToId(name, id)
     lids.idlist_len = 0;
     lids.idlist_val = 0;
     lnames.namelist_len = 1;
-    lnames.namelist_val = (prname *) malloc(PR_MAXNAMELEN);
+    lnames.namelist_val = malloc(PR_MAXNAMELEN);
     stolower(name);
     strncpy(lnames.namelist_val[0], name, PR_MAXNAMELEN);
-    code = ubik_Call(PR_NameToID, pruclient, 0, &lnames, &lids);
+    code = ubik_PR_NameToID(pruclient, 0, &lnames, &lids);
     if (lids.idlist_val) {
        *id = *lids.idlist_val;
-       free(lids.idlist_val);
+       xdr_free((xdrproc_t) xdr_idlist, &lids);
     }
     if (lnames.namelist_val)
        free(lnames.namelist_val);
     return code;
 }
 
-
-
-pr_IdToName(ids, names)
-     idlist *ids;
-     namelist *names;
+int
+pr_IdToName(idlist *ids, namelist *names)
 {
     register afs_int32 code;
 
-    code = ubik_Call(PR_IDToName, pruclient, 0, ids, names);
+    code = ubik_PR_IDToName(pruclient, 0, ids, names);
     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;
     register afs_int32 code;
 
     lids.idlist_len = 1;
-    lids.idlist_val = (afs_int32 *) malloc(sizeof(afs_int32));
+    lids.idlist_val = malloc(sizeof(afs_int32));
     *lids.idlist_val = id;
     lnames.namelist_len = 0;
     lnames.namelist_val = 0;
-    code = ubik_Call(PR_IDToName, pruclient, 0, &lids, &lnames);
-    if (lnames.namelist_val) {
+    code = ubik_PR_IDToName(pruclient, 0, &lids, &lnames);
+
+    if (lnames.namelist_val)
        strncpy(name, lnames.namelist_val[0], PR_MAXNAMELEN);
-       free(lnames.namelist_val);
-    }
+
     if (lids.idlist_val)
        free(lids.idlist_val);
-    return code;
-}
 
+    xdr_free((xdrproc_t) xdr_namelist, &lnames);
 
+    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;
 
     over = 0;
-    code = ubik_Call(PR_GetCPS, pruclient, 0, id, CPS, &over);
+    code = ubik_PR_GetCPS(pruclient, 0, id, CPS, &over);
     if (code != PRSUCCESS)
        return code;
     if (over) {
@@ -457,17 +458,14 @@ pr_GetCPS(id, CPS)
     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;
 
     over = 0;
-    code = ubik_Call(PR_GetCPS2, pruclient, 0, id, host, CPS, &over);
+    code = ubik_PR_GetCPS2(pruclient, 0, id, host, CPS, &over);
     if (code != PRSUCCESS)
        return code;
     if (over) {
@@ -479,15 +477,14 @@ pr_GetCPS2(id, host, CPS)
     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;
 
     over = 0;
-    code = ubik_Call(PR_GetHostCPS, pruclient, 0, host, CPS, &over);
+    code = ubik_PR_GetHostCPS(pruclient, 0, host, CPS, &over);
     if (code != PRSUCCESS)
        return code;
     if (over) {
@@ -500,10 +497,8 @@ pr_GetHostCPS(host, CPS)
     return 0;
 }
 
-
-pr_ListMembers(group, lnames)
-     char *group;
-     namelist *lnames;
+int
+pr_ListMembers(char *group, namelist *lnames)
 {
     register afs_int32 code;
     afs_int32 gid;
@@ -517,10 +512,8 @@ pr_ListMembers(group, lnames)
     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;
@@ -528,7 +521,7 @@ pr_ListOwned(oid, lnames, moreP)
 
     alist.prlist_len = 0;
     alist.prlist_val = 0;
-    code = ubik_Call(PR_ListOwned, pruclient, 0, oid, &alist, moreP);
+    code = ubik_PR_ListOwned(pruclient, 0, oid, &alist, moreP);
     if (code)
        return code;
     if (*moreP == 1) {
@@ -537,18 +530,19 @@ pr_ListOwned(oid, lnames, moreP)
                oid);
        *moreP = 0;
     }
-    lids = (idlist *) & alist;
+    lids = (idlist *) &alist;
     code = pr_IdToName(lids, lnames);
+
+    xdr_free((xdrproc_t) xdr_prlist, &alist);
+
     if (code)
        return code;
-    if (alist.prlist_val)
-       free(alist.prlist_val);
+
     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;
@@ -557,39 +551,34 @@ pr_IDListMembers(gid, lnames)
 
     alist.prlist_len = 0;
     alist.prlist_val = 0;
-    code = ubik_Call(PR_ListElements, pruclient, 0, gid, &alist, &over);
+    code = ubik_PR_ListElements(pruclient, 0, gid, &alist, &over);
     if (code)
        return code;
     if (over) {
        fprintf(stderr, "membership list for id %d exceeds display limit\n",
                gid);
     }
-    lids = (idlist *) & alist;
+    lids = (idlist *) &alist;
     code = pr_IdToName(lids, lnames);
+
+    xdr_free((xdrproc_t) xdr_prlist, &alist);
+
     if (code)
        return code;
-    if (alist.prlist_val)
-       free(alist.prlist_val);
     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;
 
-    code = ubik_Call(PR_ListEntry, pruclient, 0, id, aentry);
+    code = ubik_PR_ListEntry(pruclient, 0, id, aentry);
     return 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;
@@ -601,18 +590,15 @@ pr_ListEntries(flag, startindex, nentries, entries, nextstartindex)
     bulkentries.prentries_len = 0;
 
     code =
-       ubik_Call(PR_ListEntries, pruclient, 0, flag, startindex,
+       ubik_PR_ListEntries(pruclient, 0, flag, startindex,
                  &bulkentries, nextstartindex);
     *nentries = bulkentries.prentries_len;
     *entries = bulkentries.prentries_val;
     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;
@@ -623,7 +609,7 @@ pr_CheckEntryByName(name, id, owner, creator)
        return code;
     if (*id == ANONYMOUSID)
        return PRNOENT;
-    code = ubik_Call(PR_ListEntry, pruclient, 0, *id, &aentry);
+    code = ubik_PR_ListEntry(pruclient, 0, *id, &aentry);
     if (code)
        return code;
     /* this should be done in one RPC, but I'm lazy. */
@@ -636,11 +622,8 @@ pr_CheckEntryByName(name, id, owner, creator)
     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;
@@ -651,7 +634,7 @@ pr_CheckEntryById(name, id, owner, creator)
        return code;
     if (id == ANONYMOUSID)
        return PRNOENT;
-    code = ubik_Call(PR_ListEntry, pruclient, 0, id, &aentry);
+    code = ubik_PR_ListEntry(pruclient, 0, id, &aentry);
     if (code)
        return code;
     /* this should be done in one RPC, but I'm lazy. */
@@ -664,11 +647,8 @@ pr_CheckEntryById(name, id, owner, creator)
     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;
@@ -686,14 +666,15 @@ pr_ChangeEntry(oldname, newname, newid, newowner)
        if (oid == ANONYMOUSID)
            return PRNOENT;
     }
-    code = ubik_Call(PR_ChangeEntry, pruclient, 0, id, newname, oid, newid);
+    if (newid)
+       code = ubik_PR_ChangeEntry(pruclient, 0, id, newname, oid, *newid);
+    else
+       code = ubik_PR_ChangeEntry(pruclient, 0, id, newname, oid, 0);
     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;
@@ -702,7 +683,7 @@ pr_IsAMemberOf(uname, gname, flag)
     stolower(uname);
     stolower(gname);
     lnames.namelist_len = 2;
-    lnames.namelist_val = (prname *) malloc(2 * PR_MAXNAMELEN);
+    lnames.namelist_val = malloc(2 * PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], uname, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[1], gname, PR_MAXNAMELEN);
     lids.idlist_val = 0;
@@ -711,82 +692,63 @@ pr_IsAMemberOf(uname, gname, flag)
     if (code) {
        if (lnames.namelist_val)
            free(lnames.namelist_val);
-       if (lids.idlist_val)
-           free(lids.idlist_val);
+       xdr_free((xdrproc_t) xdr_idlist, &lids);
        return code;
     }
     code =
-       ubik_Call(PR_IsAMemberOf, pruclient, 0, lids.idlist_val[0],
+       ubik_PR_IsAMemberOf(pruclient, 0, lids.idlist_val[0],
                  lids.idlist_val[1], flag);
     if (lnames.namelist_val)
        free(lnames.namelist_val);
-    if (lids.idlist_val)
-       free(lids.idlist_val);
+    xdr_free((xdrproc_t) xdr_idlist, &lids);
     return code;
 }
 
-
-pr_ListMaxUserId(mid)
-     afs_int32 *mid;
+int
+pr_ListMaxUserId(afs_int32 *mid)
 {
     register afs_int32 code;
     afs_int32 gid;
-    code = ubik_Call(PR_ListMax, pruclient, 0, mid, &gid);
+    code = ubik_PR_ListMax(pruclient, 0, mid, &gid);
     return code;
 }
 
-pr_SetMaxUserId(mid)
-     afs_int32 mid;
+int
+pr_SetMaxUserId(afs_int32 mid)
 {
     register afs_int32 code;
     afs_int32 flag = 0;
-    code = ubik_Call(PR_SetMax, pruclient, 0, mid, flag);
+    code = ubik_PR_SetMax(pruclient, 0, mid, flag);
     return code;
 }
 
-pr_ListMaxGroupId(mid)
-     afs_int32 *mid;
+int
+pr_ListMaxGroupId(afs_int32 *mid)
 {
     register afs_int32 code;
     afs_int32 id;
-    code = ubik_Call(PR_ListMax, pruclient, 0, &id, mid);
+    code = ubik_PR_ListMax(pruclient, 0, &id, mid);
     return code;
 }
 
-pr_SetMaxGroupId(mid)
-     afs_int32 mid;
+int
+pr_SetMaxGroupId(afs_int32 mid)
 {
     register afs_int32 code;
     afs_int32 flag = 0;
 
     flag |= PRGRP;
-    code = ubik_Call(PR_SetMax, pruclient, 0, mid, flag);
+    code = ubik_PR_SetMax(pruclient, 0, mid, flag);
     return code;
 }
 
 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;
 
     code =
-       ubik_Call(PR_SetFieldsEntry, pruclient, 0, id, mask, flags, ngroups,
+       ubik_PR_SetFieldsEntry(pruclient, 0, id, mask, flags, ngroups,
                  nusers, 0, 0);
     return code;
 }
-
-
-int
-stolower(s)
-     char *s;
-{
-    while (*s) {
-       if (isupper(*s))
-           *s = tolower(*s);
-       s++;
-    }
-    return 0;
-}