[OpenAFS-devel] Patch for pagsh.krb to create KRB5CCNAME variable

Rainer Toebbicke rtb@pclella.cern.ch
Wed, 21 Feb 2007 16:28:48 +0100


This is a multi-part message in MIME format.
--------------090507060906000409050902
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

The attached patch creates the appropriate KRB5CCNAME environment 
variable in pagsh.krb so that it behaves similarly for Krb5 and Krb4.

Yes, I am aware of the Heimdal pagsh. But not only is that one not 
part of OpenAFS, it is neither suitable as a #!target in a script nor 
does it use the predictable file name derived from the PAG number (at 
least not that easily predictable).

(bcc: to openafs-bugs)

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rainer Toebbicke
European Laboratory for Particle Physics(CERN) - Geneva, Switzerland
Phone: +41 22 767 8985       Fax: +41 22 767 7155

--------------090507060906000409050902
Content-Type: text/plain;
 name="p_pagsh_krb5"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="p_pagsh_krb5"

--- openafs/src/sys/pagsh.c.o142	2006-10-06 14:44:43.000000000 +0200
+++ openafs/src/sys/pagsh.c	2007-02-09 14:52:37.000000000 +0100
@@ -119,18 +119,22 @@
     afs_uint32 pag;
     struct stat sbuf;
     char fname[256], *prefix = "/ticket/";
+    char fname5[256], *prefix5 = "FILE:/ticket/krb5cc_";
     int numenv;
     char **newenv, **senv, **denv;
 
     if (stat("/ticket", &sbuf) == -1) {
 	prefix = "/tmp/tkt";
+	prefix5 = "FILE:/tmp/krb5cc_";
     }
 
     pag = curpag() & 0xffffffff;
     if (pag == -1) {
 	sprintf(fname, "%s%d", prefix, getuid());
+	sprintf(fname5, "%s%d", prefix5, getuid());
     } else {
 	sprintf(fname, "%sp%ld", prefix, pag);
+	sprintf(fname5, "%sp%ld", prefix5, pag);
     }
 /*    ktc_set_tkt_string(fname); */
 
@@ -139,13 +143,18 @@
     newenv = (char **)malloc((numenv + 2) * sizeof(char *));
 
     for (senv = environ, denv = newenv; *senv; *senv++) {
-	if (strncmp(*senv, "KRBTKFILE=", 10) != 0)
+	if (strncmp(*senv, "KRBTKFILE=", 10) != 0 &&
+		strncmp(*senv, "KRB5CCNAME=", 11) != 0)
 	    *denv++ = *senv;
     }
 
-    *denv = malloc(10 + strlen(fname) + 1);
+    *denv = malloc(10+11 + strlen(fname) + strlen(fname5) + 2);
     strcpy(*denv, "KRBTKFILE=");
     strcat(*denv, fname);
+    *(denv+1) = *denv + strlen(*denv) + 1;
+    denv++;
+    strcpy(*denv, "KRB5CCNAME=");
+    strcat(*denv, fname5);
     *++denv = 0;
     environ = newenv;
 }

--------------090507060906000409050902--