Remove use of client principal from krb5_context (default_ccprincipal) and default...
authorAlexandra Ellwood <lxs@mit.edu>
Thu, 15 Jul 2004 17:45:04 +0000 (17:45 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Thu, 15 Jul 2004 17:45:04 +0000 (17:45 +0000)
ticket: 2634

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

src/include/ChangeLog
src/include/k5-int.h
src/lib/krb4/CCache-glue.c
src/lib/krb4/ChangeLog
src/lib/krb5/ccache/ChangeLog
src/lib/krb5/ccache/ccdefault.c
src/lib/krb5/os/ChangeLog
src/lib/krb5/os/ccdefname.c
src/lib/krb5/os/init_os_ctx.c

index 04be6e5877e0074f81fed2cb68a39613e9751e16..88178298ae0494caabc381ff1fb3bcf89997201f 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-15  Alexandra Ellwood  <lxs@mit.edu>
+
+       * k5-int.h (krb5_os_context) 
+        Removed default_ccprincipal field from krb5_context
+
 2004-07-14  Jeffrey Altman <jaltman@mit.edu>
 
     * k5-int.h: define for WIN32 the macro krb5int_zap_data to 
index d668f1ec9a524fe67e313038d36301c2e98f778e..4041309740fb60828e41caccf32278aa1aac47d6 100644 (file)
@@ -764,7 +764,6 @@ typedef struct _krb5_os_context {
        krb5_int32              usec_offset;
        krb5_int32              os_flags;
        char *                  default_ccname;
-       krb5_principal  default_ccprincipal;
 } *krb5_os_context;
 
 /*
index 3a585377f3eeaaf5c561ebfffe70fa8106c41636..db00631f856f523cf2fde5252d668b7be740337c 100644 (file)
@@ -68,11 +68,7 @@ static void UpdateDefaultCache (void);
 /*
  * Name of the default cache
  */
-char*                  gDefaultCacheName = NULL;
-char                   gDefaultName[ANAME_SZ];
-char                   gDefaultInstance[INST_SZ];
-char                   gDefaultRealm[REALM_SZ];
-Boolean                        gHaveDefaultPrincipal = false;
+char* gDefaultCacheName = NULL;
 
 /*
  * Initialize credentials cache
@@ -329,44 +325,13 @@ krb_get_cred (
        if (strncmp (service, KRB_TICKET_GRANTING_TICKET, ANAME_SZ) == 0) {
                OSStatus        err;
                char            *cacheName;
-               KLPrincipal     defaultPrincipal = nil;
                KLPrincipal     outPrincipal;
                
-               if (gHaveDefaultPrincipal) {
-                       err = KLCreatePrincipalFromTriplet (gDefaultName, gDefaultInstance, gDefaultRealm, &defaultPrincipal);
-                       if (err != klNoErr)
-                               defaultPrincipal = nil;
-               }
-                                       
-               err = __KLInternalAcquireInitialTicketsForCache (defaultPrincipal, NULL, TKT_FILE, 
-                                                        kerberosVersion_V4, &outPrincipal, &cacheName);
-               if (defaultPrincipal != nil)
-                       KLDisposePrincipal (defaultPrincipal);
-
-               if (err == noErr) {
-                       char*   newName = nil;
-                       char*   newInstance = nil;
-                       char*   newRealm = nil;
-               
-                       gHaveDefaultPrincipal = false;
-                       err = KLGetTripletFromPrincipal (outPrincipal, &newName, &newInstance, &newRealm);
-                       if (err == noErr) {
-                               // If this isn't a valid krb4 principal, don't store it or track the cache name
-                               if ((strlen (newName) < ANAME_SZ) && (strlen (newInstance) < INST_SZ) && 
-                                                                                                               (strlen (newRealm) < REALM_SZ)) {
-                                       strcpy (gDefaultName, newName);
-                                       strcpy (gDefaultInstance, newInstance);
-                                       strcpy (gDefaultRealm, newRealm);
-                                       krb_set_tkt_string (cacheName);         // Tickets for the krb4 principal went here
-                                       
-                                       gHaveDefaultPrincipal = true;
-                               }
-                               
-                               KLDisposeString (newName);
-                               KLDisposeString (newInstance);
-                               KLDisposeString (newRealm);
-                       }
-                       
+               err = __KLInternalAcquireInitialTicketsForCache (TKT_FILE, kerberosVersion_V4, NULL, 
+                                                                 &outPrincipal, &cacheName);
+
+               if (err == klNoErr) {
+                       krb_set_tkt_string (cacheName);         // Tickets for the krb4 principal went here
                        KLDisposeString (cacheName);    
                        KLDisposePrincipal (outPrincipal);
                } else {
@@ -498,7 +463,6 @@ krb_set_tkt_string (
                gDefaultCacheName = malloc (strlen (val) + 1);
                if (gDefaultCacheName != NULL)
                        strcpy (gDefaultCacheName, val);
-               gHaveDefaultPrincipal = false;
        }
 }
 
index 7b865d367bf75f1fea9a189d1d665e58f37529da..41c3210788cfaff64c92c41cb50afc226e992543 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-15  Alexandra Ellwood  <lxs@mit.edu>
+
+       * CCache-glue.c (krb_get_cred) 
+        Removed default principal tracking.
+
 2004-07-14  Ken Raeburn  <raeburn@mit.edu>
 
        * recvauth.c (krb_recvauth): Initialize cp and tmp_buf.  Check
index ea620fcce0f34a306fc5ce9ba423b12935e09718..143fa581d9bdf36ef8a0300b94199e7cdab5ea1c 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-15  Alexandra Ellwood  <lxs@mit.edu>
+
+       * ccdefault.c (krb5_cc_default, krb5int_cc_default) 
+        Removed default_ccprincipal field from krb5_context
+
 2004-07-14  Ken Raeburn  <raeburn@mit.edu>
 
        * t_cc.c (cc_test): Rename one of the "resolve" cases so the
index 3dfb1a32cf51813c6e009ed3ede79903da11cb43..8a45a243b8df7d5dfdf19db5243c1a9453be894c 100644 (file)
@@ -42,7 +42,7 @@ static HANDLE hLeashDLL = INVALID_HANDLE_VALUE;
 krb5_error_code KRB5_CALLCONV
 krb5_cc_default(krb5_context context, krb5_ccache *ccache)
 {
-    krb5_error_code retval;
+       krb5_error_code retval;
        krb5_os_context os_ctx;
 
        if (!context || context->magic != KV5M_CONTEXT)
@@ -50,13 +50,7 @@ krb5_cc_default(krb5_context context, krb5_ccache *ccache)
        
        os_ctx = context->os_context;
        
-    retval = krb5_cc_resolve(context, krb5_cc_default_name(context), ccache);
-    if (!retval && ccache && !os_ctx->default_ccprincipal) {
-       /* We got a ccache... remember what principal is associated with it */
-       if (krb5_cc_get_principal (context, *ccache, &os_ctx->default_ccprincipal) != 0)
-               os_ctx->default_ccprincipal = 0;
-    }
-    return retval; 
+       return krb5_cc_resolve(context, krb5_cc_default_name(context), ccache);
 }
 
 /* This is the internal function which opens the default ccache.  On platforms supporting
@@ -69,53 +63,29 @@ krb5_cc_default(krb5_context context, krb5_ccache *ccache)
 krb5_error_code KRB5_CALLCONV
 krb5int_cc_default(krb5_context context, krb5_ccache *ccache)
 {
-#ifdef USE_LOGIN_LIBRARY
-       {
-               /* make sure the default cache has tix before you open it */
-               char                            *outCacheName;
-               KLPrincipal                     desiredPrincipal = nil;
-               krb5_principal          desiredKrb5Principal;
-               krb5_error_code         err;
-               krb5_os_context         os_ctx;
+    if (!context || context->magic != KV5M_CONTEXT) {
+        return KV5M_CONTEXT;
+    }
 
