Windows: Implement cm_TGTLifeTime()

cm_aclent.h defined cm_TGTLifeTime() as a macro that always
returned 0x7fffffff.  Implement cm_TGTLifeTime() as a function
that returns the actual token lifetime.

Change-Id: I8b19626395f536db248ae8324b13e49eda9a1a87
Reviewed-on: http://gerrit.openafs.org/6994
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
This commit is contained in:
Jeffrey Altman 2012-03-30 14:58:11 -04:00 committed by Jeffrey Altman
parent cf81cd790f
commit fd919b3ae5
2 changed files with 27 additions and 4 deletions

View File

@ -139,6 +139,22 @@ static cm_aclent_t *GetFreeACLEnt(cm_scache_t * scp)
return aclp; return aclp;
} }
time_t cm_TGTLifeTime(cm_user_t *userp, afs_uint32 cellID)
{
cm_cell_t *cellp = NULL;
cm_ucell_t * ucp = NULL;
time_t expirationTime = 0;
cellp = cm_FindCellByID(cellID, CM_FLAG_NOPROBE);
lock_ObtainMutex(&userp->mx);
ucp = cm_GetUCell(userp, cellp);
if (ucp->ticketp)
expirationTime = ucp->expirationTime;
lock_ReleaseMutex(&userp->mx);
return expirationTime;
}
/* /*
* Add rights to an acl cache entry. Do the right thing if not present, * Add rights to an acl cache entry. Do the right thing if not present,
@ -155,7 +171,14 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 rights)
if (aclp->userp == userp) { if (aclp->userp == userp) {
aclp->randomAccess = rights; aclp->randomAccess = rights;
if (aclp->tgtLifetime == 0) if (aclp->tgtLifetime == 0)
aclp->tgtLifetime = cm_TGTLifeTime(pag); aclp->tgtLifetime = cm_TGTLifeTime(userp, scp->fid.cell);
if (cm_data.aclLRUp != aclp) {
/* move to the head of the LRU queue */
osi_QRemoveHT((osi_queue_t **) &cm_data.aclLRUp, (osi_queue_t **) &cm_data.aclLRUEndp, &aclp->q);
osi_QAddH((osi_queue_t **) &cm_data.aclLRUp,
(osi_queue_t **) &cm_data.aclLRUEndp,
&aclp->q);
}
lock_ReleaseWrite(&cm_aclLock); lock_ReleaseWrite(&cm_aclLock);
return 0; return 0;
} }
@ -174,7 +197,7 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 rights)
cm_HoldUser(userp); cm_HoldUser(userp);
aclp->userp = userp; aclp->userp = userp;
aclp->randomAccess = rights; aclp->randomAccess = rights;
aclp->tgtLifetime = cm_TGTLifeTime(userp); aclp->tgtLifetime = cm_TGTLifeTime(userp, scp->fid.cell);
lock_ReleaseWrite(&cm_aclLock); lock_ReleaseWrite(&cm_aclLock);
return 0; return 0;

View File

@ -12,8 +12,6 @@
#include <osi.h> #include <osi.h>
#define cm_TGTLifeTime(x) (0x7fffffff)
#define CM_ACLENT_MAGIC ('A' | 'C' <<8 | 'L'<<16 | 'E'<<24) #define CM_ACLENT_MAGIC ('A' | 'C' <<8 | 'L'<<16 | 'E'<<24)
/* /*
@ -49,4 +47,6 @@ extern long cm_ShutdownACLCache(void);
extern void cm_ResetACLCache(cm_cell_t *cellp, cm_user_t *userp); extern void cm_ResetACLCache(cm_cell_t *cellp, cm_user_t *userp);
extern time_t cm_TGTLifeTime(cm_user_t *userp, afs_uint32 cellID);
#endif /* _CM_ACLENT_H_ */ #endif /* _CM_ACLENT_H_ */