diff --git a/src/afs/DARWIN/osi_groups.c b/src/afs/DARWIN/osi_groups.c index ecb49d6df6..4c394b3218 100644 --- a/src/afs/DARWIN/osi_groups.c +++ b/src/afs/DARWIN/osi_groups.c @@ -74,7 +74,7 @@ Afs_xsetgroups(p, args, retval) pcred_unlock(p); if (PagInCred(cr) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ AddPag(p, treq.uid, &cr); diff --git a/src/afs/FBSD/osi_groups.c b/src/afs/FBSD/osi_groups.c index e288326c7d..29467414f8 100644 --- a/src/afs/FBSD/osi_groups.c +++ b/src/afs/FBSD/osi_groups.c @@ -58,7 +58,7 @@ Afs_xsetgroups(struct thread *td, struct setgroups_args *uap) cr = crdup(td->td_ucred); if (PagInCred(cr) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ AddPag(td, treq.uid, &cr); diff --git a/src/afs/HPUX/osi_groups.c b/src/afs/HPUX/osi_groups.c index 1b28a43f5d..75c65312e0 100644 --- a/src/afs/HPUX/osi_groups.c +++ b/src/afs/HPUX/osi_groups.c @@ -47,7 +47,7 @@ Afs_xsetgroups() * overwrite it with the old pag. */ if (PagInCred(p_cred(u.u_procp)) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { struct ucred *cred; AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ diff --git a/src/afs/IRIX/osi_groups.c b/src/afs/IRIX/osi_groups.c index 9e1d5c0095..bc68500643 100644 --- a/src/afs/IRIX/osi_groups.c +++ b/src/afs/IRIX/osi_groups.c @@ -67,7 +67,7 @@ fixup_pags(int **credpp, int ngroups, gid_t * gidset, int old_afs_pag, } if (ngroups >= 1) { /* possibly a DFS PAG */ new_dfs_pag = (int)groups[ngroups - 1]; - if (((new_dfs_pag >> 24) & 0xff) == 'A') + if (afs_IsPagId(new_dfs_pag)) new_dfs_pag = (int)groups[ngroups - 1]; else new_dfs_pag = 0; @@ -138,7 +138,7 @@ osi_DFSGetPagFromCred(struct ucred *credp) * the first or third group entry. */ pag = credp->cr_groups[ngroups - 1]; - if (((pag >> 24) & 0xff) == 'A') + if (afs_IsPagId(pag)) return pag; else return NOPAG; diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index a060633d5f..b61824cca6 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -39,7 +39,7 @@ afs_linux_pag_from_groups(struct group_info *group_info) for (i = 0; i < group_info->ngroups; i++) { g0 = afs_from_kgid(GROUP_AT(group_info, i)); - if (((g0 >> 24) & 0xff) == 'A') + if (afs_IsPagId(g0)) return g0; } return NOPAG; @@ -61,7 +61,7 @@ afs_linux_pag_to_groups(afs_uint32 newpag, for (i = 0, j = 0; i < old->ngroups; ++i) { afs_kgid_t ths = GROUP_AT(old, i); - if ((afs_from_kgid(ths) >> 24) == 'A') + if (afs_IsPagId(afs_from_kgid(ths))) continue; if ((i == 0 || !gid_lt(newkgid, GROUP_AT(old, i - 1))) && gid_lt(newkgid, ths)) { @@ -658,7 +658,7 @@ osi_get_keyring_pag(afs_ucred_t *cred) /* Only set PAG in groups if needed, * and the creds are from the current process */ if (afs_linux_cred_is_current(cred) && - ((keyring_pag >> 24) & 0xff) == 'A' && + afs_IsPagId(keyring_pag) && keyring_pag != afs_linux_pag_from_groups(current_group_info())) { __setpag(&cred, keyring_pag, &newpag, 0, NULL); diff --git a/src/afs/NBSD/osi_groups.c b/src/afs/NBSD/osi_groups.c index 81043f4ff3..bc9849860e 100644 --- a/src/afs/NBSD/osi_groups.c +++ b/src/afs/NBSD/osi_groups.c @@ -65,7 +65,7 @@ Afs_xsetgroups(afs_proc_t *p, const void *args, register_t *retval) * overwrite it with the old pag. */ if (PagInCred(cred) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ AddPag(p, treq.uid, &cred); diff --git a/src/afs/OBSD/osi_groups.c b/src/afs/OBSD/osi_groups.c index 98ccf0421d..1af2b530a3 100644 --- a/src/afs/OBSD/osi_groups.c +++ b/src/afs/OBSD/osi_groups.c @@ -61,7 +61,7 @@ Afs_xsetgroups(p, args, retval) * overwrite it with the old pag. */ if (PagInCred(p->p_rcred) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ AddPag(p, treq.uid, &p->p_rcred); diff --git a/src/afs/SOLARIS/osi_groups.c b/src/afs/SOLARIS/osi_groups.c index cd8df917e5..388cda7a80 100644 --- a/src/afs/SOLARIS/osi_groups.c +++ b/src/afs/SOLARIS/osi_groups.c @@ -60,7 +60,7 @@ afs_xsetgroups(u_int uap, gid_t *rvp) * overwrite it with the old pag. */ if (PagInCred(proc->p_cred) == NOPAG) { - if (((treq.uid >> 24) & 0xff) == 'A') { + if (afs_IsPagId(treq.uid)) { AFS_GLOCK(); /* we've already done a setpag, so now we redo it */ AddPag(treq.uid, &proc->p_cred); @@ -93,7 +93,7 @@ pag_to_gidset(afs_uint32 pagvalue, gid_t *gidset, int *a_ngroups, /* See if we already have a PAG gid */ for (i = 0; i < ngroups; i++) { - if (((gidset[i] >> 24) & 0xff) == 'A') { + if (afs_IsPagId(gidset[i])) { gidslot = &gidset[i]; break; } @@ -276,7 +276,7 @@ osi_get_group_pag(struct cred *cred) { ngroups = crgetngroups(cred); for (i = 0; i < ngroups; i++) { - if (((gidset[i] >> 24) & 0xff) == 'A') { + if (afs_IsPagId(gidset[i])) { return gidset[i]; } } diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index ec0a0dd435..a25070379d 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -575,7 +575,7 @@ afs_get_pag_from_groups(gid_t g0a, gid_t g1a) return ret; # else /* Additional testing */ - if (((ret >> 24) & 0xff) == 'A') + if (afs_IsPagId(ret)) return ret; # endif /* UKERNEL */ } @@ -713,3 +713,12 @@ PagInCred(afs_ucred_t *cred) #endif return pag; } + +int +afs_IsPagId(afs_uint32 id) +{ + if (((id >> 24) & 0xff) == 'A') { + return 1; + } + return 0; +} diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index db69dc09a4..a2c29f45ad 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -541,6 +541,7 @@ extern void afs_DestroyReq(struct vrequest *av); extern afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a); extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p); extern afs_int32 PagInCred(afs_ucred_t *cred); +extern int afs_IsPagId(afs_uint32 id); /* afs_osi_uio.c */ #if !defined(AFS_DARWIN80_ENV) diff --git a/src/afs/afs_user.c b/src/afs/afs_user.c index 78e3a4b13e..ad7c55a996 100644 --- a/src/afs/afs_user.c +++ b/src/afs/afs_user.c @@ -782,7 +782,7 @@ afs_GCPAGs(afs_int32 * ReleasedCount) for (i = 0; i < NUSERS; i++) { for (pu = afs_users[i]; pu; pu = pu->next) { pu->states |= TMP_UPAGNotReferenced; - if (((pu->uid >> 24) & 0xff) != 'A') { + if (afs_IsPagId(pu->uid)) { /* this is a uid-based token, */ /* increment the count */ afs_GCPAGs_UIDBaseTokenCount++;