-               if (!context || context->magic != KV5M_CONTEXT)
-                       return KV5M_CONTEXT;
-       
-               os_ctx = context->os_context;
-                               
-               desiredKrb5Principal = os_ctx->default_ccprincipal;
-               
-               /* do we want a specific client principal? */
-               if (desiredKrb5Principal != NULL) {
-                       char            *desiredName;
-                       
-                       err = krb5_unparse_name (context, desiredKrb5Principal, &desiredName);
-                       if (!err) {
-                               err = KLCreatePrincipalFromString (desiredName, 
-                                                               kerberosVersion_V5, &desiredPrincipal);
-                               krb5_free_unparsed_name (context, desiredName);
-                               if (err != klNoErr)
-                                       desiredPrincipal = nil;
-                       }
-               }
-               
-               /* Try to make sure a krb5 tgt is in the cache */
-               err = __KLInternalAcquireInitialTicketsForCache (desiredPrincipal, NULL, 
-                                                    krb5_cc_default_name (context), 
-                                                                                                       kerberosVersion_V5, nil, &outCacheName);
-               if (err == klNoErr) {
-                       /* This function tries to get tickets and put them in the specified 
-                          cache, however, if the cache does not exist, it may choose to put 
-                          them elsewhere (ie: the system default) so we set that here */
-                       if (strcmp (krb5_cc_default_name (context), outCacheName) != 0) {
-                               krb5_cc_set_default_name (context, outCacheName);
-                       }
-                       KLDisposeString (outCacheName);
-               }
-               
-               if (desiredPrincipal != nil)
-                       KLDisposePrincipal (desiredPrincipal);
-       }
+#ifdef USE_LOGIN_LIBRARY
+    {
+        /* make sure the default cache has tix before you open it */
+        KLStatus err = klNoErr;
+        char *outCacheName = NULL;
+        
+        /* Try to make sure a krb5 tgt is in the cache */
+        err = __KLInternalAcquireInitialTicketsForCache (krb5_cc_default_name (context), kerberosVersion_V5, 
+                                                         NULL, NULL, &outCacheName);
+        if (err == klNoErr) {
+            /* This function tries to get tickets and put them in the specified 
+            cache, however, if the cache does not exist, it may choose to put 
+            them elsewhere (ie: the system default) so we set that here */
+            if (strcmp (krb5_cc_default_name (context), outCacheName) != 0) {
+                krb5_cc_set_default_name (context, outCacheName);
+            }
+            KLDisposeString (outCacheName);
+        }
+    }
 #else
 #ifdef USE_LEASH
 
