ptserver-acl-dumpentry-to-disallow-access-based-on-record-20020911
[openafs.git] / src / ptserver / ptprocs.c
index ac984c8..363cdbc 100644 (file)
@@ -25,9 +25,15 @@ RCSID("$Header$");
 #ifdef AFS_NT40_ENV 
 #include <winsock2.h>
 #else
-#include <strings.h>
 #include <netinet/in.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 "afs/audit.h"
@@ -107,9 +113,9 @@ afs_int32 WhoIsThis (acall, at, aid)
        goto done;                      /* no longer supported */
     }
     else if (code == 2) {              /* kad class */
-       if (code = rxkad_GetServerInfo
-           (acall->conn, (afs_int32 *) 0, 0/*was &exp*/,
-            name, inst, tcell, (afs_int32 *) 0))
+       if ((code = rxkad_GetServerInfo
+           (acall->conn, NULL, 0/*was &exp*/,
+            name, inst, tcell, NULL)))
            goto done;
 #if 0
        /* This test is unnecessary, since rxkad_GetServerInfo already check.
@@ -155,7 +161,7 @@ afs_int32 WhoIsThis (acall, at, aid)
     return 0;
 }
 
-afs_int32 PR_INewEntry (call,aname,aid,oid)
+afs_int32 SPR_INewEntry (call,aname,aid,oid)
   struct rx_call *call;
   char aname[PR_MAXNAMELEN];
   afs_int32 aid;
@@ -219,7 +225,7 @@ afs_int32 iNewEntry (call,aname,aid,oid)
 }
 
 
-afs_int32 PR_NewEntry (call, aname, flag, oid, aid)
+afs_int32 SPR_NewEntry (call, aname, flag, oid, aid)
   struct rx_call *call;
   char aname[PR_MAXNAMELEN];
   afs_int32 flag;
@@ -257,7 +263,7 @@ afs_int32 newEntry (call, aname, flag, oid, aid)
     if (code) ABORT_WITH(tt,code);
 
     /* this is for cross-cell self registration. It is not added in the
-     * PR_INewEntry because we want self-registration to only do 
+     * SPR_INewEntry because we want self-registration to only do 
      * automatic id assignment.
      */
     code = WhoIsThisWithName(call,tt,&cid,cname);
@@ -280,7 +286,7 @@ afs_int32 newEntry (call, aname, flag, oid, aid)
 
 
 
-afs_int32 PR_WhereIsIt (call,aid,apos)
+afs_int32 SPR_WhereIsIt (call,aid,apos)
 struct rx_call *call;
 afs_int32 aid;
 afs_int32 *apos;
@@ -319,7 +325,7 @@ afs_int32 *apos;
 }
 
 
-afs_int32 PR_DumpEntry (call,apos, aentry)
+afs_int32 SPR_DumpEntry (call,apos, aentry)
 struct rx_call *call;
 afs_int32 apos;
 struct prdebugentry *aentry;
@@ -354,7 +360,7 @@ struct prdebugentry *aentry;
     code = pr_ReadEntry(tt, 0, apos, aentry);
     if (code) ABORT_WITH(tt,code);
 
-    if (!AccessOK (tt, cid, aentry, PRP_STATUS_MEM, PRP_STATUS_ANY))
+    if (!AccessOK (tt, cid, 0, PRP_STATUS_MEM, 0))
         ABORT_WITH(tt,PRPERM);
 
     /* Since prdebugentry is in the form of a prentry not a coentry, we will
@@ -370,7 +376,7 @@ struct prdebugentry *aentry;
     return PRSUCCESS;
 }
 
-afs_int32 PR_AddToGroup (call,aid,gid)
+afs_int32 SPR_AddToGroup (call,aid,gid)
 struct rx_call *call;
 afs_int32 aid;
 afs_int32 gid;
@@ -433,7 +439,7 @@ afs_int32 gid;
     return PRSUCCESS;
 }
 
-afs_int32 PR_NameToID (call, aname, aid)
+afs_int32 SPR_NameToID (call, aname, aid)
   struct rx_call *call;
   namelist *aname;
   idlist *aid;
@@ -458,7 +464,7 @@ afs_int32 nameToID (call, aname, aid)
 
     /* Initialize return struct */
     aid->idlist_len = 0;
