mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
afs: Introduce afs_IsPagId()
Many places in the code contain a check like this, in order to check if a given uid number represents a PAG: if (((uid >> 24) & 0xff) == 'A') Consolidate these checks into a single function, called afs_IsPagId. Change-Id: I8b9e9a8fc07672a3e1edfd2eff8227d8c2558a0a Reviewed-on: https://gerrit.openafs.org/14086 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
parent
134b671171
commit
c856bd9c87
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user