* g_cnffile.c (krb__get_srvtabname): new function, looks up
authorMark Eichin <eichin@mit.edu>
Mon, 13 Nov 1995 01:40:31 +0000 (01:40 +0000)
committerMark Eichin <eichin@mit.edu>
Mon, 13 Nov 1995 01:40:31 +0000 (01:40 +0000)
[libdefaults]krb4_srvtab for use where KEYFILE used to be.
* g_cnffile.c (krb__v5_get_file): new function, looks up argument
in [libdefaults] and tries to open it as a filename. Returns
filehandle (or NULL, if fopen failed.)
(krb__get_cnffile, krb__get_realmsfile): use krb__v5_get_file to
look up "krb4_config" or "krb4_realms" respectively. Also add
$KRB_REALMS override for realms file.

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

src/lib/krb4/ChangeLog
src/lib/krb4/g_cnffile.c

index 6405146e28375cab4921b4635fd03b681277b38f..8a090da6858f598ff613bf7e7932e66a907ba72d 100644 (file)
@@ -1,3 +1,14 @@
+Sun Nov 12 05:26:08 1995  Mark W. Eichin  <eichin@cygnus.com>
+
+       * g_cnffile.c (krb__get_srvtabname): new function, looks up
+       [libdefaults]krb4_srvtab for use where KEYFILE used to be.
+       * g_cnffile.c (krb__v5_get_file): new function, looks up argument
+       in [libdefaults] and tries to open it as a filename. Returns
+       filehandle (or NULL, if fopen failed.)
+       (krb__get_cnffile, krb__get_realmsfile): use krb__v5_get_file to
+       look up "krb4_config" or "krb4_realms" respectively. Also add
+       $KRB_REALMS override for realms file.
+
 Mon Oct  2 11:12:05 1995  Ezra Peisach  <epeisach@kangaroo.mit.edu>
 
        * configure.in (V5_MAKE_SHARED_LIB): Change rule to install
index b1d38efdfd6d867c0fad67dfcc93c46b1ea927c9..a212beb12248a2b44e7ba5f58fab3cbc2f313f74 100644 (file)
 
 #include <stdio.h>
 #include <krb.h>
+#include "k5-int.h"
+
+static FILE*
+krb__v5_get_file(s)
+     char *s;
+{
+       FILE *cnffile = 0;
+       krb5_context context;
+       const char* names[3];
+       char **full_name = 0, **cpp;
+       krb5_error_code retval;
+
+       krb5_init_context(&context);
+       names[0] = "libdefaults";
+       names[1] = s;
+       names[2] = 0;
+       retval = profile_get_values(context->profile, names, &full_name);
+       if (retval == 0 && full_name && full_name[0]) {
+               cnffile = fopen(full_name[0],"r");
+               for (cpp = full_name; *cpp; cpp++) 
+                       krb5_xfree(*cpp);
+               krb5_xfree(full_name);
+       }
+       krb5_free_context(context);
+       return cnffile;
+}
+
+char *
+krb__get_srvtabname(default_srvtabname)
+       char *default_srvtabname;
+{
+       krb5_context context;
+       const char* names[3];
+       char **full_name = 0, **cpp;
+       krb5_error_code retval;
+       char *retname;
+
+       krb5_init_context(&context);
+       names[0] = "libdefaults";
+       names[1] = "krb4_srvtab";
+       names[2] = 0;
+       retval = profile_get_values(context->profile, names, &full_name);
+       if (retval == 0 && full_name && full_name[0]) {
+               retname = strdup(full_name[0]);
+               for (cpp = full_name; *cpp; cpp++) 
+                       krb5_xfree(*cpp);
+               krb5_xfree(full_name);
+       } else {
+               retname = strdup(default_srvtabname);
+       }
+       krb5_free_context(context);
+       return retname;
+}
 
 FILE*
 krb__get_cnffile()
@@ -25,8 +78,12 @@ krb__get_cnffile()
        FILE *cnffile = 0;
        extern char *getenv();
 
+       /* standard V4 override first */
        s = getenv("KRB_CONF");
        if (s) cnffile = fopen(s,"r");
+       /* if that's wrong, use V5 config */
+       if (!cnffile) cnffile = krb__v5_get_file("krb4_config");
+       /* and if V5 config doesn't have it, go to hard-coded values */
        if (!cnffile) cnffile = fopen(KRB_CONF,"r");
 #ifdef ATHENA_CONF_FALLBACK
        if (!cnffile) cnffile = fopen(KRB_FB_CONF,"r");
@@ -38,13 +95,17 @@ krb__get_cnffile()
 FILE*
 krb__get_realmsfile()
 {
-       FILE *realmsfile;
+       FILE *realmsfile = 0;
+       char *s;
 
-       realmsfile = fopen(KRB_RLM_TRANS, "r");
+       /* standard (not really) V4 override first */
+       s = getenv("KRB_REALMS");
+       if (s) realmsfile = fopen(s,"r");
+       if (!realmsfile) realmsfile = krb__v5_get_file("krb4_realms");
+       if (!realmsfile) realmsfile = fopen(KRB_RLM_TRANS, "r");
 
 #ifdef ATHENA_CONF_FALLBACK
-       if (realmsfile == (FILE *) 0)
-           realmsfile = fopen(KRB_FB_RLM_TRANS, "r");
+       if (!realmsfile) realmsfile = fopen(KRB_FB_RLM_TRANS, "r");
 #endif
 
        return realmsfile;