-    aid->idlist_val = (afs_int32 *)0;
+    aid->idlist_val = NULL;
     
     size = aname->namelist_len;
     if (size == 0) return 0;
@@ -489,11 +495,11 @@ afs_int32 nameToID (call, aname, aid)
 }
 
 /*
- * PR_IDToName
+ * SPR_IDToName
  * Given an array of ids, find the name for each of them.
  * The array of ids and names is unlimited.
  */
-afs_int32 PR_IDToName (call, aid, aname)
+afs_int32 SPR_IDToName (call, aid, aname)
   struct rx_call *call;
   idlist *aid;
   namelist *aname;
@@ -518,9 +524,11 @@ afs_int32 idToName (call, aid, aname)
 
     /* leave this first for rpc stub */
     size = aid->idlist_len;
-    if (size <= 0) size = 0;
+    if (size == 0) return 0;
+    if (size <  0) return PRTOOMANY;
     aname->namelist_val = (prname *)malloc(size*PR_MAXNAMELEN);
     aname->namelist_len = 0;
+    if (aname->namelist_val == 0) return PRNOMEM;
     if (aid->idlist_len == 0) return 0;
     if (size == 0) return PRTOOMANY;   /* rxgen will probably handle this */
 
@@ -546,7 +554,7 @@ afs_int32 idToName (call, aid, aname)
     return PRSUCCESS;
 }
 
-afs_int32 PR_Delete (call, aid)
+afs_int32 SPR_Delete (call, aid)
   struct rx_call *call;
   afs_int32 aid;
 {
@@ -685,7 +693,7 @@ afs_int32 Delete (call, aid)
     return PRSUCCESS;
 }
 
-afs_int32 PR_UpdateEntry (call, aid, name, uentry)
+afs_int32 SPR_UpdateEntry (call, aid, name, uentry)
   struct rx_call *call;
   afs_int32 aid;
   char *name;
@@ -750,7 +758,7 @@ afs_int32 PR_UpdateEntry (call, aid, name, uentry)
     return PRSUCCESS;
 }
 
-afs_int32 PR_RemoveFromGroup (call,aid,gid)
+afs_int32 SPR_RemoveFromGroup (call,aid,gid)
 struct rx_call *call;
 afs_int32 aid;
 afs_int32 gid;
@@ -810,7 +818,7 @@ afs_int32 gid;
 }
 
 
-afs_int32 PR_GetCPS (call, aid, alist, over)
+afs_int32 SPR_GetCPS (call, aid, alist, over)
   struct rx_call *call;
   afs_int32 aid;
   prlist *alist;
@@ -837,7 +845,7 @@ afs_int32 getCPS (call, aid, alist, over)
 
     *over = 0;
     alist->prlist_len = 0;
-    alist->prlist_val = (afs_int32 *) 0;
+    alist->prlist_val = NULL;
     code = Initdb();
     if (code != PRSUCCESS) return code;
     code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
@@ -881,7 +889,7 @@ int inCPS (CPS,id)
 #endif /* IP_WILDCARDS */
 
 
-afs_int32 PR_GetCPS2 (call, aid, ahost, alist, over)
+afs_int32 SPR_GetCPS2 (call, aid, ahost, alist, over)
   struct rx_call *call;
   afs_int32 aid;
   afs_int32 ahost;
@@ -918,7 +926,7 @@ afs_int32 getCPS2 (call, aid, ahost, alist, over)
     *over = 0;
     iaddr.s_addr = ntohl(ahost);
     alist->prlist_len = 0;
-    alist->prlist_val = (afs_int32 *) 0;
+    alist->prlist_val = NULL;
     code = Initdb();
     if (code != PRSUCCESS) return code;
     code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
