viced: RXAFS_GetVolumeStatus remove access check
[openafs.git] / src / viced / afsfileprocs.c
index 730d371..f99326e 100644 (file)
@@ -790,6 +790,7 @@ VanillaUser(struct client *client)
  *      locktype            : indicates what kind of lock to take on vnodes
  *      rights              : returns a pointer to caller's rights
  *      anyrights           : returns a pointer to anonymous' rights
+ *      remote             : indicates that the volume is a remote RW replica
  *
  * Returns:
  *      0 on success
@@ -807,7 +808,7 @@ GetVolumePackageWithCall(struct rx_call *acall, struct VCallByVol *cbv,
                          AFSFid * Fid, Volume ** volptr, Vnode ** targetptr,
                          int chkforDir, Vnode ** parent,
                         struct client **client, int locktype,
-                        afs_int32 * rights, afs_int32 * anyrights)
+                        afs_int32 * rights, afs_int32 * anyrights, int remote)
 {
     struct acl_accessList *aCL;        /* Internal access List */
     int aCLSize;               /* size of the access list */
@@ -831,35 +832,41 @@ GetVolumePackageWithCall(struct rx_call *acall, struct VCallByVol *cbv,
            goto gvpdone;
        }
     }
-    if ((errorCode =
-        SetAccessList(targetptr, volptr, &aCL, &aCLSize, parent,
-                      (chkforDir == MustBeDIR ? (AFSFid *) 0 : Fid),
-                      (chkforDir == MustBeDIR ? 0 : locktype))) != 0)
-       goto gvpdone;
-    if (chkforDir == MustBeDIR)
-       osi_Assert((*parent) == 0);
-    if (!(*client)) {
-       if ((errorCode = GetClient(tcon, client)) != 0)
+    /*
+     * If the remote flag is set, the current call is dealing with a remote RW
+     * replica, and it can be assumed that the appropriate access checks were
+     * done by the calling server hosting the master volume.
+     */
+    if (!remote) {
+       if ((errorCode = SetAccessList(targetptr, volptr, &aCL, &aCLSize, parent,
+               (chkforDir == MustBeDIR ? (AFSFid *) 0 : Fid),
+               (chkforDir == MustBeDIR ? 0 : locktype))) != 0)
            goto gvpdone;
+       if (chkforDir == MustBeDIR)
+           osi_Assert((*parent) == 0);
        if (!(*client)) {
-           errorCode = EINVAL;
-           goto gvpdone;
+           if ((errorCode = GetClient(tcon, client)) != 0)
+               goto gvpdone;
+           if (!(*client)) {
+               errorCode = EINVAL;
+               goto gvpdone;
+           }
+       }
+       GetRights(*client, aCL, rights, anyrights);
+       /* ok, if this is not a dir, set the PRSFS_ADMINISTER bit iff we're the owner */
+       if ((*targetptr)->disk.type != vDirectory) {
+           /* anyuser can't be owner, so only have to worry about rights, not anyrights */
+           if ((*targetptr)->disk.owner == (*client)->ViceId)
+               (*rights) |= PRSFS_ADMINISTER;
+           else
+               (*rights) &= ~PRSFS_ADMINISTER;
        }
-    }
-    GetRights(*client, aCL, rights, anyrights);
-    /* ok, if this is not a dir, set the PRSFS_ADMINISTER bit iff we're the owner */
-    if ((*targetptr)->disk.type != vDirectory) {
-       /* anyuser can't be owner, so only have to worry about rights, not anyrights */
-       if ((*targetptr)->disk.owner == (*client)->ViceId)
-           (*rights) |= PRSFS_ADMINISTER;
-       else
-           (*rights) &= ~PRSFS_ADMINISTER;
-    }
 #ifdef ADMIN_IMPLICIT_LOOKUP
-    /* admins get automatic lookup on everything */
-    if (!VanillaUser(*client))
-       (*rights) |= PRSFS_LOOKUP;
+       /* admins get automatic lookup on everything */
+       if (!VanillaUser(*client))
+           (*rights) |= PRSFS_LOOKUP;
 #endif /* ADMIN_IMPLICIT_LOOKUP */
+    }
 gvpdone:
     if (errorCode)
        rx_KeepAliveOn(acall);
