Windows: Implement cm_TGTLifeTime()
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 30 Mar 2012 18:58:11 +0000 (14:58 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 3 Apr 2012 03:17:15 +0000 (20:17 -0700)
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>

src/WINNT/afsd/cm_aclent.c
src/WINNT/afsd/cm_aclent.h

index 326383f..ebec61b 100644 (file)
@@ -139,6 +139,22 @@ static cm_aclent_t *GetFreeACLEnt(cm_scache_t * scp)
     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,
@@ -155,7 +171,14 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 rights)
         if (aclp->userp == userp) {
             aclp->randomAccess = rights;
             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);
             return 0;
         }
@@ -174,7 +197,7 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, afs_uint32 rights)
     cm_HoldUser(userp);
     aclp->userp = userp;
     aclp->randomAccess = rights;
-    aclp->tgtLifetime = cm_TGTLifeTime(userp);
+    aclp->tgtLifetime = cm_TGTLifeTime(userp, scp->fid.cell);
     lock_ReleaseWrite(&cm_aclLock);
 
     return 0;
index 40cba00..d7b7f1a 100644 (file)
@@ -12,8 +12,6 @@
 
 #include <osi.h>
 
-#define cm_TGTLifeTime(x)      (0x7fffffff)
-
 #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 time_t cm_TGTLifeTime(cm_user_t *userp, afs_uint32 cellID);
+
 #endif  /* _CM_ACLENT_H_ */