@@ -966,7 +974,7 @@ afs_int32 getCPS2 (call, aid, ahost, alist, over)
 }
 
 
-afs_int32 PR_GetHostCPS (call, ahost, alist, over)
+afs_int32 SPR_GetHostCPS (call, ahost, alist, over)
   struct rx_call *call;
   afs_int32 ahost;
   prlist *alist;
@@ -997,7 +1005,7 @@ afs_int32 getHostCPS (call, ahost, alist, over)
     *over = 0;
     iaddr.s_addr = ntohl(ahost);
     alist->prlist_len = 0;
-    alist->prlist_val = (afs_int32 *) 0;
+    alist->prlist_val = NULL;
     code = Initdb();
     if (code != PRSUCCESS) return code;
     code = ubik_BeginTransReadAny(dbase,UBIK_READTRANS,&tt);
@@ -1031,7 +1039,7 @@ bad:
 }
 
 
-afs_int32 PR_ListMax (call,uid,gid)
+afs_int32 SPR_ListMax (call,uid,gid)
 struct rx_call *call;
 afs_int32 *uid;
 afs_int32 *gid;
@@ -1068,7 +1076,7 @@ afs_int32 *gid;
     return PRSUCCESS;
 }
 
-afs_int32 PR_SetMax (call,aid,gflag)
+afs_int32 SPR_SetMax (call,aid,gflag)
 struct rx_call *call;
 afs_int32 aid;
 afs_int32 gflag;
@@ -1111,7 +1119,7 @@ afs_int32 gflag;
     return PRSUCCESS;
 }
 
-afs_int32 PR_ListEntry (call,aid,aentry)
+afs_int32 SPR_ListEntry (call,aid,aentry)
 struct rx_call *call;
 afs_int32 aid;
 struct prcheckentry *aentry;
@@ -1153,10 +1161,11 @@ struct prcheckentry *aentry;
         ABORT_WITH(tt,PRPERM);
 
     aentry->flags = tentry.flags >> PRIVATE_SHIFT;
-    if (aentry->flags == 0)
+    if (aentry->flags == 0) {
        if (tentry.flags & PRGRP)
            aentry->flags = PRP_GROUP_DEFAULT >> PRIVATE_SHIFT;
        else aentry->flags = PRP_USER_DEFAULT >> PRIVATE_SHIFT;
+    }
     aentry->owner = tentry.owner;
     aentry->id = tentry.id;
     strncpy(aentry->name,tentry.name,PR_MAXNAMELEN);
@@ -1170,7 +1179,7 @@ struct prcheckentry *aentry;
     return PRSUCCESS;
 }
 
-afs_int32 PR_ListEntries(call, flag, startindex, bulkentries, nextstartindex)
+afs_int32 SPR_ListEntries(call, flag, startindex, bulkentries, nextstartindex)
   struct rx_call *call;
   afs_int32          flag;
   afs_int32          startindex;
@@ -1297,7 +1306,7 @@ afs_int32 put_prentries(tentry, bulkentries)
   return 0;
 }
 
-afs_int32 PR_ChangeEntry (call,aid,name,oid,newid)
+afs_int32 SPR_ChangeEntry (call,aid,name,oid,newid)
 struct rx_call *call;
 afs_int32 aid;
 char *name;
@@ -1352,7 +1361,7 @@ afs_int32 newid;
     return code;
 }
 
-afs_int32 PR_SetFieldsEntry (call, id, mask, flags, ngroups, nusers, spare1, spare2)
+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 */
@@ -1437,7 +1446,7 @@ afs_int32 setFieldsEntry (call, id, mask, flags, ngroups, nusers, spare1, spare2
     return code;
 }
 
-afs_int32 PR_ListElements (call, aid, alist, over)
+afs_int32 SPR_ListElements (call, aid, alist, over)
   struct rx_call *call;
   afs_int32 aid;
   prlist *alist;
@@ -1464,7 +1473,7 @@ afs_int32 listElements (call, aid, alist, over)
 
     *over = 0;
     alist->prlist_len = 0;