@@ -875,7 +882,7 @@ GetVolumePackage(struct rx_call *acall, AFSFid * Fid, Volume ** volptr,
 {
     return GetVolumePackageWithCall(acall, NULL, Fid, volptr, targetptr,
                                     chkforDir, parent, client, locktype,
-                                    rights, anyrights);
+                                    rights, anyrights, 0);
 }
 
 
@@ -1249,7 +1256,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len)
     if (size > len)
        size = len;
 
-    buff = (char *)malloc(COPYBUFFSIZE);
+    buff = malloc(COPYBUFFSIZE);
     if (buff == NULL) {
        return EIO;
     }
@@ -1326,7 +1333,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len)
                IH_RELEASE(newH);
                FDH_REALLYCLOSE(targFdP);
                rc = IH_DEC(V_linkHandle(volptr), ino, V_parentId(volptr));
-               if (!rc) {
+               if (rc) {
                    ViceLog(0,
                            ("CopyOnWrite failed: error %u after i_dec on disk full, volume %u in partition %s needs salvage\n",
                             rc, V_id(volptr), volptr->partition->name));
@@ -1586,6 +1593,8 @@ Update_ParentVnodeStatus(Vnode * parentptr, Volume * volptr, DirHandle * dir,
  * Update the target file's (or dir's) status block after the specified
  * operation is complete. Note that some other fields maybe updated by
  * the individual module.
+ * If remote is set, the volume is a RW replica and access checks can
+ * be skipped.
  */
 
 /* XXX INCOMPLETE - More attention is needed here! */
@@ -1593,7 +1602,7 @@ static void
 Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
                         struct client *client, AFSStoreStatus * InStatus,
                         Vnode * parentptr, Volume * volptr,
-                        afs_fsize_t length)
+                        afs_fsize_t length, int remote)
 {
     Date currDate;             /*Current date */
     int writeIdx;              /*Write index to bump */
@@ -1654,7 +1663,7 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
        targetptr->disk.author = client->ViceId;
     if (Caller & TVS_SDATA) {
        targetptr->disk.dataVersion++;
-       if (VanillaUser(client)) {
+       if (!remote && VanillaUser(client)) {
            targetptr->disk.modeBits &= ~04000; /* turn off suid for file. */
 #ifdef CREATE_SGUID_ADMIN_ONLY
            targetptr->disk.modeBits &= ~02000; /* turn off sgid for file. */
@@ -1672,7 +1681,7 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
     }
     if (InStatus->Mask & AFS_SETOWNER) {
        /* admin is allowed to do chmod, chown as well as chown, chmod. */
-       if (VanillaUser(client)) {
+       if (!remote && VanillaUser(client)) {
            targetptr->disk.modeBits &= ~04000; /* turn off suid for file. */
 #ifdef CREATE_SGUID_ADMIN_ONLY
            targetptr->disk.modeBits &= ~02000; /* turn off sgid for file. */
@@ -1690,10 +1699,10 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
        int modebits = InStatus->UnixModeBits;
 #define        CREATE_SGUID_ADMIN_ONLY 1
 #ifdef CREATE_SGUID_ADMIN_ONLY
-       if (VanillaUser(client))
+       if (!remote && VanillaUser(client))
            modebits = modebits & 0777;
 #endif
-       if (VanillaUser(client)) {
+       if (!remote && VanillaUser(client)) {
            targetptr->disk.modeBits = modebits;
        } else {
            targetptr->disk.modeBits = modebits;
@@ -1806,7 +1815,7 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
        return VSALVAGE;
     }
 
-    *targetptr = VAllocVnode(&errorCode, volptr, FileType);
+    *targetptr = VAllocVnode(&errorCode, volptr, FileType, 0, 0);
     if (errorCode != 0) {
        VAdjustDiskUsage(&temp, volptr, -BlocksPreallocatedForVnode, 0);
        return (errorCode);
@@ -1988,7 +1997,6 @@ static afs_int32
 RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
                  char **motd, Volume * volptr)
 {
-    int temp;
 
     status->Vid = V_id(volptr);
     status->ParentId = V_parentId(volptr);
@@ -2003,22 +2011,18 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
     status->MinQuota = V_minquota(volptr);
     status->MaxQuota = V_maxquota(volptr);
     status->BlocksInUse = V_diskused(volptr);
-    status->PartBlocksAvail = RoundInt64ToInt32(volptr->partition->free);
-    status->PartMaxBlocks = RoundInt64ToInt32(volptr->partition->totalUsable);
+    status->PartBlocksAvail = RoundInt64ToInt31(volptr->partition->free);
+    status->PartMaxBlocks = RoundInt64ToInt31(volptr->partition->totalUsable);
 
     /* now allocate and copy these things; they're freed by the RXGEN stub */
-    temp = strlen(V_name(volptr)) + 1;
-    *name = malloc(temp);
+    *name = strdup(V_name(volptr));
     if (!*name) {
        ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
     }
-    strcpy(*name, V_name(volptr));
-    temp = strlen(V_offlineMessage(volptr)) + 1;
-    *offMsg = malloc(temp);
+    *offMsg = strdup(V_offlineMessage(volptr));
     if (!*offMsg) {
        ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
     }
-    strcpy(*offMsg, V_offlineMessage(volptr));
     *motd = malloc(1);
     if (!*motd) {
        ViceLogThenPanic(0, ("Failed malloc in RXGetVolumeStatus\n"));
@@ -2131,6 +2135,8 @@ static
 GetStatus(Vnode * targetptr, AFSFetchStatus * status, afs_int32 rights,
          afs_int32 anyrights, Vnode * parentptr)
 {
+    int Time =FT_ApproxTime();
+
     /* initialize return status from a vnode  */
     status->InterfaceVersion = 1;
     status->SyncCounter = status->dataVersionHigh = status->lockCount =
@@ -2165,7 +2171,7 @@ GetStatus(Vnode * targetptr, AFSFetchStatus * status, afs_int32 rights,
         Directory ? targetptr->disk.uniquifier : parentptr->disk.uniquifier);
     status->ServerModTime = targetptr->disk.serverModifyTime;
     status->Group = targetptr->disk.group;
-    status->lockCount = targetptr->disk.lock.lockCount;
+    status->lockCount = Time > targetptr->disk.lock.lockTime ? 0 : targetptr->disk.lock.lockCount;
     status->errorCode = 0;
 
 }                              /*GetStatus */
@@ -2226,7 +2232,7 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
     if ((errorCode =
         GetVolumePackageWithCall(acall, cbv, Fid, &volptr, &targetptr, DONTCHECK,
                          &parentwhentargetnotdir, &client, READ_LOCK,
-                         &rights, &anyrights)))
+                         &rights, &anyrights, 0)))
        goto Bad_FetchData;
 
     SetVolumeSync(Sync, volptr);
@@ -2529,14 +2535,12 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
 
     /* allocate space for return output parameters */
-    OutStats->AFSBulkStats_val = (struct AFSFetchStatus *)
-       malloc(nfiles * sizeof(struct AFSFetchStatus));
+    OutStats->AFSBulkStats_val = malloc(nfiles * sizeof(struct AFSFetchStatus));
     if (!OutStats->AFSBulkStats_val) {
        ViceLogThenPanic(0, ("Failed malloc in SRXAFS_BulkStatus\n"));
     }
     OutStats->AFSBulkStats_len = nfiles;
-    CallBacks->AFSCBs_val = (struct AFSCallBack *)
-       malloc(nfiles * sizeof(struct AFSCallBack));
+    CallBacks->AFSCBs_val = malloc(nfiles * sizeof(struct AFSCallBack));
     if (!CallBacks->AFSCBs_val) {
        ViceLogThenPanic(0, ("Failed malloc in SRXAFS_BulkStatus\n"));
     }
@@ -2653,22 +2657,18 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
 
     /* allocate space for return output parameters */
-    OutStats->AFSBulkStats_val = (struct AFSFetchStatus *)
-       malloc(nfiles * sizeof(struct AFSFetchStatus));
+    OutStats->AFSBulkStats_val = calloc(nfiles, sizeof(struct AFSFetchStatus));
     if (!OutStats->AFSBulkStats_val) {
        ViceLogThenPanic(0, ("Failed malloc in SRXAFS_FetchStatus\n"));
     }
     OutStats->AFSBulkStats_len = nfiles;
-    CallBacks->AFSCBs_val = (struct AFSCallBack *)
-       malloc(nfiles * sizeof(struct AFSCallBack));
+    CallBacks->AFSCBs_val = calloc(nfiles, sizeof(struct AFSCallBack));
     if (!CallBacks->AFSCBs_val) {
        ViceLogThenPanic(0, ("Failed malloc in SRXAFS_FetchStatus\n"));
     }
     CallBacks->AFSCBs_len = nfiles;
 
     /* Zero out return values to avoid leaking information on partial succes */
-    memset(OutStats->AFSBulkStats_val, 0, nfiles * sizeof(struct AFSFetchStatus));
-    memset(CallBacks->AFSCBs_val, 0, nfiles * sizeof(struct AFSCallBack));
     memset(Sync, 0, sizeof(*Sync));
 
     if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))) {
@@ -2686,7 +2686,13 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                              &parentwhentargetnotdir, &client, READ_LOCK,
                              &rights, &anyrights))) {
            tstatus = &OutStats->AFSBulkStats_val[i];
-           tstatus->errorCode = errorCode;
+
+           if (thost->hostFlags & HERRORTRANS) {
+               tstatus->errorCode = sys_error_to_et(errorCode);
+           } else {
+               tstatus->errorCode = errorCode;
+           }
+
            PutVolumePackage(acall, parentwhentargetnotdir, targetptr,
                             (Vnode *) 0, volptr, &client);
            parentwhentargetnotdir = (Vnode *) 0;
@@ -2710,7 +2716,13 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                 Check_PermissionRights(targetptr, client, rights,
                                        CHK_FETCHSTATUS, 0))) {
                tstatus = &OutStats->AFSBulkStats_val[i];
-               tstatus->errorCode = errorCode;
+
+               if (thost->hostFlags & HERRORTRANS) {
+                   tstatus->errorCode = sys_error_to_et(errorCode);
+               } else {
+                   tstatus->errorCode = errorCode;
+               }
+
                (void)PutVolumePackage(acall, parentwhentargetnotdir,
                                       targetptr, (Vnode *) 0, volptr,
                                       &client);
@@ -2747,6 +2759,7 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
        volptr = (Volume *) 0;
        client = (struct client *)0;
     }
