/* Do we have tokens ? */
if (conn->user->vid != UNDEFVID) {
+ char *ticket;
+ struct ClearToken ct;
+
*secLevel = 2;
+
+ /* Make a copy of the ticket data to give to rxkad, because the
+ * the ticket data could change while rxkad is sleeping for memory
+ * allocation. We should implement locking on unixuser
+ * structures to fix this properly, but for now, this is easier. */
+ ticket = afs_osi_Alloc(MAXKTCTICKETLEN);
+ memcpy(ticket, conn->user->stp, conn->user->stLen);
+ memcpy(&ct, &conn->user->ct, sizeof(ct));
+
/* kerberos tickets on channel 2 */
secObj = rxkad_NewClientSecurityObject(
cryptall ? rxkad_crypt : rxkad_clear,
- (struct ktc_encryptionKey *)conn->user->ct.HandShakeKey,
- conn->user->ct.AuthHandle,
- conn->user->stLen, conn->user->stp);
+ (struct ktc_encryptionKey *)ct.HandShakeKey,
+ ct.AuthHandle,
+ conn->user->stLen, ticket);
+
+ afs_osi_Free(ticket, MAXKTCTICKETLEN);
}
if (secObj == NULL) {
*secLevel = 0;
struct unixuser *tu;
struct ClearToken clear;
struct cell *tcell;
- char *stp;
+ char *stp, *stpNew;
char *cellName;
- int stLen;
+ int stLen, stLenOld;
struct vrequest treq;
afs_int32 flag, set_parent_pag = 0;
areq = &treq;
}
}
+
+ stpNew = (char *)afs_osi_Alloc(stLen);
+ if (stpNew == NULL) {
+ return ENOMEM;
+ }
+ memcpy(stpNew, stp, stLen);
+
/* now we just set the tokens */
tu = afs_GetUser(areq->uid, i, WRITE_LOCK); /* i has the cell # */
+ stp = tu->stp;
+ stLenOld = tu->stLen;
+
tu->vid = clear.ViceId;
- if (tu->stp != NULL) {
- afs_osi_Free(tu->stp, tu->stLen);
- }
- tu->stp = (char *)afs_osi_Alloc(stLen);
- if (tu->stp == NULL) {
- return ENOMEM;
- }
+ tu->stp = stpNew;
tu->stLen = stLen;
- memcpy(tu->stp, stp, stLen);
tu->ct = clear;
#ifndef AFS_NOSTATS
afs_stats_cmfullperf.authent.TicketUpdates++;
afs_NotifyUser(tu, UTokensObtained);
afs_PutUser(tu, WRITE_LOCK);
+ if (stp) {
+ afs_osi_Free(stp, stLenOld);
+ }
+
return 0;
nocell: