call afs_osi_suser correctly in PNewUuid
[openafs.git] / src / afs / afs_pioctl.c
index a16388e..3ac472b 100644 (file)
@@ -836,6 +836,9 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
            vp = (struct vnode *)dp->d_inode;
 #else
        code = gop_lookupname_user(path, AFS_UIOUSER, follow, &vp);
+#if defined(AFS_FBSD80_ENV) /* XXX check on 7x */
+       VN_HOLD(vp);
+#endif /* AFS_FBSD80_ENV */
 #endif /* AFS_LINUX22_ENV */
 #endif /* AFS_AIX41_ENV */
        AFS_GLOCK();
@@ -933,6 +936,10 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 #ifdef AFS_LINUX22_ENV
        dput(dp);
 #else
+#if defined(AFS_FBSD80_ENV)
+    if (VOP_ISLOCKED(vp))
+       VOP_UNLOCK(vp, 0);
+#endif /* AFS_FBSD80_ENV */
        AFS_RELE(vp);           /* put vnode back */
 #endif
     }
@@ -2282,14 +2289,14 @@ DECL_PIOCTL(PFindVolume)
     tvp = afs_GetVolume(&avc->f.fid, areq, READ_LOCK);
     if (tvp) {
        cp = aout;
-       for (i = 0; i < MAXHOSTS; i++) {
+       for (i = 0; i < AFS_MAXHOSTS; i++) {
            ts = tvp->serverHost[i];
            if (!ts)
                break;
            memcpy(cp, (char *)&ts->addr->sa_ip, sizeof(afs_int32));
            cp += sizeof(afs_int32);
        }
-       if (i < MAXHOSTS) {
+       if (i < AFS_MAXHOSTS) {
            /* still room for terminating NULL, add it on */
            ainSize = 0;        /* reuse vbl */
            memcpy(cp, (char *)&ainSize, sizeof(afs_int32));
@@ -2553,7 +2560,7 @@ DECL_PIOCTL(PRemoveCallBack)
 DECL_PIOCTL(PNewCell)
 {
     /* create a new cell */
-    afs_int32 cellHosts[MAXCELLHOSTS], *lp, magic = 0;
+    afs_int32 cellHosts[AFS_MAXCELLHOSTS], *lp, magic = 0;
     char *newcell = 0, *linkedcell = 0, *tp = ain;
     register afs_int32 code, linkedstate = 0, ls;
     u_short fsport = 0, vlport = 0;
@@ -2571,16 +2578,16 @@ DECL_PIOCTL(PNewCell)
     if (magic != 0x12345678)
        return EINVAL;
 
-    /* A 3.4 fs newcell command will pass an array of MAXCELLHOSTS
+    /* A 3.4 fs newcell command will pass an array of AFS_MAXCELLHOSTS
      * server addresses while the 3.5 fs newcell command passes
-     * MAXHOSTS. To figure out which is which, check if the cellname
+     * AFS_MAXHOSTS. To figure out which is which, check if the cellname
      * is good.
      */
-    newcell = tp + (MAXCELLHOSTS + 3) * sizeof(afs_int32);
-    scount = ((newcell[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
+    newcell = tp + (AFS_MAXCELLHOSTS + 3) * sizeof(afs_int32);
+    scount = ((newcell[0] != '\0') ? AFS_MAXCELLHOSTS : AFS_MAXHOSTS);
 
-    /* MAXCELLHOSTS (=8) is less than MAXHOSTS (=13) */
-    memcpy((char *)cellHosts, tp, MAXCELLHOSTS * sizeof(afs_int32));
+    /* AFS_MAXCELLHOSTS (=8) is less than AFS_MAXHOSTS (=13) */
+    memcpy((char *)cellHosts, tp, AFS_MAXCELLHOSTS * sizeof(afs_int32));
     tp += (scount * sizeof(afs_int32));
 
     lp = (afs_int32 *) tp;
@@ -2655,15 +2662,15 @@ DECL_PIOCTL(PListCells)
     tcell = afs_GetCellByIndex(whichCell, READ_LOCK);
     if (tcell) {
        cp = aout;
-       memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32));
-       for (i = 0; i < MAXCELLHOSTS; i++) {
+       memset(cp, 0, AFS_MAXCELLHOSTS * sizeof(afs_int32));
+       for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
            if (tcell->cellHosts[i] == 0)
                break;
            memcpy(cp, (char *)&tcell->cellHosts[i]->addr->sa_ip,
                   sizeof(afs_int32));
            cp += sizeof(afs_int32);
        }
-       cp = aout + MAXCELLHOSTS * sizeof(afs_int32);
+       cp = aout + AFS_MAXCELLHOSTS * sizeof(afs_int32);
        strcpy(cp, tcell->cellName);
        cp += strlen(tcell->cellName) + 1;
        *aoutSize = cp - aout;
@@ -3340,7 +3347,7 @@ ReSortCells_cb(struct cell *cell, void *arg)
     for (i = 0; i < s; i++) {
        if (l[i] == cell->cellNum) {
            ObtainWriteLock(&cell->lock, 690);
-           afs_SortServers(cell->cellHosts, MAXCELLHOSTS);
+           afs_SortServers(cell->cellHosts, AFS_MAXCELLHOSTS);
            ReleaseWriteLock(&cell->lock);
        }
     }
@@ -3371,7 +3378,7 @@ ReSortCells(int s, afs_int32 * l, int vlonly)
            for (k = 0; k < s; k++)
                if (j->cell == l[k]) {
                    ObtainWriteLock(&j->lock, 233);
-                   afs_SortServers(j->serverHost, MAXHOSTS);
+                   afs_SortServers(j->serverHost, AFS_MAXHOSTS);
                    ReleaseWriteLock(&j->lock);
                    break;
                }
@@ -3896,7 +3903,7 @@ DECL_PIOCTL(PSetRxkcrypt)
 #define        PIOCTL_HEADER   6
 static int
 HandleClientContext(struct afs_ioctl *ablob, int *com,
-                   afs_ucred_t **acred, AFS_UCRED *credp)
+                   afs_ucred_t **acred, afs_ucred_t *credp)
 {
     char *ain, *inData;
     afs_uint32 hostaddr;
@@ -3906,6 +3913,9 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
     struct unixuser *au;
     afs_uint32 comp = *com & 0xff00;
     afs_uint32 h, l;
+#if defined(AFS_SUN510_ENV)
+    gid_t gids[2];
+#endif
 
 #if defined(AFS_SGIMP_ENV)
     osi_Assert(ISAFS_GLOCK());
@@ -3976,30 +3986,34 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
     newcred->cr_groupset.gs_union.un_groups[0] = g0;
     newcred->cr_groupset.gs_union.un_groups[1] = g1;
 #elif defined(AFS_LINUX26_ENV)
-#ifdef AFS_LINUX26_ONEGROUP_ENV
+# ifdef AFS_LINUX26_ONEGROUP_ENV
     set_cr_group_info(newcred, groups_alloc(1)); /* not that anything sets this */
     l = (((g0-0x3f00) & 0x3fff) << 14) | ((g1-0x3f00) & 0x3fff);
     h = ((g0-0x3f00) >> 14);
     h = ((g1-0x3f00) >> 14) + h + h + h;
     GROUP_AT(cr_group_info(newcred), 0) = ((h << 28) | l);
-#else
+# else
     set_cr_group_info(newcred, groups_alloc(2));
     GROUP_AT(cr_group_info(newcred), 0) = g0;
     GROUP_AT(cr_group_info(newcred), 1) = g1;
-#endif
+# endif
+#elif defined(AFS_SUN510_ENV)
+    gids[0] = g0;
+    gids[1] = g1;
+    crsetgroups(newcred, 2, gids);
 #else
     newcred->cr_groups[0] = g0;
     newcred->cr_groups[1] = g1;
 #endif
 #ifdef AFS_AIX_ENV
     newcred->cr_ngrps = 2;
-#elif !defined(AFS_LINUX26_ENV)
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV)
+#elif !defined(AFS_LINUX26_ENV) && !defined(AFS_SUN510_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV)
     newcred->cr_ngroups = 2;
-#else
+# else
     for (i = 2; i < NGROUPS; i++)
        newcred->cr_groups[i] = NOGROUP;
-#endif
+# endif
 #endif
     if (!(exporter = exporter_find(exporter_type))) {
        /* Exporter wasn't initialized or an invalid exporter type */
@@ -4463,7 +4477,7 @@ DECL_PIOCTL(PNewUuid)
     if (!afs_resourceinit_flag)        /* afs deamons havn't started yet */
        return EIO;             /* Inappropriate ioctl for device */
 
-    if (!afs_osi_suser(acred))
+    if (!afs_osi_suser(*acred))
        return EACCES;
 
     ObtainWriteLock(&afs_xinterface, 555);