[1196] in Kerberos-V5-bugs
krb5b4pl3: default to "kerberos.REALM" if "REALM" isn't in krb.conf
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Sun Mar 19 20:37:38 1995
From: "Jonathan I. Kamens" <jik@cam.ov.com>
Date: Sun, 19 Mar 1995 20:40:44 -0500
To: krb5-bugs@MIT.EDU
I believe that at one point, we (i.e., OV) submitted a patch to add
this functionality, based on a release earlier than krb5b4pl3.
Subsequently, I believe that Cygnus submitted a similar patch. Well,
just for thoroughness, now that we're finally migrating all of our
changes to krb5b4pl3, here's the patch from us, based on that release.
--- lib/krb5/os/get_krbhst.c 1995/03/02 02:08:19 1.1
+++ lib/krb5/os/get_krbhst.c 1995/03/02 02:12:32
@@ -29,6 +29,11 @@
#include <krb5/ext-proto.h>
#include <stdio.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+#define DEF_KDC_HOSTNAME "kerberos."
/*
Figures out the Kerberos server names for the given realm, filling in a
@@ -76,9 +81,32 @@
* case.
*/
- if (!(config_file = fopen(krb5_config_file, "r")))
- /* can't open */
- return KRB5_CONFIG_CANTOPEN;
+ if (!(config_file = fopen(krb5_config_file, "r"))) {
+ char *host_ptr;
+
+ retval = KRB5_CONFIG_CANTOPEN;
+
+ try_default_hostname:
+ /* Can't open the config file. See if there's a host named
+ "kerberos.realm", and if so, use that as the single
+ kerberos server. */
+ if (host_ptr = malloc(realm->length + strlen(DEF_KDC_HOSTNAME) + 1)) {
+ struct hostent *hent;
+
+ (void) sprintf(host_ptr, "%s%*s", DEF_KDC_HOSTNAME,
+ realm->length, realm->data);
+ if ((hent = gethostbyname(host_ptr)) &&
+ (rethlist = (char **) calloc(2, sizeof(*rethlist)))) {
+ rethlist[0] = host_ptr;
+ *hostlist = rethlist;
+ return 0;
+ }
+ free(host_ptr);
+ }
+
+ *hostlist = 0;
+ return retval;
+ }
if (fgets(filebuf, sizeof(filebuf), config_file) == NULL)
retval = KRB5_CONFIG_BADFORMAT;
@@ -144,10 +172,12 @@
if (hlindex == 0) {
krb5_xfree(rethlist);
rethlist = 0;
- retval = KRB5_REALM_UNKNOWN;
+ if (! retval) {
+ retval = KRB5_REALM_UNKNOWN;
+ goto try_default_hostname;
+ }
}
*hostlist = rethlist;
return retval;
}
-