+    errorCode = 0;
 
   Bad_InlineBulkStatus:
     /* Update and store volume/vnode and parent vnodes back */
@@ -2763,7 +2776,7 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode,
                AUD_ID, t_client ? t_client->ViceId : 0,
                AUD_FIDS, Fids, AUD_END);
-    return 0;
+    return errorCode;
 
 }                              /*SRXAFS_InlineBulkStatus */
 
@@ -2860,7 +2873,7 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
     /* set volume synchronization information */
     SetVolumeSync(Sync, volptr);
 
-    if ((targetptr->disk.type == vSymlink)) {
+    if (targetptr->disk.type == vSymlink) {
        /* Should we return a better error code here??? */
        errorCode = EISDIR;
        goto Bad_StoreData;
@@ -2902,7 +2915,7 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
     rx_KeepAliveOff(acall);
     /* Update the status of the target's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SDATA, client, InStatus,
-                            targetptr, volptr, 0);
+                            targetptr, volptr, 0, 0);
     rx_KeepAliveOn(acall);
 
     /* Get the updated File's status back to the caller */
@@ -3114,7 +3127,7 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
     /* Update the status of the target's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SSTATUS, client, InStatus,
                             (parentwhentargetnotdir ? parentwhentargetnotdir
-                             : targetptr), volptr, 0);
+                             : targetptr), volptr, 0, 0);
 
     rx_KeepAliveOn(acall);
 
@@ -3377,7 +3390,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* update the status of the new file's vnode */
     Update_TargetVnodeStatus(targetptr, TVS_CFILE, client, InStatus,
-                            parentptr, volptr, 0);
+                            parentptr, volptr, 0, 0);
 
     rx_KeepAliveOn(acall);
 
@@ -4044,7 +4057,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* update the status of the new symbolic link file vnode */
     Update_TargetVnodeStatus(targetptr, TVS_SLINK, client, InStatus,
-                            parentptr, volptr, strlen((char *)LinkContents));
+                            parentptr, volptr, strlen((char *)LinkContents), 0);
 
     /* Write the contents of the symbolic link name into the target inode */
     fdP = IH_OPEN(targetptr->handle);
