Protect ubik cache accesses
[openafs.git] / src / ptserver / ptprocs.c
index f08a82b..1cd803f 100644 (file)
@@ -50,8 +50,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/stds.h>
 #include <ctype.h>
@@ -69,13 +67,7 @@ RCSID
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #endif
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 #include "ptserver.h"
 #include "pterror.h"
 #include "ptprototypes.h"
@@ -90,37 +82,78 @@ RCSID
 
 extern int restricted;
 extern struct ubik_dbase *dbase;
-extern afs_int32 Initdb();
 extern int pr_noAuth;
-extern afs_int32 initd;
 extern char *pr_realmName;
-afs_int32 iNewEntry(), newEntry(), whereIsIt(), dumpEntry(), addToGroup(),
-nameToID(), Delete(), removeFromGroup();
-afs_int32 getCPS(), getCPS2(), getHostCPS(), listMax(), setMax(), listEntry();
-afs_int32 listEntries(), changeEntry(), setFieldsEntry(), put_prentries();
-afs_int32 listElements(), listOwned(), isAMemberOf(), idToName();
+extern int prp_group_default;
+extern int prp_user_default;
 
+static afs_int32 iNewEntry(struct rx_call *call, char aname[], afs_int32 aid, 
+                          afs_int32 oid, afs_int32 *cid);
+static afs_int32 newEntry(struct rx_call *call, char aname[], afs_int32 flag, 
+                         afs_int32 oid, afs_int32 *aid, afs_int32 *cid);       
+static afs_int32 whereIsIt(struct rx_call *call, afs_int32 aid, afs_int32 *apos,
+                          afs_int32 *cid);
+static afs_int32 dumpEntry(struct rx_call *call, afs_int32 apos, 
+                          struct prdebugentry *aentry, afs_int32 *cid);
+static afs_int32 addToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid, 
+                           afs_int32 *cid);
+static afs_int32 nameToID(struct rx_call *call, namelist *aname, idlist *aid);
+static afs_int32 idToName(struct rx_call *call, idlist *aid, namelist *aname);
+static afs_int32 Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid);
+static afs_int32 UpdateEntry(struct rx_call *call, afs_int32 aid, char *name, 
+                            struct PrUpdateEntry *uentry, afs_int32 *cid);
+static afs_int32 removeFromGroup(struct rx_call *call, afs_int32 aid, 
+                                afs_int32 gid, afs_int32 *cid);
+static afs_int32 getCPS(struct rx_call *call, afs_int32 aid, prlist *alist, 
+                       afs_int32 *over, afs_int32 *cid);
+static afs_int32 getCPS2(struct rx_call *call, afs_int32 aid, afs_int32 ahost,
+                        prlist *alist, afs_int32 *over, afs_int32 *cid);
+static afs_int32 getHostCPS(struct rx_call *call, afs_int32 ahost, 
+                           prlist *alist, afs_int32 *over);
+static afs_int32 listMax(struct rx_call *call, afs_int32 *uid, afs_int32 *gid);
+static afs_int32 setMax(struct rx_call *call, afs_int32 aid, afs_int32 gflag, 
+                       afs_int32 *cid);
+static afs_int32 listEntry(struct rx_call *call, afs_int32 aid, 
+                          struct prcheckentry *aentry, afs_int32 *cid);
+static afs_int32 listEntries(struct rx_call *call, afs_int32 flag, 
+                            afs_int32 startindex, prentries *bulkentries, 
+                            afs_int32 *nextstartindex, afs_int32 *cid);
+static afs_int32 put_prentries(struct prentry *tentry, prentries *bulkentries);
+static afs_int32 changeEntry(struct rx_call *call, afs_int32 aid, char *name, 
+                            afs_int32 oid, afs_int32 newid, afs_int32 *cid);
+static afs_int32 setFieldsEntry(struct rx_call *call, afs_int32 id, 
+                               afs_int32 mask, afs_int32 flags, 
+                               afs_int32 ngroups, afs_int32 nusers, 
+                               afs_int32 spare1, afs_int32 spare2, 
+                               afs_int32 *cid);
+static afs_int32 listElements(struct rx_call *call, afs_int32 aid,
+                             prlist *alist, afs_int32 *over, afs_int32 *cid);
 #if defined(SUPERGROUPS)
-afs_int32 listSuperGroups();
+static afs_int32 listSuperGroups(struct rx_call *call, afs_int32 aid, 
+                                prlist *alist, afs_int32 *over, 
+                                afs_int32 *cid);
 #endif
+static afs_int32 listOwned(struct rx_call *call, afs_int32 aid, prlist *alist,
+                          afs_int32 *lastP, afs_int32 *cid);
+static afs_int32 isAMemberOf(struct rx_call *call, afs_int32 uid, afs_int32 gid,
+                            afs_int32 *flag, afs_int32 *cid);
+#if IP_WILDCARDS
+static afs_int32 addWildCards(struct ubik_trans *tt, prlist *alist, 
+                             afs_int32 host);
+#endif
+static afs_int32 WhoIsThisWithName(struct rx_call *acall, 
+                                  struct ubik_trans *at, afs_int32 *aid, 
+                                  char *aname);
 
-extern int IDCmp();
-
-extern int prp_group_default;
-extern int prp_user_default;
-
-/* When abort, reset initd so that the header is read in on next call.
+/* when we abort, the ubik cachedVersion will be reset, so we'll read in the
+ * header on the next call.
  * Abort the transaction and return the code.
  */
-#define ABORT_WITH(tt,code) return(initd=0,ubik_AbortTrans(tt),code)
+#define ABORT_WITH(tt,code) return(ubik_AbortTrans(tt),code)
 
 static int
-CreateOK(ut, cid, oid, flag, admin)
-     struct ubik_trans *ut;
-     afs_int32 cid;            /* id of caller */
-     afs_int32 oid;            /* id of owner */
-     afs_int32 flag;           /* indicates type of entry */
-     int admin;                        /* sysadmin membership */
+CreateOK(struct ubik_trans *ut, afs_int32 cid, afs_int32 oid, afs_int32 flag, 
+        int admin)
 {
     if (restricted && !admin) 
        return 0;
@@ -146,10 +179,7 @@ CreateOK(ut, cid, oid, flag, admin)
 }
 
 afs_int32
-WhoIsThis(acall, at, aid)
-     struct rx_call *acall;
-     struct ubik_trans *at;
-     afs_int32 *aid;
+WhoIsThis(struct rx_call *acall, struct ubik_trans *at, afs_int32 *aid)
 {
     int foreign = 0;
     /* aid is set to the identity of the caller, if known, else ANONYMOUSID */
@@ -183,7 +213,7 @@ WhoIsThis(acall, at, aid)
            foreign = afs_is_foreign_ticket_name(name,inst,tcell,pr_realmName);
 
        strncpy(vname, name, sizeof(vname));
-       if (ilen = strlen(inst)) {
+       if ((ilen = strlen(inst))) {
            if (strlen(vname) + 1 + ilen >= sizeof(vname))
                goto done;
            strcat(vname, ".");
@@ -209,11 +239,7 @@ WhoIsThis(acall, at, aid)
 }
 
 afs_int32
-SPR_INewEntry(call, aname, aid, oid)
-     struct rx_call *call;
-     char aname[PR_MAXNAMELEN];
-     afs_int32 aid;
-     afs_int32 oid;
+SPR_INewEntry(struct rx_call *call, char aname[], afs_int32 aid, afs_int32 oid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -221,17 +247,13 @@ SPR_INewEntry(call, aname, aid, oid)
     code = iNewEntry(call, aname, aid, oid, &cid);
     osi_auditU(call, PTS_INewEntEvent, code, AUD_ID, aid, AUD_STR, aname,
               AUD_ID, oid, AUD_END);
-    ViceLog(25, ("PTS_INewEntry: code %d cid %d aid %d aname %s oid %d", code, cid, aid, aname, oid));
+    ViceLog(5, ("PTS_INewEntry: code %d cid %d aid %d aname %s oid %d\n", code, cid, aid, aname, oid));
     return code;
 }
 
-afs_int32
-iNewEntry(call, aname, aid, oid, cid)
-     struct rx_call *call;
-     char aname[PR_MAXNAMELEN];
-     afs_int32 aid;
-     afs_int32 oid;
-     afs_int32 * cid;
+static afs_int32
+iNewEntry(struct rx_call *call, char aname[], afs_int32 aid, afs_int32 oid, 
+         afs_int32 *cid)
 {
     /* used primarily for conversion - not intended to be used as usual means
      * of entering people into the database. */
@@ -288,12 +310,8 @@ iNewEntry(call, aname, aid, oid, cid)
 
 
 afs_int32
-SPR_NewEntry(call, aname, flag, oid, aid)
-     struct rx_call *call;
-     char aname[PR_MAXNAMELEN];
-     afs_int32 flag;
-     afs_int32 oid;
-     afs_int32 *aid;
+SPR_NewEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid, 
+            afs_int32 *aid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -301,23 +319,17 @@ SPR_NewEntry(call, aname, flag, oid, aid)
     code = newEntry(call, aname, flag, oid, aid, &cid);
     osi_auditU(call, PTS_NewEntEvent, code, AUD_ID, *aid, AUD_STR, aname,
               AUD_ID, oid, AUD_END);
-    ViceLog(25, ("PTS_NewEntry: code %d cid %d aid %d aname %s oid %d", code, cid, *aid, aname, oid));
+    ViceLog(5, ("PTS_NewEntry: code %d cid %d aid %d aname %s oid %d\n", code, cid, *aid, aname, oid));
     return code;
 }
 
-afs_int32
-newEntry(call, aname, flag, oid, aid, cid)
-     struct rx_call *call;
-     char aname[PR_MAXNAMELEN];
-     afs_int32 flag;
-     afs_int32 oid;
-     afs_int32 *aid;
-     afs_int32 *cid;
+static afs_int32
+newEntry(struct rx_call *call, char aname[], afs_int32 flag, afs_int32 oid, 
+        afs_int32 *aid, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
     int admin;
-    extern afs_int32 WhoIsThisWithName();
     char cname[PR_MAXNAMELEN];
     stolower(aname);
     code = Initdb();
@@ -362,10 +374,7 @@ newEntry(call, aname, flag, oid, aid, cid)
 
 
 afs_int32
-SPR_WhereIsIt(call, aid, apos)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 *apos;
+SPR_WhereIsIt(struct rx_call *call, afs_int32 aid, afs_int32 *apos)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -373,16 +382,12 @@ SPR_WhereIsIt(call, aid, apos)
     code = whereIsIt(call, aid, apos, &cid);
     osi_auditU(call, PTS_WheIsItEvent, code, AUD_ID, aid, AUD_LONG, *apos,
               AUD_END);
-    ViceLog(125, ("PTS_WhereIsIt: code %d cid %d aid %d apos %d", code, cid, aid, *apos));
+    ViceLog(125, ("PTS_WhereIsIt: code %d cid %d aid %d apos %d\n", code, cid, aid, *apos));
     return code;
 }
 
-afs_int32
-whereIsIt(call, aid, apos, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 *apos;
-     afs_int32 *cid;
+static afs_int32
+whereIsIt(struct rx_call *call, afs_int32 aid, afs_int32 *apos, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -417,26 +422,21 @@ whereIsIt(call, aid, apos, cid)
 
 
 afs_int32
-SPR_DumpEntry(call, apos, aentry)
-     struct rx_call *call;
-     afs_int32 apos;
-     struct prdebugentry *aentry;
+SPR_DumpEntry(struct rx_call *call, afs_int32 apos, 
+             struct prdebugentry *aentry)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = dumpEntry(call, apos, aentry, &cid);
     osi_auditU(call, PTS_DmpEntEvent, code, AUD_LONG, apos, AUD_END);
-    ViceLog(125, ("PTS_DumpEntry: code %d cid %d apos %d", code, cid, apos));
+    ViceLog(125, ("PTS_DumpEntry: code %d cid %d apos %d\n", code, cid, apos));
     return code;
 }
 
-afs_int32
-dumpEntry(call, apos, aentry, cid)
-     struct rx_call *call;
-     afs_int32 apos;
-     struct prdebugentry *aentry;
-     afs_int32 *cid;
+static afs_int32
+dumpEntry(struct rx_call *call, afs_int32 apos, struct prdebugentry *aentry, 
+         afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -457,7 +457,7 @@ dumpEntry(call, apos, aentry, cid)
     code = WhoIsThis(call, tt, cid);
     if (code)
        ABORT_WITH(tt, PRPERM);
-    code = pr_ReadEntry(tt, 0, apos, aentry);
+    code = pr_ReadEntry(tt, 0, apos, (struct prentry *)aentry);
     if (code)
        ABORT_WITH(tt, code);
 
@@ -480,10 +480,7 @@ dumpEntry(call, apos, aentry, cid)
 }
 
 afs_int32
-SPR_AddToGroup(call, aid, gid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gid;
+SPR_AddToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -491,16 +488,12 @@ SPR_AddToGroup(call, aid, gid)
     code = addToGroup(call, aid, gid, &cid);
     osi_auditU(call, PTS_AdToGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
               AUD_END);
-    ViceLog(5, ("PTS_AddToGroup: code %d cid %d gid %d aid %d", code, cid, gid, aid));
+    ViceLog(5, ("PTS_AddToGroup: code %d cid %d gid %d aid %d\n", code, cid, gid, aid));
     return code;
 }
 
-afs_int32
-addToGroup(call, aid, gid, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gid;
-     afs_int32 *cid;
+static afs_int32
+addToGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -575,24 +568,18 @@ addToGroup(call, aid, gid, cid)
 }
 
 afs_int32
-SPR_NameToID(call, aname, aid)
-     struct rx_call *call;
-     namelist *aname;
-     idlist *aid;
+SPR_NameToID(struct rx_call *call, namelist *aname, idlist *aid)
 {
     afs_int32 code;
 
     code = nameToID(call, aname, aid);
     osi_auditU(call, PTS_NmToIdEvent, code, AUD_END);
-    ViceLog(125, ("PTS_NameToID: code %d", code));
+    ViceLog(125, ("PTS_NameToID: code %d\n", code));
     return code;
 }
 
-afs_int32
-nameToID(call, aname, aid)
-     struct rx_call *call;
-     namelist *aname;
-     idlist *aid;
+static afs_int32
+nameToID(struct rx_call *call, namelist *aname, idlist *aid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -628,16 +615,37 @@ nameToID(call, aname, aid)
        ABORT_WITH(tt, code);
 
     for (i = 0; i < aname->namelist_len; i++) {
-       code = NameToID(tt, aname->namelist_val[i], &aid->idlist_val[i]);
+       char vname[256];
+       char *nameinst, *cell;
+
+       strncpy(vname, aname->namelist_val[i], sizeof(vname));
+       vname[sizeof(vname)-1] ='\0';
+
+       nameinst = vname;
+       cell = strchr(vname, '@');
+       if (cell) {
+           *cell = '\0';
+           cell++;
+       }
+
+       if (cell && afs_is_foreign_ticket_name(nameinst,NULL,cell,pr_realmName))
+           code = NameToID(tt, aname->namelist_val[i], &aid->idlist_val[i]);
+       else 
+           code = NameToID(tt, nameinst, &aid->idlist_val[i]);
+
        if (code != PRSUCCESS)
            aid->idlist_val[i] = ANONYMOUSID;
         osi_audit(PTS_NmToIdEvent, code, AUD_STR,
                   aname->namelist_val[i], AUD_ID, aid->idlist_val[i], 
                   AUD_END);
-       ViceLog(125, ("PTS_NameToID: code %d aname %s aid %d", code,
+       ViceLog(125, ("PTS_NameToID: code %d aname %s aid %d\n", code,
                      aname->namelist_val[i], aid->idlist_val[i]));
-       if (count++ > 50)
-           IOMGR_Poll(), count = 0;
+       if (count++ > 50) {
+#ifndef AFS_PTHREAD_ENV
+           IOMGR_Poll();
+#endif
+           count = 0;
+       }
     }
     aid->idlist_len = aname->namelist_len;
 
@@ -653,24 +661,18 @@ nameToID(call, aname, aid)
  * The array of ids and names is unlimited.
  */
 afs_int32
-SPR_IDToName(call, aid, aname)
-     struct rx_call *call;
-     idlist *aid;
-     namelist *aname;
+SPR_IDToName(struct rx_call *call, idlist *aid, namelist *aname)
 {
     afs_int32 code;
 
     code = idToName(call, aid, aname);
     osi_auditU(call, PTS_IdToNmEvent, code, AUD_END);
-    ViceLog(125, ("PTS_IDToName: code %d", code));
+    ViceLog(125, ("PTS_IDToName: code %d\n", code));
     return code;
 }
 
-afs_int32
-idToName(call, aid, aname)
-     struct rx_call *call;
-     idlist *aid;
-     namelist *aname;
+static afs_int32
+idToName(struct rx_call *call, idlist *aid, namelist *aname)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -712,10 +714,14 @@ idToName(call, aid, aname)
            sprintf(aname->namelist_val[i], "%d", aid->idlist_val[i]);
         osi_audit(PTS_IdToNmEvent, code, AUD_ID, aid->idlist_val[i],
                  AUD_STR, aname->namelist_val[i], AUD_END);
-       ViceLog(125, ("PTS_idToName: code %d aid %d aname %s", code,
+       ViceLog(125, ("PTS_idToName: code %d aid %d aname %s\n", code,
                      aid->idlist_val[i], aname->namelist_val[i]));
-       if (count++ > 50)
-           IOMGR_Poll(), count = 0;
+       if (count++ > 50) {
+#ifndef AFS_PTHREAD_ENV
+           IOMGR_Poll();
+#endif
+           count = 0;
+       }
     }
     aname->namelist_len = aid->idlist_len;
 
@@ -726,24 +732,19 @@ idToName(call, aid, aname)
 }
 
 afs_int32
-SPR_Delete(call, aid)
-     struct rx_call *call;
-     afs_int32 aid;
+SPR_Delete(struct rx_call *call, afs_int32 aid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = Delete(call, aid, &cid);
     osi_auditU(call, PTS_DelEvent, code, AUD_ID, aid, AUD_END);
-    ViceLog(25, ("PTS_Delete: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(5, ("PTS_Delete: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 }
 
-afs_int32
-Delete(call, aid, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 *cid;
+static afs_int32
+Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -789,7 +790,7 @@ Delete(call, aid, cid)
     /* Delete each continuation block as a separate transaction so that no one
      * transaction become to large to complete. */
     nptr = tentry.next;
-    while (nptr != (afs_int32) NULL) {
+    while (nptr != 0) {
        struct contentry centry;
        int i;
 
@@ -810,8 +811,10 @@ Delete(call, aid, cid)
            if (code)
                ABORT_WITH(tt, code);
            tentry.count--;     /* maintain count */
+#ifndef AFS_PTHREAD_ENV
            if ((i & 3) == 0)
                IOMGR_Poll();
+#endif
        }
        tentry.next = centry.next;      /* thread out this block */
        code = FreeBlock(tt, nptr);     /* free continuation block */
@@ -825,7 +828,9 @@ Delete(call, aid, cid)
        code = ubik_EndTrans(tt);
        if (code)
            return code;
+#ifndef AFS_PTHREAD_ENV
        IOMGR_Poll();           /* just to keep the connection alive */
+#endif
        code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
        if (code)
            return code;
@@ -850,7 +855,7 @@ Delete(call, aid, cid)
     {
        struct prentryg *tentryg = (struct prentryg *)&tentry;
        nptr = tentryg->nextsg;
-       while (nptr != NULL) {
+       while (nptr != 0) {
            struct contentry centry;
            int i;
 
@@ -866,8 +871,10 @@ Delete(call, aid, cid)
                if (code)
                    ABORT_WITH(tt, code);
                tentryg->countsg--;     /* maintain count */
+#ifndef AFS_PTHREAD_ENV
                if ((i & 3) == 0)
                    IOMGR_Poll();
+#endif
            }
            tentryg->nextsg = centry.next;      /* thread out this block */
            code = FreeBlock(tt, nptr); /* free continuation block */
@@ -881,7 +888,9 @@ Delete(call, aid, cid)
            code = ubik_EndTrans(tt);
            if (code)
                return code;
+#ifndef AFS_PTHREAD_ENV
            IOMGR_Poll();       /* just to keep the connection alive */
+#endif
 
            code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
            if (code)
@@ -909,7 +918,7 @@ Delete(call, aid, cid)
      * transaction, we start a new transaction every 50 entries. */
     count = 0;
     nptr = tentry.owned;
-    while (nptr != (afs_int32) NULL) {
+    while (nptr != 0) {
        struct prentry nentry;
 
        code = pr_ReadEntry(tt, 0, nptr, &nentry);
@@ -922,8 +931,10 @@ Delete(call, aid, cid)
            if (code)
                ABORT_WITH(tt, code);
            count++;
+#ifndef AFS_PTHREAD_ENV
            if ((count & 3) == 0)
                IOMGR_Poll();
+#endif
        }
        if (count < 50)
            continue;
@@ -935,7 +946,9 @@ Delete(call, aid, cid)
        code = ubik_EndTrans(tt);
        if (code)
            return code;
+#ifndef AFS_PTHREAD_ENV
        IOMGR_Poll();           /* just to keep the connection alive */
+#endif
        code = ubik_BeginTrans(dbase, UBIK_WRITETRANS, &tt);
        if (code)
            return code;
@@ -966,28 +979,21 @@ Delete(call, aid, cid)
 }
 
 afs_int32
-SPR_UpdateEntry(call, aid, name, uentry)
-     struct rx_call *call;
-     afs_int32 aid;
-     char *name;
-     struct PrUpdateEntry *uentry;
+SPR_UpdateEntry(struct rx_call *call, afs_int32 aid, char *name, 
+               struct PrUpdateEntry *uentry)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = UpdateEntry(call, aid, name, uentry, &cid);
     osi_auditU(call, PTS_UpdEntEvent, code, AUD_ID, aid, AUD_STR, name, AUD_END);
-    ViceLog(5, ("PTS_UpdateEntry: code %d cid %d aid %d name %s", code, cid, aid, name));
+    ViceLog(5, ("PTS_UpdateEntry: code %d cid %d aid %d name %s\n", code, cid, aid, name));
     return code;
 }
 
 afs_int32
-UpdateEntry(call, aid, name, uentry, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     char *name;
-     struct PrUpdateEntry *uentry;
-     afs_int32 *cid;
+UpdateEntry(struct rx_call *call, afs_int32 aid, char *name, 
+           struct PrUpdateEntry *uentry, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1064,10 +1070,7 @@ UpdateEntry(call, aid, name, uentry, cid)
 }
 
 afs_int32
-SPR_RemoveFromGroup(call, aid, gid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gid;
+SPR_RemoveFromGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -1075,16 +1078,13 @@ SPR_RemoveFromGroup(call, aid, gid)
     code = removeFromGroup(call, aid, gid, &cid);
     osi_auditU(call, PTS_RmFmGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
               AUD_END);
-    ViceLog(5, ("PTS_RemoveFromGroup: code %d cid %d gid %d aid %d", code, cid, gid, aid));
+    ViceLog(5, ("PTS_RemoveFromGroup: code %d cid %d gid %d aid %d\n", code, cid, gid, aid));
     return code;
 }
 
-afs_int32
-removeFromGroup(call, aid, gid, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gid;
-     afs_int32 *cid;
+static afs_int32
+removeFromGroup(struct rx_call *call, afs_int32 aid, afs_int32 gid, 
+               afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1153,28 +1153,20 @@ removeFromGroup(call, aid, gid, cid)
 
 
 afs_int32
-SPR_GetCPS(call, aid, alist, over)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
+SPR_GetCPS(struct rx_call *call, afs_int32 aid, prlist *alist, afs_int32 *over)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = getCPS(call, aid, alist, over, &cid);
     osi_auditU(call, PTS_GetCPSEvent, code, AUD_ID, aid, AUD_END);
-    ViceLog(125, ("PTS_GetCPS: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(125, ("PTS_GetCPS: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 }
 
-afs_int32
-getCPS(call, aid, alist, over, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
-     afs_int32 *cid;
+static afs_int32
+getCPS(struct rx_call *call, afs_int32 aid, prlist *alist, afs_int32 *over, 
+       afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1220,9 +1212,7 @@ getCPS(call, aid, alist, over, cid)
 
 #ifdef IP_WILDCARDS
 int
-inCPS(CPS, id)
-     prlist CPS;
-     afs_int32 id;
+inCPS(prlist CPS, afs_int32 id)
 {
     int i;
 
@@ -1236,12 +1226,8 @@ inCPS(CPS, id)
 
 
 afs_int32
-SPR_GetCPS2(call, aid, ahost, alist, over)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 ahost;
-     prlist *alist;
-     afs_int32 *over;
+SPR_GetCPS2(struct rx_call *call, afs_int32 aid, afs_int32 ahost, 
+           prlist *alist, afs_int32 *over)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -1249,18 +1235,13 @@ SPR_GetCPS2(call, aid, ahost, alist, over)
     code = getCPS2(call, aid, ahost, alist, over, &cid);
     osi_auditU(call, PTS_GetCPS2Event, code, AUD_ID, aid, AUD_HOST, ahost,
               AUD_END);
-    ViceLog(125, ("PTS_GetCPS2: code %d cid %d aid %d ahost %d", code, cid, aid, ahost));
+    ViceLog(125, ("PTS_GetCPS2: code %d cid %d aid %d ahost %d\n", code, cid, aid, ahost));
     return code;
 }
 
-afs_int32
-getCPS2(call, aid, ahost, alist, over, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 ahost;
-     prlist *alist;
-     afs_int32 *over;
-     afs_int32 *cid;
+static afs_int32
+getCPS2(struct rx_call *call, afs_int32 aid, afs_int32 ahost, prlist *alist, 
+       afs_int32 *over, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1270,9 +1251,6 @@ getCPS2(call, aid, ahost, alist, over, cid)
     afs_int32 hostid;
     int host_list = 0;
     struct in_addr iaddr;
-#if IP_WILDCARDS
-    extern afs_int32 addWildCards();
-#endif /* IP_WILDCARDS */
 
     *over = 0;
     iaddr.s_addr = ntohl(ahost);
@@ -1334,35 +1312,26 @@ getCPS2(call, aid, ahost, alist, over, cid)
 
 
 afs_int32
-SPR_GetHostCPS(call, ahost, alist, over)
-     struct rx_call *call;
-     afs_int32 ahost;
-     prlist *alist;
-     afs_int32 *over;
+SPR_GetHostCPS(struct rx_call *call, afs_int32 ahost, prlist *alist, 
+              afs_int32 *over)
 {
     afs_int32 code;
 
     code = getHostCPS(call, ahost, alist, over);
     osi_auditU(call, PTS_GetHCPSEvent, code, AUD_HOST, ahost, AUD_END);
-    ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d", code, ahost));
+    ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d\n", code, ahost));
     return code;
 }
 
 afs_int32
-getHostCPS(call, ahost, alist, over)
-     struct rx_call *call;
-     afs_int32 ahost;
-     prlist *alist;
-     afs_int32 *over;
+getHostCPS(struct rx_call *call, afs_int32 ahost, prlist *alist, 
+          afs_int32 *over)
 {
     register afs_int32 code, temp;
     struct ubik_trans *tt;
     struct prentry host_tentry;
     afs_int32 hostid;
     struct in_addr iaddr;
-#if IP_WILDCARDS
-    extern afs_int32 addWildCards();
-#endif /* IP_WILDCARDS */
 
     *over = 0;
     iaddr.s_addr = ntohl(ahost);
@@ -1408,24 +1377,18 @@ getHostCPS(call, ahost, alist, over)
 
 
 afs_int32
-SPR_ListMax(call, uid, gid)
-     struct rx_call *call;
-     afs_int32 *uid;
-     afs_int32 *gid;
+SPR_ListMax(struct rx_call *call, afs_int32 *uid, afs_int32 *gid)
 {
     afs_int32 code;
 
     code = listMax(call, uid, gid);
     osi_auditU(call, PTS_LstMaxEvent, code, AUD_END);
-    ViceLog(125, ("PTS_ListMax: code %d", code));
+    ViceLog(125, ("PTS_ListMax: code %d\n", code));
     return code;
 }
 
 afs_int32
-listMax(call, uid, gid)
-     struct rx_call *call;
-     afs_int32 *uid;
-     afs_int32 *gid;
+listMax(struct rx_call *call, afs_int32 *uid, afs_int32 *gid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1454,10 +1417,7 @@ listMax(call, uid, gid)
 }
 
 afs_int32
-SPR_SetMax(call, aid, gflag)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gflag;
+SPR_SetMax(struct rx_call *call, afs_int32 aid, afs_int32 gflag)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -1465,16 +1425,12 @@ SPR_SetMax(call, aid, gflag)
     code = setMax(call, aid, gflag, &cid);
     osi_auditU(call, PTS_SetMaxEvent, code, AUD_ID, aid, AUD_LONG, gflag,
               AUD_END);
-    ViceLog(125, ("PTS_SetMax: code %d cid %d aid %d gflag %d", code, cid, aid, gflag));
+    ViceLog(125, ("PTS_SetMax: code %d cid %d aid %d gflag %d\n", code, cid, aid, gflag));
     return code;
 }
 
-afs_int32
-setMax(call, aid, gflag, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     afs_int32 gflag;
-     afs_int32 *cid;
+static afs_int32
+setMax(struct rx_call *call, afs_int32 aid, afs_int32 gflag, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1511,26 +1467,20 @@ setMax(call, aid, gflag, cid)
 }
 
 afs_int32
-SPR_ListEntry(call, aid, aentry)
-     struct rx_call *call;
-     afs_int32 aid;
-     struct prcheckentry *aentry;
+SPR_ListEntry(struct rx_call *call, afs_int32 aid, struct prcheckentry *aentry)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = listEntry(call, aid, aentry, &cid);
     osi_auditU(call, PTS_LstEntEvent, code, AUD_ID, aid, AUD_END);
-    ViceLog(125, ("PTS_ListEntry: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(125, ("PTS_ListEntry: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 }
 
-afs_int32
-listEntry(call, aid, aentry, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     struct prcheckentry *aentry;
-     afs_int32 *cid;
+static afs_int32
+listEntry(struct rx_call *call, afs_int32 aid, struct prcheckentry *aentry, 
+         afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1584,30 +1534,21 @@ listEntry(call, aid, aentry, cid)
 }
 
 afs_int32
-SPR_ListEntries(call, flag, startindex, bulkentries, nextstartindex)
-     struct rx_call *call;
-     afs_int32 flag;
-     afs_int32 startindex;
-     prentries *bulkentries;
-     afs_int32 *nextstartindex;
+SPR_ListEntries(struct rx_call *call, afs_int32 flag, afs_int32 startindex, 
+               prentries *bulkentries, afs_int32 *nextstartindex)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = listEntries(call, flag, startindex, bulkentries, nextstartindex, &cid);
     osi_auditU(call, PTS_LstEntsEvent, code, AUD_LONG, flag, AUD_END);
-    ViceLog(125, ("PTS_ListEntries: code %d cid %d flag %d", code, cid, flag));
+    ViceLog(125, ("PTS_ListEntries: code %d cid %d flag %d\n", code, cid, flag));
     return code;
 }
 
-afs_int32
-listEntries(call, flag, startindex, bulkentries, nextstartindex, cid)
-     struct rx_call *call;
-     afs_int32 flag;
-     afs_int32 startindex;
-     prentries *bulkentries;
-     afs_int32 *nextstartindex;
-     afs_int32 *cid;
+static afs_int32
+listEntries(struct rx_call *call, afs_int32 flag, afs_int32 startindex, 
+           prentries *bulkentries, afs_int32 *nextstartindex, afs_int32 *cid)
 {
     afs_int32 code;
     struct ubik_trans *tt;
@@ -1651,7 +1592,9 @@ listEntries(call, flag, startindex, bulkentries, nextstartindex, cid)
            goto done;
 
        if (++pollcount > 50) {
+#ifndef AFS_PTHREAD_ENV
            IOMGR_Poll();
+#endif
            pollcount = 0;
        }
 
@@ -1685,10 +1628,8 @@ listEntries(call, flag, startindex, bulkentries, nextstartindex, cid)
 }
 
 #define PR_MAXENTRIES 500
-afs_int32
-put_prentries(tentry, bulkentries)
-     struct prentry *tentry;
-     prentries *bulkentries;
+static afs_int32
+put_prentries(struct prentry *tentry, prentries *bulkentries)
 {
     struct prlistentries *entry;
 
@@ -1729,12 +1670,8 @@ put_prentries(tentry, bulkentries)
 }
 
 afs_int32
-SPR_ChangeEntry(call, aid, name, oid, newid)
-     struct rx_call *call;
-     afs_int32 aid;
-     char *name;
-     afs_int32 oid;
-     afs_int32 newid;
+SPR_ChangeEntry(struct rx_call *call, afs_int32 aid, char *name, afs_int32 oid, 
+               afs_int32 newid)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -1742,18 +1679,13 @@ SPR_ChangeEntry(call, aid, name, oid, newid)
     code = changeEntry(call, aid, name, oid, newid, &cid);
     osi_auditU(call, PTS_ChgEntEvent, code, AUD_ID, aid, AUD_STR, name,
               AUD_LONG, oid, AUD_LONG, newid, AUD_END);
-    ViceLog(5, ("PTS_ChangeEntry: code %d cid %d aid %d name %s oid %d newid %d", code, cid, aid, name, oid, newid));
+    ViceLog(5, ("PTS_ChangeEntry: code %d cid %d aid %d name %s oid %d newid %d\n", code, cid, aid, name, oid, newid));
     return code;
 }
 
-afs_int32
-changeEntry(call, aid, name, oid, newid, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     char *name;
-     afs_int32 oid;
-     afs_int32 newid;
-     afs_int32 *cid;
+static afs_int32
+changeEntry(struct rx_call *call, afs_int32 aid, char *name, afs_int32 oid, 
+           afs_int32 newid, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1797,12 +1729,11 @@ changeEntry(call, aid, name, oid, newid, cid)
 }
 
 afs_int32
-SPR_SetFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2)
-     struct rx_call *call;
-     afs_int32 id;
-     afs_int32 mask;           /* specify which fields to update */
-     afs_int32 flags, ngroups, nusers;
-     afs_int32 spare1, spare2;
+SPR_SetFieldsEntry(struct rx_call *call, 
+                  afs_int32 id, 
+                  afs_int32 mask, /* specify which fields to update */ 
+                  afs_int32 flags, afs_int32 ngroups, afs_int32 nusers, 
+                  afs_int32 spare1, afs_int32 spare2)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -1811,18 +1742,16 @@ SPR_SetFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2)
        setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1,
                       spare2, &cid);
     osi_auditU(call, PTS_SetFldEntEvent, code, AUD_ID, id, AUD_END);
-    ViceLog(5, ("PTS_SetFieldsEntry: code %d cid %d id %d", code, cid, id));
+    ViceLog(5, ("PTS_SetFieldsEntry: code %d cid %d id %d\n", code, cid, id));
     return code;
 }
 
-afs_int32
-setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2, cid)
-     struct rx_call *call;
-     afs_int32 id;
-     afs_int32 mask;           /* specify which fields to update */
-     afs_int32 flags, ngroups, nusers;
-     afs_int32 spare1, spare2;
-     afs_int32 *cid;
+static afs_int32
+setFieldsEntry(struct rx_call *call, 
+              afs_int32 id, 
+              afs_int32 mask, /* specify which fields to update */ 
+              afs_int32 flags, afs_int32 ngroups, afs_int32 nusers, 
+              afs_int32 spare1, afs_int32 spare2, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1902,28 +1831,21 @@ setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2, cid)
 }
 
 afs_int32
-SPR_ListElements(call, aid, alist, over)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
+SPR_ListElements(struct rx_call *call, afs_int32 aid, prlist *alist, 
+                afs_int32 *over)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = listElements(call, aid, alist, over, &cid);
     osi_auditU(call, PTS_LstEleEvent, code, AUD_ID, aid, AUD_END);
-    ViceLog(125, ("PTS_ListElements: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(125, ("PTS_ListElements: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 }
 
-afs_int32
-listElements(call, aid, alist, over, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
-     afs_int32 *cid;
+static afs_int32
+listElements(struct rx_call *call, afs_int32 aid, prlist *alist, 
+            afs_int32 *over, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -1970,11 +1892,8 @@ listElements(call, aid, alist, over, cid)
 
 
 afs_int32
-SPR_ListSuperGroups(call, aid, alist, over)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
+SPR_ListSuperGroups(struct rx_call *call, afs_int32 aid, prlist *alist, 
+                   afs_int32 *over)
 {
 #if defined(SUPERGROUPS)
     afs_int32 code;
@@ -1982,7 +1901,7 @@ SPR_ListSuperGroups(call, aid, alist, over)
 
     code = listSuperGroups(call, aid, alist, over, &cid);
     osi_auditU(call, PTS_LstSGrps, code, AUD_ID, aid, AUD_END);
-    ViceLog(125, ("PTS_ListSuperGroups: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(125, ("PTS_ListSuperGroups: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 #else
     return RXGEN_OPCODE;
@@ -1990,13 +1909,9 @@ SPR_ListSuperGroups(call, aid, alist, over)
 }
 
 #if defined(SUPERGROUPS)
-afs_int32
-listSuperGroups(call, aid, alist, over, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *over;
-     afs_int32 *cid;
+static afs_int32
+listSuperGroups(struct rx_call *call, afs_int32 aid, prlist *alist, 
+               afs_int32 *over, afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -2051,28 +1966,21 @@ listSuperGroups(call, aid, alist, over, cid)
  * maximum value is enforced in GetOwnedChain().
  */
 afs_int32
-SPR_ListOwned(call, aid, alist, lastP)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *lastP;
+SPR_ListOwned(struct rx_call *call, afs_int32 aid, prlist *alist, 
+             afs_int32 *lastP)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
 
     code = listOwned(call, aid, alist, lastP, &cid);
     osi_auditU(call, PTS_LstOwnEvent, code, AUD_ID, aid, AUD_END);
-    ViceLog(125, ("PTS_ListOwned: code %d cid %d aid %d", code, cid, aid));
+    ViceLog(125, ("PTS_ListOwned: code %d cid %d aid %d\n", code, cid, aid));
     return code;
 }
 
 afs_int32
-listOwned(call, aid, alist, lastP, cid)
-     struct rx_call *call;
-     afs_int32 aid;
-     prlist *alist;
-     afs_int32 *lastP;
-     afs_int32 *cid;
+listOwned(struct rx_call *call, afs_int32 aid, prlist *alist, afs_int32 *lastP, 
+         afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -2143,11 +2051,8 @@ listOwned(call, aid, alist, lastP, cid)
 }
 
 afs_int32
-SPR_IsAMemberOf(call, uid, gid, flag)
-     struct rx_call *call;
-     afs_int32 uid;
-     afs_int32 gid;
-     afs_int32 *flag;
+SPR_IsAMemberOf(struct rx_call *call, afs_int32 uid, afs_int32 gid, 
+               afs_int32 *flag)
 {
     afs_int32 code;
     afs_int32 cid = ANONYMOUSID;
@@ -2155,17 +2060,13 @@ SPR_IsAMemberOf(call, uid, gid, flag)
     code = isAMemberOf(call, uid, gid, flag, &cid);
     osi_auditU(call, PTS_IsMemOfEvent, code, AUD_LONG, uid, AUD_LONG, gid,
               AUD_END);
-    ViceLog(125, ("PTS_IsAMemberOf: code %d cid %d uid %d gid %d", code, cid, uid, gid));
+    ViceLog(125, ("PTS_IsAMemberOf: code %d cid %d uid %d gid %d\n", code, cid, uid, gid));
     return code;
 }
 
-afs_int32
-isAMemberOf(call, uid, gid, flag, cid)
-     struct rx_call *call;
-     afs_int32 uid;
-     afs_int32 gid;
-     afs_int32 *flag;
-     afs_int32 *cid;
+static afs_int32
+isAMemberOf(struct rx_call *call, afs_int32 uid, afs_int32 gid, afs_int32 *flag,
+           afs_int32 *cid)
 {
     register afs_int32 code;
     struct ubik_trans *tt;
@@ -2217,11 +2118,8 @@ isAMemberOf(call, uid, gid, flag, cid)
 }
 
 #if IP_WILDCARDS
-afs_int32
-addWildCards(tt, alist, host)
-     struct ubik_trans *tt;
-     prlist *alist;
-     afs_int32 host;
+static afs_int32
+addWildCards(struct ubik_trans *tt, prlist *alist, afs_int32 host)
 {
     afs_int32 temp;
     struct prentry tentry;
@@ -2269,12 +2167,9 @@ addWildCards(tt, alist, host)
 }
 #endif /* IP_WILDCARDS */
 
-afs_int32
-WhoIsThisWithName(acall, at, aid, aname)
-     struct rx_call *acall;
-     struct ubik_trans *at;
-     afs_int32 *aid;
-     char *aname;
+static afs_int32
+WhoIsThisWithName(struct rx_call *acall, struct ubik_trans *at, afs_int32 *aid, 
+                 char *aname)
 {
     /* aid is set to the identity of the caller, if known, else ANONYMOUSID */
     /* returns -1 and sets aid to ANONYMOUSID on any failure */