If RegKRB5CCNAME is set in kerberos.ini, use that value to determine the
authorRichard Basch <probe@mit.edu>
Fri, 28 Feb 1997 23:11:37 +0000 (23:11 +0000)
committerRichard Basch <probe@mit.edu>
Fri, 28 Feb 1997 23:11:37 +0000 (23:11 +0000)
registry key that contains the credential cache name to use.  This indirection
provides a means of interoperating with Gradent's PC-DCE product.
[deengert@anl.gov]

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

src/lib/krb5/os/ccdefname.c

index 639fc666b60be02dcda117790a5a76dae06df933..b1a0f4f11c3df4736519ab9e296189c834591dd5 100644 (file)
@@ -111,12 +111,55 @@ char      pathbuf[255];
         {
             char defname[160];                  /* Default value */
 
-            GetWindowsDirectory (defname, sizeof(defname)-7);
-            strcat (defname, "\\krb5cc");
-            strcpy (name_buf, "FILE:");
-            GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
-                name_buf+5, sizeof(name_buf)-5, KERBEROS_INI);
-        }
+#if defined(_WIN32)
+           /* If the RegKRB5CCNAME variable is set, it will point to
+            * the registry key that has the name of the cache to use.
+            * The Gradient PC-DCE sets the registry key
+            * [HKEY_CURRENT_USER\Software\Gradient\DCE\Default\KRB5CCNAME]
+            * to point at the cache file name (including the FILE: prefix).
+            * By indirecting with the RegKRB5CCNAME entry in kerberos.ini,
+            * we can accomodate other versions that might set a registry
+            * variable.
+            */
+           char newkey[256];
+           
+           LONG name_buf_size;
+           HKEY hkey;
+           DWORD ipType;
+           int found = 0;
+           char *cp;
+    
+
+           GetPrivateProfileString(INI_FILES, "RegKRB5CCNAME", "", 
+                                   newkey, sizeof(newkey), KERBEROS_INI); 
+           if (strlen(newkey)) {
+               cp = strrchr(newkey,'\\');
+               if (cp) {
+                   *cp = '\0'; /* split the string */
+                   cp++;
+               } else
+                   cp = "";
+               if (RegOpenKeyEx(HKEY_CURRENT_USER, newkey, 0,
+                                KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
+                   name_buf_size = sizeof(name_buf);
+                   if (RegQueryValueEx(hkey, cp, 0, &ipType, 
+                                       name_buf, &name_buf_size)
+                       == ERROR_SUCCESS) 
+                       found = 1;
+               }
+           }
+           if(!(found)) {
+#endif
+               
+               GetWindowsDirectory (defname, sizeof(defname)-7);
+               strcat (defname, "\\krb5cc");
+               strcpy (name_buf, "FILE:");
+               GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
+                                       name_buf+5, sizeof(name_buf)-5, KERBEROS_INI);
+#if defined(_WIN32)
+           }
+#endif
+       }
 #else
        sprintf(name_buf, "FILE:/tmp/krb5cc_%d", getuid());
 #endif