Remove support for Solaris pre-8
[openafs.git] / src / afs / SOLARIS / osi_groups.c
index 86b2518..a6cd8e4 100644 (file)
  * setpag
  *
  */
+
+#include <unistd.h>
+#ifdef AFS_SUN510_ENV
+#include <sys/cred.h>
+#endif
+
 #include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
 
-RCSID("$Header$");
 
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
-#include "../afs/afs_stats.h"  /* statistics */
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
+#include "afs/afs_stats.h"     /* statistics */
 
 
 static int
-afs_getgroups(
-    struct cred *cred,
-    gid_t *gidset);
+  afs_getgroups(struct cred *cred, gid_t * gidset);
 
 static int
-afs_setgroups(
-    struct cred **cred,
-    int ngroups,
-    gid_t *gidset,
-    int change_parent);
+  afs_setgroups(struct cred **cred, int ngroups, gid_t * gidset,
+               int change_parent);
 
 
-#if    defined(AFS_SUN55_ENV)
 int
 afs_xsetgroups(uap, rvp)
-u_int uap; /* this is gidsetsize */
-gid_t *rvp; /* this is gidset */
-#else 
-struct setgroupsa {
-    u_int gidsetsize;
-    gid_t *gidset;
-};
-
-afs_xsetgroups(uap, rvp) 
-    struct setgroupsa *uap;
-    rval_t *rvp;
-#endif
+     u_int uap;                        /* this is gidsetsize */
+     gid_t *rvp;               /* this is gidset */
 {
     int code = 0;
     struct vrequest treq;
@@ -60,7 +49,8 @@ afs_xsetgroups(uap, rvp)
     AFS_GLOCK();
     code = afs_InitReq(&treq, proc->p_cred);
     AFS_GUNLOCK();
-    if (code) return code;
+    if (code)
+       return code;
     code = setgroups(uap, rvp);
 
     /* Note that if there is a pag already in the new groups we don't
@@ -79,10 +69,10 @@ afs_xsetgroups(uap, rvp)
 
 int
 setpag(cred, pagvalue, newpag, change_parent)
-    struct cred **cred;
-    afs_uint32 pagvalue;
-    afs_uint32 *newpag;
-    afs_uint32 change_parent;
+     struct cred **cred;
+     afs_uint32 pagvalue;
+     afs_uint32 *newpag;
+     afs_uint32 change_parent;
 {
     gid_t *gidset;
     int ngroups, code;
@@ -97,16 +87,16 @@ setpag(cred, pagvalue, newpag, change_parent)
 
     if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
        /* We will have to shift grouplist to make room for pag */
-       if ((sizeof gidset[0])*(ngroups + 2) > AFS_SMALLOCSIZ) {
+       if ((sizeof gidset[0]) * (ngroups + 2) > AFS_SMALLOCSIZ) {
            osi_FreeSmallSpace((char *)gidset);
            return (E2BIG);
        }
-       for (j = ngroups -1; j >= 0; j--) {
-           gidset[j+2] = gidset[j];
-       }
+       for (j = ngroups - 1; j >= 0; j--) {
+           gidset[j + 2] = gidset[j];
+       }
        ngroups += 2;
     }
-    *newpag = (pagvalue == -1 ? genpag(): pagvalue);
+    *newpag = (pagvalue == -1 ? genpag() : pagvalue);
     afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
     /* afs_setgroups will release curproc->p_crlock */
     if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) {
@@ -119,9 +109,7 @@ setpag(cred, pagvalue, newpag, change_parent)
 
 
 static int
-afs_getgroups(
-    struct cred *cred,
-    gid_t *gidset)
+afs_getgroups(struct cred *cred, gid_t * gidset)
 {
     int ngrps, savengrps;
     gid_t *gp;
@@ -129,24 +117,24 @@ afs_getgroups(
     AFS_STATCNT(afs_getgroups);
 
     gidset[0] = gidset[1] = 0;
+#if defined(AFS_SUN510_ENV)
+    savengrps = ngrps = crgetngroups(cred);
+    gp = crgetgroups(cred);
+#else
     savengrps = ngrps = cred->cr_ngroups;
     gp = cred->cr_groups;
+#endif
     while (ngrps--)
-       *gidset++ = *gp++;   
+       *gidset++ = *gp++;
     return savengrps;
 }
 
 
 
 static int
-afs_setgroups(
-    struct cred **cred,
-    int ngroups,
-    gid_t *gidset,
-    int change_parent)
+afs_setgroups(struct cred **cred, int ngroups, gid_t * gidset,
+             int change_parent)
 {
-    int ngrps;
-    int i;
     gid_t *gp;
 
     AFS_STATCNT(afs_setgroups);
@@ -157,12 +145,17 @@ afs_setgroups(
     }
     if (!change_parent)
        *cred = (struct cred *)crcopy(*cred);
+#if defined(AFS_SUN510_ENV)
+    crsetgroups(*cred, ngroups, gidset);
+    gp = crgetgroups(*cred);
+#else
     (*cred)->cr_ngroups = ngroups;
     gp = (*cred)->cr_groups;
+#endif
     while (ngroups--)
        *gp++ = *gidset++;
     mutex_exit(&curproc->p_crlock);
     if (!change_parent)
-       crset(curproc, *cred); /* broadcast to all threads */
+       crset(curproc, *cred);  /* broadcast to all threads */
     return (0);
 }