* set_ccache.c (gss_krb5_ccache_name): Check thread-specific data for the saved
authorKen Raeburn <raeburn@mit.edu>
Wed, 14 Jul 2004 01:54:16 +0000 (01:54 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 14 Jul 2004 01:54:16 +0000 (01:54 +0000)
"old" name to free.  Save the new old name in thread-specific data.

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

src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/set_ccache.c

index e1972de6f9223ee8ad4c4e03647abbe7fabe7a1d..b4f4ee27ebd5980b6230e6bacea285dc04c5956b 100644 (file)
@@ -6,6 +6,10 @@
        the mutex while manipulating krb5_gss_keytab.
        * gssapiP_krb5.h (gssint_krb5_keytab_lock): Declare.
 
+       * set_ccache.c (gss_krb5_ccache_name): Check thread-specific data
+       for the saved "old" name to free.  Save the new old name in
+       thread-specific data.
+
 2004-07-08  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LOCALINCLUDES): Add $(srcdir)/.. to the list.
index 9a6cdda702a31525310d4a8aa4b111546a0124cd..27422017bd9672db839ab807108edc174847fe52 100644 (file)
@@ -36,12 +36,20 @@ gss_krb5_ccache_name(minor_status, name, out_name)
        const char *name;
        const char **out_name;
 {
-    static char *gss_out_name = NULL;
-    
     char *old_name = NULL;
     OM_uint32 err = 0;
     OM_uint32 minor = 0;
 
+    char *gss_out_name;
+
+    err = gssint_initialize_library();
+    if (err) {
+       *minor_status = err;
+       return GSS_S_FAILURE;
+    }
+
+    gss_out_name = k5_getspecific(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME);
+
     if (out_name) {
         const char *tmp_name = NULL;
 
@@ -61,8 +69,8 @@ gss_krb5_ccache_name(minor_status, name, out_name)
         }
         
         if (!err) {
-            char *swap = NULL;
-            
+           char *swap = NULL;
+
             swap = gss_out_name;
             gss_out_name = old_name;
             old_name = swap;
@@ -74,7 +82,20 @@ gss_krb5_ccache_name(minor_status, name, out_name)
             err = minor;
         }
     }
-    
+
+    minor = k5_setspecific(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME, gss_out_name);
+    if (minor) {
+       /* Um.  Now what?  */
+       if (err == 0) {
+           err = minor;
+           if (out_name != NULL) {
+               *out_name = NULL;
+               out_name = NULL;
+           }
+       }
+       free(gss_out_name);
+    }
+
     if (!err) {
         if (out_name) {
             *out_name = gss_out_name;