Added functionality for windows to read default file locations from
authorKeith Vetter <keithv@fusion.com>
Wed, 29 Mar 1995 05:06:42 +0000 (05:06 +0000)
committerKeith Vetter <keithv@fusion.com>
Wed, 29 Mar 1995 05:06:42 +0000 (05:06 +0000)
windows ini files.

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

src/lib/krb5/os/ChangeLog
src/lib/krb5/os/ccdefname.c
src/lib/krb5/os/def_realm.c
src/lib/krb5/os/get_krbhst.c
src/lib/krb5/os/hst_realm.c
src/lib/krb5/os/osconfig.c
src/lib/krb5/os/realm_dom.c

index 51ba47587f1e7fdc5677cd7c7bb65a1faf7d3971..69e77c55a46b36818e4175a7603d1903b64b6256 100644 (file)
@@ -1,3 +1,12 @@
+Tue Mar 28 19:22:28 1995 Keith Vetter (keithv@fusion.com)
+
+        For Windows, added calls to get the default config, realms and
+        ccache files out of a windows ini file.
+        * ccdefname.c: does this for the credential cache.
+        * osconfig.c: does this for the config and realms files.
+       * get_krbh.c, realm_do.c, hst_real.c, def_real.c: added calls to
+           set the default values.
+
 Tue Mar 28 18:35:20 1995  John Gilmore  (gnu at toad.com)
 
        * DNR.c:  Add Apple MacTCP source file for domain name resolution.
index 79314a6b7a184d62de82563ec3c88549e590a02c..5ec4256cd00ce6e1c665968e431099f0884f50c1 100644 (file)
@@ -24,6 +24,7 @@
  * Return default cred. cache name.
  */
 
+#define NEED_WINDOWS
 #include "k5-int.h"
 #include <stdio.h>
 
@@ -36,10 +37,18 @@ krb5_cc_default_name(context)
     
     if (name == 0) {
        if (name_buf == 0)
-           name_buf = malloc (35);
+           name_buf = malloc (160);
        
-#ifdef MSDOS_FILESYSTEM
-        strcpy (name_buf, "FILE:\\krb5cc");
+#ifdef _WINDOWS
+        {
+            char defname[160];                  /* Default value */
+
+            strcpy (defname, "FILE:");
+            GetWindowsDirectory (defname+5, 160-5-7);
+            strcat (defname, "\\krb5cc");
+            GetPrivateProfileString(INI_FILES, INI_KRB_CCACHE, defname,
+                name_buf, 160, KERBEROS_INI);
+        }
 #else
        sprintf(name_buf, "FILE:/tmp/krb5cc_%d", getuid());
 #endif
index a6f4f993bfb25d2a91520277d1bfb1503e1dac06..a7634376f39b0f00506d24e62c4bcbbabf080e9f 100644 (file)
@@ -67,6 +67,7 @@ krb5_get_default_realm(context, lrealm)
     else if (saved_realm)
            realm = saved_realm;
     else {
+           krb5_find_config_files();
            if (!(config_file = fopen(krb5_config_file, "r")))
                    /* can't open */
                    return KRB5_CONFIG_CANTOPEN;
index eeb785c0ada45d46b9e97db022d673df519c4895..0a02a3805401f0f0b2112096c0140eb0847ebed9 100644 (file)
@@ -75,6 +75,7 @@ krb5_get_krbhst(context, realm, hostlist)
                                          * case.
                                          */
 
+    krb5_find_config_files();
     if (!(config_file = fopen(krb5_config_file, "r")))
        /* can't open */
        return KRB5_CONFIG_CANTOPEN;
index e43655f62aa94477be4d70724e31880dce06ee89..2c16267dbaca6ab93bb2fc824c3a285ff834789c 100644 (file)
@@ -178,6 +178,7 @@ krb5_get_host_realm(context, host, realmsp)
        }
     }
 
