Make GCPAGs_perproc_func cleaner for FBSD case
authorBen Kaduk <kaduk@mit.edu>
Wed, 31 Mar 2010 00:34:02 +0000 (20:34 -0400)
committerDerrick Brashear <shadow@dementia.org>
Wed, 31 Mar 2010 01:53:14 +0000 (18:53 -0700)
Partially rewrite 2cf1f10a to reduce code clutter.
Instead of accessing pproc->p_ucred directly in afs_GCPAGs_perproc_func(),
push this access into a FBSD-specific afs_proc2cred() function.
This is not quite right, since we do not lock the proc mutex, but
in the same way as the old version and with more reasonable preprocessor
conditionals.
This also eliminates a probably-needless call to osi_Panic.

Change-Id: Ib403132f31cc13f8c4581cb89ecc8938d0a0dd88
Reviewed-on: http://gerrit.openafs.org/1672
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/afs_osi_gcpags.c
src/afs/afs_user.c

index 06c7946..c9ca7e5 100644 (file)
@@ -430,15 +430,24 @@ afs_osi_proc2cred(afs_proc_t * pr)
            NGROUPS * sizeof(gid_t));
     return &cr;
 }
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#elif defined(AFS_FBSD_ENV)
+const afs_ucred_t *
+afs_osi_proc2cred(afs_proc_t * pr)
+{
+    /*
+     * This whole function is kind of an ugly hack.  For one, the
+     * 'const' is a lie.  Also, we should probably be holding the
+     * proc mutex around all accesses to the credentials structure,
+     * but the present API does not allow this.
+     */
+    return pr->p_ucred;
+}
+#elif defined(AFS_DARWIN_ENV)
 const afs_ucred_t *
 afs_osi_proc2cred(afs_proc_t * pr)
 {
     afs_ucred_t *rv = NULL;
     static afs_ucred_t cr;
-#if defined(AFS_FBSD80_ENV)
-    osi_Panic("proc2cred broken for dynamic cr_groups");
-#endif
 
     if (pr == NULL) {
        return NULL;
index 30e452e..3e9fd95 100644 (file)
@@ -631,11 +631,7 @@ afs_GCPAGs_perproc_func(afs_proc_t * pproc)
 
     afs_GCPAGs_perproc_count++;
 
-#if defined(AFS_FBSD80_ENV)
-    pcred = pproc->p_ucred;    /* XXX locking (or just use thread creds) */
-#else
     pcred = afs_osi_proc2cred(pproc);
-#endif
     if (!pcred)
        return;