[25758] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

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

daemon@ATHENA.MIT.EDU (hartmans@mit.edu)
Wed Sep 28 16:54:47 2011

Date: Wed, 28 Sep 2011 16:54:45 -0400
From: hartmans@mit.edu
Message-Id: <201109282054.p8SKsjvg016904@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

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@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);
 

_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post