get the default realm from [libdefaults]/default_realm.
get_krbhst.c (krb5_get_krbhst): Use the profile code to get the
list of Kerberos servers for a particualar realm from
[realms]/<realm>/kdc
realm_dom.c (krb5_get_realm_domain): Use the profile code to
get the default domain postfix for a realm (used only to
convert V4 -> V5 principals) from
[realms]/<realm>/default_domain
hst_realm.c (krb5_get_host_realm): Use the profile code to get
the default realm given a particular host from
[domain_realm]/<host|domain>
init_os_ctx.c (krb5_os_init_context): When the OS context is
initialized, also initialize the profile file. This loads
in the /etc/krb5.conf file.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5438
dc483132-0cff-0310-8789-
dd5450dbe970
+Fri Apr 21 11:38:45 1995 Theodore Y. Ts'o <tytso@lurch.mit.edu>
+
+ * def_realm.c (krb5_get_default_realm): Use the profile code to
+ get the default realm from [libdefaults]/default_realm.
+
+ * get_krbhst.c (krb5_get_krbhst): Use the profile code to get the
+ list of Kerberos servers for a particualar realm from
+ [realms]/<realm>/kdc
+
+ * realm_dom.c (krb5_get_realm_domain): Use the profile code to
+ get the default domain postfix for a realm (used only to
+ convert V4 -> V5 principals) from
+ [realms]/<realm>/default_domain
+
+ * hst_realm.c (krb5_get_host_realm): Use the profile code to get
+ the default realm given a particular host from
+ [domain_realm]/<host|domain>
+
+ * init_os_ctx.c (krb5_os_init_context): When the OS context is
+ initialized, also initialize the profile file. This loads
+ in the /etc/krb5.conf file.
+
Wed Apr 19 13:50:19 1995 Ezra Peisach (epeisach@kangaroo.mit.edu)
* def_realm.c: (krb5_get_default_realm) - remove global default realm.
krb5_context context;
char **lrealm;
{
+#ifdef OLD_CONFIG_FILE
FILE *config_file;
char realmbuf[BUFSIZ];
+#endif
char *realm;
char *cp;
return KV5M_CONTEXT;
if (!context->default_realm) {
+#ifdef OLD_CONFIG_FILE
krb5_find_config_files();
if (!(config_file = fopen(krb5_config_file, "r")))
/* can't open */
return ENOMEM;
strcpy(context->default_realm, realmbuf);
+#else
+ /*
+ * XXX should try to figure out a reasonable default based
+ * on the host's DNS domain.
+ */
+ context->default_realm = 0;
+ profile_get_string(context->profile, "libdefaults",
+ "default_realm", 0, 0,
+ &context->default_realm);
+ if (context->default_realm == 0)
+ return(KRB5_CONFIG_BADFORMAT);
+#endif
}
realm = context->default_realm;
* hostname added to the list returned.
*/
+#ifdef OLD_CONFIG_FILES
+
extern char *krb5_config_file; /* extern so can be set at
load/runtime */
return retval;
}
+#else
+krb5_error_code
+krb5_get_krbhst(context, realm, hostlist)
+ krb5_context context;
+ const krb5_data *realm;
+ char ***hostlist;
+{
+ char **values, **cpp, *cp;
+ const char *realm_kdc_names[4];
+ krb5_error_code retval;
+
+ realm_kdc_names[0] = "realms";
+ realm_kdc_names[1] = realm->data;
+ realm_kdc_names[2] = "kdc";
+ realm_kdc_names[3] = 0;
+
+ if (context->profile == 0)
+ return KRB5_CONFIG_CANTOPEN;
+
+ retval = profile_get_values(context->profile, realm_kdc_names, &values);
+ if (retval == PROF_NO_SECTION)
+ return KRB5_REALM_UNKNOWN;
+ if (retval == PROF_NO_RELATION)
+ return KRB5_CONFIG_BADFORMAT;
+ if (retval)
+ return retval;
+
+ /*
+ * Do cleanup over the list. We allow for some extra field to be
+ * added to the kdc line later (maybe the port number)
+ */
+ for (cpp = values; *cpp; cpp++) {
+ cp = strchr(*cpp, ' ');
+ if (cp)
+ *cp = 0;
+ cp = strchr(*cpp, '\t');
+ if (cp)
+ *cp = 0;
+ cp = strchr(*cpp, ',');
+ if (cp)
+ *cp = 0;
+ }
+
+ *hostlist = values;
+ return 0;
+}
+#endif
#define MAXHOSTNAMELEN 64
#endif
+#ifdef OLD_CONFIG_FILES
+
#define DEF_REALMNAME_SIZE 256
extern char *krb5_trans_file;
return 0;
}
+#else
+
+krb5_error_code
+krb5_get_host_realm(context, host, realmsp)
+ krb5_context context;
+ const char *host;
+ char ***realmsp;
+{
+ char **retrealms;
+ char *domain, *default_realm, *realm, *cp;
+ krb5_error_code retval;
+ char local_host[MAXHOSTNAMELEN+1];
+
+ if (host)
+ strncpy(local_host, host, MAXHOSTNAMELEN);
+ else {
+ if (gethostname(local_host, sizeof(local_host)-1) == -1)
+ return errno;
+ }
+ local_host[sizeof(local_host)-1] = '\0';
+ for (cp = local_host; *cp; cp++) {
+ if (isupper(*cp))
+ *cp = tolower(*cp);
+ }
+ domain = strchr(local_host, '.');
+
+ /* prepare default */
+ if (domain) {
+ if (!(default_realm = malloc(strlen(domain+1)+1)))
+ return ENOMEM;
+ strcpy(default_realm, domain+1);
+ /* Upper-case realm */
+ for (cp = default_realm; *cp; cp++)
+ if (islower(*cp))
+ *cp = toupper(*cp);
+ } else {
+ retval = krb5_get_default_realm(context, &default_realm);
+ if (retval) {
+ krb5_xfree(retrealms);
+ return retval;
+ }
+ }
+
+ retval = profile_get_string(context->profile, "domain_realm", local_host,
+ 0, default_realm, &realm);
+ free(default_realm);
+ if (retval)
+ return retval;
+ default_realm = realm;
+ retval = profile_get_string(context->profile, "domain_realm", domain,
+ 0, default_realm, &realm);
+ free(default_realm);
+ if (retval)
+ return retval;
+ if (!(retrealms = (char **)calloc(2, sizeof(*retrealms)))) {
+ free(realm);
+ return ENOMEM;
+ }
+
+ retrealms[0] = realm;
+ retrealms[1] = 0;
+
+ *realmsp = retrealms;
+ return 0;
+}
+
+#endif
krb5_context ctx;
{
krb5_os_context os_ctx;
+ krb5_error_code retval;
+ char *name;
+ char *filenames[2];
if (ctx->os_context)
return 0;
os_ctx->magic = KV5M_OS_CONTEXT;
ctx->os_context = (void *) os_ctx;
+
+#ifndef OLD_CONFIG_FILES
+ /*
+ * When the profile routines are later enhanced, we will try
+ * including a config file from user's home directory here.
+ */
+ name = getenv("KRB5_CONFIG");
+ filenames[0] == name ? name : DEFAULT_PROFILE_FILENAME;
+ filenames[1] = 0;
+
+ retval = profile_init(filenames, &ctx->profile);
+ if (retval)
+ ctx->profile = 0;
+#endif
return 0;
}
os_ctx->magic = 0;
free(os_ctx);
ctx->os_context = 0;
+
+ if (ctx->profile)
+ profile_release(ctx->profile);
}
#include <ctype.h>
#include <stdio.h>
+#ifdef OLD_CONFIG_FILES
+
/* for old Unixes and friends ... */
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
}
}
}
+
+#else
+
+krb5_error_code
+krb5_get_realm_domain(context, realm, domain)
+ krb5_context context;
+ const char *realm;
+ char **domain;
+{
+ krb5_error_code retval;
+
+ retval = profile_get_string(context->profile, "realms", realm,
+ "default_domain", realm, domain);
+ return retval;
+}
+#endif