@@ -4403,7 +4416,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* update the status for the target vnode */
     Update_TargetVnodeStatus(targetptr, TVS_MKDIR, client, InStatus,
-                            parentptr, volptr, 0);
+                            parentptr, volptr, 0, 0);
 
     /* Actually create the New directory in the directory package */
     SetDirHandle(&dir, targetptr);
@@ -4757,7 +4770,7 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
     (void)PutVolumePackage(acall, parentwhentargetnotdir, targetptr,
                           (Vnode *) 0, volptr, &client);
 
-    if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
+    if (errorCode == VREADONLY)        /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
 
     ViceLog(2, ("SAFS_ExtendLock returns %d\n", errorCode));
@@ -4866,7 +4879,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
     (void)PutVolumePackage(acall, parentwhentargetnotdir, targetptr,
                           (Vnode *) 0, volptr, &client);
 
-    if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
+    if (errorCode == VREADONLY)        /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
 
     ViceLog(2, ("SAFS_ReleaseLock returns %d\n", errorCode));
@@ -4979,8 +4992,8 @@ SetVolumeStats(struct AFSStatistics *stats)
 
     for (part = DiskPartitionList; part && i < AFS_MSTATDISKS;
         part = part->next) {
-       stats->Disks[i].TotalBlocks = RoundInt64ToInt32(part->totalUsable);
-       stats->Disks[i].BlocksAvailable = RoundInt64ToInt32(part->free);
+       stats->Disks[i].TotalBlocks = RoundInt64ToInt31(part->totalUsable);
+       stats->Disks[i].BlocksAvailable = RoundInt64ToInt31(part->free);
        memset(stats->Disks[i].Name, 0, AFS_DISKNAMESIZE);
        strncpy(stats->Disks[i].Name, part->name, AFS_DISKNAMESIZE);
        i++;
@@ -5358,7 +5371,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
         * for the File Server.
         */
        dataBytes = sizeof(struct afs_Stats);
-       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       dataBuffP = malloc(dataBytes);
        memcpy(dataBuffP, &afs_cmstats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes >> 2;
        a_dataP->AFS_CollData_val = dataBuffP;
@@ -5385,7 +5398,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
         */
 
        dataBytes = sizeof(struct afs_PerfStats);
-       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       dataBuffP = malloc(dataBytes);
        memcpy(dataBuffP, &afs_perfstats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes >> 2;
        a_dataP->AFS_CollData_val = dataBuffP;
@@ -5411,7 +5424,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
         */
 
        dataBytes = sizeof(struct fs_stats_FullPerfStats);
-       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       dataBuffP = malloc(dataBytes);
        memcpy(dataBuffP, &afs_FullPerfStats, dataBytes);
        a_dataP->AFS_CollData_len = dataBytes >> 2;
        a_dataP->AFS_CollData_val = dataBuffP;
@@ -5421,7 +5434,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
        afs_perfstats.numPerfCalls++;
 
        dataBytes = sizeof(struct cbcounters);
-       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       dataBuffP = malloc(dataBytes);
        {
            extern struct cbcounters cbstuff;
            dataBuffP[0]=cbstuff.DeleteFiles;
@@ -5490,7 +5503,7 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
     if (!FidArray && !CallBackArray) {
        ViceLog(1,
                ("SAFS_GiveUpAllCallBacks: host=%x\n",
-                (rx_PeerOf(tcon) ? rx_PeerOf(tcon)->host : 0)));
+                (rx_PeerOf(tcon) ? rx_HostOf(rx_PeerOf(tcon)) : 0)));
        errorCode = GetClient(tcon, &client);
        if (!errorCode) {
            H_LOCK;
@@ -5503,7 +5516,7 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
            ViceLog(0,
                    ("GiveUpCallBacks: #Fids %d < #CallBacks %d, host=%x\n",
                     FidArray->AFSCBFids_len, CallBackArray->AFSCBs_len,
-                    (rx_PeerOf(tcon) ? rx_PeerOf(tcon)->host : 0)));
+                    (rx_PeerOf(tcon) ? rx_HostOf(rx_PeerOf(tcon)) : 0)));
            errorCode = EINVAL;
            goto Bad_GiveUpCallBacks;
        }
@@ -5587,7 +5600,7 @@ SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
        goto Bad_GetCaps;
 
     dataBytes = 1 * sizeof(afs_int32);
-    dataBuffP = (afs_uint32 *) malloc(dataBytes);
+    dataBuffP = malloc(dataBytes);
     dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL;
     dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
     if (saneacls)
@@ -5603,6 +5616,25 @@ SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
     return 0;
 }
 