+    krb5_find_config_files();
     if ((trans_file = fopen(krb5_trans_file, "r")) == (FILE *) 0) {
        krb5_xfree(retrealms[0]);
        krb5_xfree(retrealms);
@@ -186,12 +187,12 @@ krb5_get_host_realm(context, host, realmsp)
     (void) sprintf(scanstring, "%%%ds %%%ds",
                   sizeof(trans_host)-1,sizeof(trans_realm)-1);
     while (1) {
-#ifdef _WINDOWS
+        #ifdef _WINDOWS
             scanval = read_2str (trans_file, trans_host, sizeof(trans_host)-1,
                 trans_realm, sizeof(trans_realm)-1);
-#else
+        #else
             scanval = fscanf(trans_file, scanstring, trans_host, trans_realm);
-#endif
+        #endif
        if (scanval != 2) {
            if (scanval == EOF) {
                fclose(trans_file);
@@ -230,3 +231,6 @@ krb5_get_host_realm(context, host, realmsp)
     *realmsp = retrealms;
     return 0;
 }
+
+
+
index 84ec68c2f27a31dc2311956437cf4c21cf4fc167..07a3d045aec11703a77834a71ef7b161ea094de0 100644 (file)
@@ -24,6 +24,7 @@
  * Definition of default configuration parameters.
  */
 
+#define NEED_WINDOWS
 #include "k5-int.h"
 
 char *krb5_config_file = DEFAULT_CONFIG_FILENAME;
@@ -49,3 +50,41 @@ char *krb5_kdc_sec_udp_portname = 0;
 
 char *krb5_default_pwd_prompt1 = DEFAULT_PWD_STRING1;
 char *krb5_default_pwd_prompt2 = DEFAULT_PWD_STRING2;
+
+/*
+ * On Windows, we want to let the user specify in the kerberos.ini file
+ * where the config and realms files, krb.con and krb.rea, reside. If they
+ * aren't specified then we fall back to having them in the windows
+ * directory. We use the same format as the K4 version for compatability.
+ *
+ * Note: these values can change asynchronously so we can't cache the values.
+ */
+krb5_error_code
+krb5_find_config_files ()
+{
+#ifdef _WINDOWS
+    static char cnfname[160];                   /* For krb.con */
+    static char realmsname[160];                /* For krb.rea */
+    char defname[160];                          /* Default value */
+
+    /* First locate krb.con file */
+    GetWindowsDirectory(defname, sizeof(defname));
+    strcat (defname, "\\");
+    strcat (defname, DEFAULT_CONFIG_FILENAME);
+       GetPrivateProfileString(INI_FILES, INI_KRB_CONF, defname,
+       cnfname, sizeof(cnfname), KERBEROS_INI);
+    
+    /* Now locate krb.rea file */
+    GetWindowsDirectory(defname, sizeof(defname));
+    strcat (defname, "\\");
+    strcat (defname, DEFAULT_TRANS_FILENAME);
+       GetPrivateProfileString(INI_FILES, INI_KRB_REALMS, defname,
+       realmsname, sizeof(realmsname), KERBEROS_INI);
+
+    krb5_config_file = cnfname;
+    krb5_trans_file = realmsname;
+
+#endif /* _WINDOWS */
+
+    return 0;
+}
index 27907ac209338f986dc6068f24233eba228642c1..92563c1f73f3711de67113a6ddcfca3d9f26cc62 100644 (file)
@@ -122,6 +122,7 @@ krb5_get_realm_domain(context, realm, domain)
            return retval;
        realm = realmlist[0];
     }
+    krb5_find_config_files();
     if ((trans_file = fopen(krb5_trans_file, "r")) == (FILE *) 0) {
        if (realmlist != NULL) {
            krb5_xfree(realmlist[0]);
@@ -132,12 +133,12 @@ krb5_get_realm_domain(context, realm, domain)
     (void) sprintf(scanstring, "%%%ds %%%ds",
                   sizeof(trans_host)-1,sizeof(trans_realm)-1);
     while (1) {
-#ifdef _WINDOWS
+        #ifdef _WINDOWS
             scanval = read_2str (trans_file, trans_host, sizeof(trans_host)-1,
                 trans_realm, sizeof(trans_realm)-1);
-#else
+        #else
             scanval = fscanf(trans_file, scanstring, trans_host, trans_realm);
-#endif
+        #endif
        if (scanval != 2) {
            if (scanval == EOF) {
                fclose(trans_file);