From 053522f534f73f9843a68334158ff98a48d9578e Mon Sep 17 00:00:00 2001 From: Ben Kaduk Date: Tue, 30 Mar 2010 20:34:02 -0400 Subject: [PATCH] Make GCPAGs_perproc_func cleaner for FBSD case 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 Tested-by: Derrick Brashear --- src/afs/afs_osi_gcpags.c | 17 +++++++++++++---- src/afs/afs_user.c | 4 ---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/afs/afs_osi_gcpags.c b/src/afs/afs_osi_gcpags.c index 06c79467c..c9ca7e54c 100644 --- a/src/afs/afs_osi_gcpags.c +++ b/src/afs/afs_osi_gcpags.c @@ -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; diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index 30e452eab..3e9fd9545 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -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; -- 2.39.5