svn rev #25249: trunk/src/windows/leashdll/

hartmans@MIT.EDU hartmans at MIT.EDU
Wed Sep 28 16:54:45 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25249
Commit By: hartmans
Log Message:
leashw32: do not set KRB5CCNAME to empty string

If the KRB5CCNAME variable gets set to the empty string
there will be no credential cache and the automatic credential
cache detection will be skipped.  Ensure that the KRB5CCNAME
variable is not set to an empty string by us.  If it was set
to the empty string by someone else, unset it.

Patch by Jeffrey Altman.

From: Alexey Melnikov <alexey.melnikov at isode.com>


Changed Files:
U   trunk/src/windows/leashdll/lshfunc.c
Modified: trunk/src/windows/leashdll/lshfunc.c
===================================================================
--- trunk/src/windows/leashdll/lshfunc.c	2011-09-28 20:54:41 UTC (rev 25248)
+++ trunk/src/windows/leashdll/lshfunc.c	2011-09-28 20:54:45 UTC (rev 25249)
@@ -3484,8 +3484,9 @@
     SetLastError(0);
     GetEnvironmentVariable("KRB5CCNAME", ccachename, sizeof(ccachename));
     gle = GetLastError();
-    if ( (gle == ERROR_ENVVAR_NOT_FOUND) && context ) {
-	SetEnvironmentVariable("KRB5CCNAME", pkrb5_cc_default_name(ctx));
+    if ( ((gle == ERROR_ENVVAR_NOT_FOUND) || !ccachename[0]) && context ) {
+        char * ccdef = pkrb5_cc_default_name(ctx);
+	SetEnvironmentVariable("KRB5CCNAME", ccdef ? ccdef : NULL);
 	GetEnvironmentVariable("KRB5CCNAME", ccachename, sizeof(ccachename));
     }
 
@@ -3562,15 +3563,19 @@
 
     if ( prompt && ticketinfo.btickets != GOOD_TICKETS ) {
 	acquire_tkt_send_msg(ctx, NULL, ccachename, NULL, ccname, cclen);
+        /*
+         * If the ticket manager returned an alternative credential cache
+         * remember it as the default for this process.
+         */
+        if ( ccname && ccname[0] && strcmp(ccachename,ccname) ) {
+            SetEnvironmentVariable("KRB5CCNAME",ccname);
+        }
+
     } else if (ccachename[0] && ccname) {
 	strncpy(ccname, ccachename, cclen);
 	ccname[cclen-1] = '\0';
     }
 
-    if ( ccname && ccname[0] && strcmp(ccachename,ccname) ) {
-	SetEnvironmentVariable("KRB5CCNAME",ccname);
-    }
-
     if ( !context )
         pkrb5_free_context(ctx);
 }
@@ -3598,8 +3603,9 @@
     SetLastError(0);
     GetEnvironmentVariable("KRB5CCNAME", ccachename, sizeof(ccachename));
     gle = GetLastError();
-    if ( (gle == ERROR_ENVVAR_NOT_FOUND) && context ) {
-	SetEnvironmentVariable("KRB5CCNAME", pkrb5_cc_default_name(ctx));
+    if ( ((gle == ERROR_ENVVAR_NOT_FOUND) || !ccachename[0]) && context ) {
+        char * ccdef = pkrb5_cc_default_name(ctx);
+	SetEnvironmentVariable("KRB5CCNAME", ccdef ? ccdef : NULL);
 	GetEnvironmentVariable("KRB5CCNAME", ccachename, sizeof(ccachename));
     }
 
@@ -3658,17 +3664,19 @@
     if (prompt) {
 	if (ticketinfo.btickets != GOOD_TICKETS || strcmp(name,ticketinfo.principal)) {
 	    acquire_tkt_send_msg(ctx, NULL, ccachename, desiredPrincipal, ccname, cclen);
+            /*
+             * If the ticket manager returned an alternative credential cache
+             * remember it as the default for this process.
+             */
+            if ( ccname && ccname[0] && strcmp(ccachename,ccname) ) {
+                SetEnvironmentVariable("KRB5CCNAME",ccname);
+            }
 	} else if (ccachename[0] && ccname) {
 	    strncpy(ccname, ccachename, cclen);
 	    ccname[cclen-1] = '\0';
 	}
     }
 
-    if ( ccname && ccname[0] && strcmp(ccachename,ccname) ) {
-	SetEnvironmentVariable("KRB5CCNAME",ccname);
-    }
-
-
     if (name)
 	pkrb5_free_unparsed_name(ctx, name);
 




More information about the cvs-krb5 mailing list