+/* client is held, but not locked */
+static int
+FlushClientCPS(struct client *client, void *arock)
+{
+    ObtainWriteLock(&client->lock);
+
+    client->prfail = 2;        /* Means re-eval client's cps */
+
+    if ((client->ViceId != ANONYMOUSID) && client->CPS.prlist_val) {
+       free(client->CPS.prlist_val);
+       client->CPS.prlist_val = NULL;
+       client->CPS.prlist_len = 0;
+    }
+
+    ReleaseWriteLock(&client->lock);
+
+    return 0;
+}
+
 afs_int32
 SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
                struct IPAddrs * addrs, afs_int32 spare1, afs_int32 * spare2,
@@ -5612,12 +5644,17 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     afs_int32 nids, naddrs;
     afs_int32 *vd, *addr;
     Error errorCode = 0;               /* return code to caller */
-    struct client *client = 0;
 
     ViceLog(1, ("SRXAFS_FlushCPS\n"));
     FS_LOCK;
     AFSCallStats.TotalCalls++;
     FS_UNLOCK;
+
+    if (!viced_SuperUser(acall)) {
+       errorCode = EPERM;
+       goto Bad_FlushCPS;
+    }
+
     nids = vids->ViceIds_len;  /* # of users in here */
     naddrs = addrs->IPAddrs_len;       /* # of hosts in here */
     if (nids < 0 || naddrs < 0) {
@@ -5629,23 +5666,7 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     for (i = 0; i < nids; i++, vd++) {
        if (!*vd)
            continue;
-       client = h_ID2Client(*vd);      /* returns write locked and refCounted, or NULL */
-       if (!client)
-           continue;
-
-       client->prfail = 2;     /* Means re-eval client's cps */
-#ifdef notdef
-       if (client->tcon) {
-           rx_SetRock(((struct rx_connection *)client->tcon), 0);
-       }
-#endif
-       if ((client->ViceId != ANONYMOUSID) && client->CPS.prlist_val) {
-           free(client->CPS.prlist_val);
-           client->CPS.prlist_val = NULL;
-           client->CPS.prlist_len = 0;
-       }
-       ReleaseWriteLock(&client->lock);
-       PutClient(&client);
+       h_EnumerateClients(*vd, FlushClientCPS, NULL);
     }
 
     addr = addrs->IPAddrs_val;
@@ -5855,10 +5876,6 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
                          &rights, &anyrights)))
        goto Bad_GetVolumeStatus;
 