@@ -123,20 +93,12 @@ krb5int_cc_default(krb5_context context, krb5_ccache *ccache)
         hLeashDLL = LoadLibrary("leashw32.dll");
         if ( hLeashDLL != INVALID_HANDLE_VALUE ) {
             (FARPROC) pLeash_AcquireInitialTicketsIfNeeded =
-                GetProcAddress(hLeashDLL, "not_an_API_Leash_AcquireInitialTicketsIfNeeded");
+            GetProcAddress(hLeashDLL, "not_an_API_Leash_AcquireInitialTicketsIfNeeded");
         }
     }
-
-    if ( pLeash_AcquireInitialTicketsIfNeeded )
-    {
-              krb5_os_context         os_ctx;
-
-        if (!context || context->magic != KV5M_CONTEXT)
-            return KV5M_CONTEXT;
-
-              os_ctx = context->os_context;
-
-        pLeash_AcquireInitialTicketsIfNeeded(context,os_ctx->default_ccprincipal);
+    
+    if ( pLeash_AcquireInitialTicketsIfNeeded ) {
+        pLeash_AcquireInitialTicketsIfNeeded(context, NULL);
     }
 #endif
 #endif
index 4efd66d127f2d96669659c732af1d5c348c53ce4..65a8ebc7c0157710c808bb027a4344f27cc2e4f2 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-15  Alexandra Ellwood  <lxs@mit.edu>
+
+       * init_os_ctx.c (krb5_os_init_context, krb5_os_free_context) 
+          ccdefname.c (krb5_cc_set_default_name):
+        Removed default_ccprincipal field from krb5_context
+
 2004-07-04  Ken Raeburn  <raeburn@mit.edu>
 
        * dnssrv.c (krb5int_make_srv_query_realm) [HAVE_RES_NSEARCH]: Use
index e77bcfef92a719a1e1872b7acf0758f65afcb50c..9db56d468c4071f696365ff9f870fd164ba192f7 100644 (file)
@@ -259,13 +259,6 @@ krb5_cc_set_default_name(krb5_context context, const char *name)
                return ENOMEM;
        strcpy(new_name, name_buf);
        
-       if (!os_ctx->default_ccname || (strcmp(os_ctx->default_ccname, new_name) != 0)) {
-               /* the ccache changed... forget the old principal */
-               if (os_ctx->default_ccprincipal)
-                       krb5_free_principal (context, os_ctx->default_ccprincipal);
-               os_ctx->default_ccprincipal = 0;  /* we don't care until we use it */
-       }
-       
        if (os_ctx->default_ccname)
                free(os_ctx->default_ccname);
 
index b569b8a862c00a4276da6431435173f250ae21e5..0dd7cccd62a3982063ea99107d2d3f09dec4c73e 100644 (file)
@@ -349,7 +349,6 @@ krb5_os_init_context(krb5_context ctx)
        os_ctx->usec_offset = 0;
        os_ctx->os_flags = 0;
        os_ctx->default_ccname = 0;
-       os_ctx->default_ccprincipal = 0;
 
        krb5_cc_set_default_name(ctx, NULL);
 
@@ -459,11 +458,6 @@ krb5_os_free_context(krb5_context ctx)
                 os_ctx->default_ccname = 0;
         }
 
-       if (os_ctx->default_ccprincipal) {
-               krb5_free_principal (ctx, os_ctx->default_ccprincipal);
-               os_ctx->default_ccprincipal = 0;
-       }
-
        os_ctx->magic = 0;
 
        if (ctx->profile) {