Do not export tickets from the LSA if they contain NULL session keys.
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 31 Jan 2004 09:29:13 +0000 (09:29 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 31 Jan 2004 09:29:13 +0000 (09:29 +0000)
This is primarily to prevent unusable TGTs from being imported into the
MIT Credential Cache

ticket: 2153
tags: pullup

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15991 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/ccache/ChangeLog
src/lib/krb5/ccache/cc_mslsa.c

index cca7ecb01338b53e1f5f1a0b81bf07ee3d8407fc..f9e7d5254fb95ce2106631bde4dbe50cc2e79975 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-31  Jeffrey Altman <jaltman@mit.edu>
+
+   * cc_mslsa.c: Do not return tickets to the caller if they contain
+     NULL session keys.  This is to prevent useless TGTs from being
+     placed into the MIT credential cache.
+
 2004-01-30  Jeffrey Altman <jaltman@mit.edu>
 
    * cc_mslsa.c: As per extensive conversations with Doug Engert we have
index 243a86ab19c9e0edec319b934f1821f39793880a..d5b9ce6698cf38dd907931b2a87805afbd3527c7 100644 (file)
@@ -249,14 +249,14 @@ PreserveInitialTicketIdentity(void)
 {
     HKEY hKey;
     DWORD size = sizeof(DWORD);
+    DWORD type = REG_DWORD;
     const char *key_path = "Software\\MIT\\Kerberos5";
     const char *value_name = "PreserveInitialTicketIdentity";
     DWORD retval = 1;     /* default to Preserve */
 
-  userkey:
-    if (RegOpenKeyEx(HKEY_CURRENT_USER, key_path, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+    if (RegOpenKeyExA(HKEY_CURRENT_USER, key_path, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
         goto syskey;
-    if (RegQueryValueEx(hKey, value_name, 0, REG_DWORD, &retval, &size) != ERROR_SUCCESS)
+    if (RegQueryValueExA(hKey, value_name, 0, &type, (LPBYTE)&retval, &size) != ERROR_SUCCESS)
     {
         RegCloseKey(hKey);
         goto syskey;
@@ -265,9 +265,9 @@ PreserveInitialTicketIdentity(void)
     goto done;
 
   syskey:
-    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key_path, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+    if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_path, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
         goto done;
-    if (RegQueryValueEx(hKey, value_name, 0, REG_DWORD, &retval, &size) != ERROR_SUCCESS)
+    if (RegQueryValueExA(hKey, value_name, 0, &type, (LPBYTE)&retval, &size) != ERROR_SUCCESS)
     {
         RegCloseKey(hKey);
         goto done;
@@ -288,7 +288,7 @@ MSCredToMITCred(KERB_EXTERNAL_TICKET *msticket, UNICODE_STRING InitialTicketDoma
     creds->magic=KV5M_CREDS;
 
     // construct Client Principal
-    if ( PreserveInitialTicketIdentity ) {
+    if ( PreserveInitialTicketIdentity() ) {
         wcsncpy(wrealm, InitialTicketDomain.Buffer, InitialTicketDomain.Length/sizeof(WCHAR));
         wrealm[InitialTicketDomain.Length/sizeof(WCHAR)]=0;
     } else {
@@ -1260,6 +1260,7 @@ krb5_lcc_next_cred(krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor,
     krb5_lcc_data *data = (krb5_lcc_data *)id->data;
     KERB_EXTERNAL_TICKET *msticket, * mstgt;
 
+  next_cred:
     if ( lcursor->index >= lcursor->response->CountOfTickets )
         return KRB5_CC_END;
 
@@ -1267,6 +1268,12 @@ krb5_lcc_next_cred(krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor,
                           &lcursor->response->Tickets[lcursor->index++],&msticket))
         return KRB5_FCC_INTERNAL;
 
+    /* Don't return tickets with NULL Session Keys */
+    if ( msticket->SessionKey.KeyType == KERB_ETYPE_NULL) {
+        LsaFreeReturnBuffer(msticket);
+        goto next_cred;
+    }
+
     /* convert the ticket */
     if (GetMSTGT(data->LogonHandle, data->PackageId, &mstgt)) {
         MSCredToMITCred(msticket, mstgt->DomainName, context, creds);