-    if ((VanillaUser(client)) && (!(rights & PRSFS_READ))) {
-       errorCode = EACCES;
-       goto Bad_GetVolumeStatus;
-    }
     (void)RXGetVolumeStatus(FetchVolStatus, Name, OfflineMsg, Motd, volptr);
 
   Bad_GetVolumeStatus:
@@ -5867,15 +5884,15 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
     ViceLog(2, ("SAFS_GetVolumeStatus returns %d\n", errorCode));
     /* next is to guarantee out strings exist for stub */
     if (*Name == 0) {
-       *Name = (char *)malloc(1);
+       *Name = malloc(1);
        **Name = 0;
     }
     if (*Motd == 0) {
-       *Motd = (char *)malloc(1);
+       *Motd = malloc(1);
        **Motd = 0;
     }
     if (*OfflineMsg == 0) {
-       *OfflineMsg = (char *)malloc(1);
+       *OfflineMsg = malloc(1);
        **OfflineMsg = 0;
     }
     errorCode = CallPostamble(tcon, errorCode, thost);
@@ -6540,7 +6557,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     FreeSendBuffer((struct afs_buffer *)tbuffer);
 #endif /* HAVE_PIOV */
     if (sync) {
-       FDH_SYNC(fdP);
+       (void) FDH_SYNC(fdP);
     }
     if (errorCode) {
        Error tmp_errorCode = 0;