-    alist->prlist_val = (afs_int32 *) 0;
+    alist->prlist_val = NULL;
 
     code = Initdb();
     if (code != PRSUCCESS) return code;
@@ -1493,13 +1502,13 @@ afs_int32 listElements (call, aid, alist, over)
 }
 
 /* 
- * PR_istOwned
+ * SPR_ListOwned
  * List the entries owned by this id.  If the id is zero,
  * return the orphans list. This will return up to PR_MAXGROUPS
  * at a time with the lastP available to get the rest. The
  * maximum value is enforced in GetOwnedChain().
  */
-afs_int32 PR_ListOwned (call, aid, alist, lastP)
+afs_int32 SPR_ListOwned (call, aid, alist, lastP)
   struct rx_call *call;
   afs_int32 aid;
   prlist *alist;
@@ -1526,7 +1535,7 @@ afs_int32 listOwned (call, aid, alist, lastP)
     afs_int32 start;
 
     alist->prlist_len = 0;
-    alist->prlist_val = (afs_int32 *) 0;
+    alist->prlist_val = NULL;
 
     if (!lastP) return PRBADARG;
     start = *lastP;
@@ -1576,7 +1585,7 @@ afs_int32 listOwned (call, aid, alist, lastP)
     return code;
 }
 
-afs_int32 PR_IsAMemberOf (call,uid,gid,flag)
+afs_int32 SPR_IsAMemberOf (call,uid,gid,flag)
 struct rx_call *call;
 afs_int32 uid;
 afs_int32 gid;
@@ -1635,7 +1644,7 @@ static stolower(s)
 register char *s;
 {
     register int tc;
-    while (tc = *s) {
+    while ((tc = *s)) {
        if (isupper(tc)) *s = tolower(tc);
        s++;
     }
@@ -1656,7 +1665,7 @@ afs_int32 addWildCards(tt,alist,host)
     int size = 0, i, code;
     int added = 0;
  
-    while (host = (host & wild)) {
+    while ((host = (host & wild))) {
        wild = htonl ( ntohl(wild) << 8) ;
        iaddr.s_addr = host;
        code = NameToID(tt, inet_ntoa(iaddr),&hostid);
@@ -1671,14 +1680,14 @@ afs_int32 addWildCards(tt,alist,host)
        } else
            continue;
        wlist.prlist_len = 0;
-       wlist.prlist_val = (afs_int32 *) 0;
+       wlist.prlist_val = NULL;
        
        code = GetList (tt, &tentry, &wlist, 0);
        if (code) return code;
        added +=  wlist.prlist_len;
        for (i=0; i< wlist.prlist_len; i++) {
            if (!inCPS(*alist,wlist.prlist_val[i]))
-               if (code = AddToPRList (alist, &size, wlist.prlist_val[i] )) {
+               if ((code = AddToPRList (alist, &size, wlist.prlist_val[i] ))) {
                    free(wlist.prlist_val);
                    return(code);
                }
@@ -1720,17 +1729,17 @@ afs_int32 WhoIsThisWithName(acall, at, aid, aname)
        int clen;
        extern char *pr_realmName;
 
-       if (code = rxkad_GetServerInfo
-           (acall->conn, (afs_int32 *) 0, 0/*was &exp*/,
-            name, inst, tcell, (afs_int32 *) 0))
+       if ((code = rxkad_GetServerInfo
+           (acall->conn, NULL, 0/*was &exp*/,
+            name, inst, tcell, NULL)))
            goto done;
        strncpy (vname, name, sizeof(vname));
-       if (ilen = strlen (inst)) {
+       if ((ilen = strlen(inst))) {
            if (strlen(vname) + 1 + ilen >= sizeof(vname)) goto done;
            strcat (vname, ".");
            strcat (vname, inst);
        }
-       if (clen = strlen (tcell)){
+       if ( (clen = strlen(tcell))) {
 
 #if    defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
            static char local_realm[AFS_REALM_SZ] = "";