[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
kadmin doesn't use specified config file
Hello all,
I noticed the -c option of kadmin and kadmind doesn't work properly since
only little information is read from specified file. The rest of needed
setup information (e.g. path to the database) is either read from
/etc/krb5.conf (or another file pointed to by KRB5_CONFIG) or set to default
values (if such info is not available in krb5.conf).
I think the behavior of these programs should be the same as e.g. of KDC.
Inspired by the KDC code I've written a simple patch, which seems to fix the
behavior (see attachements). Is it possible to add it to the standard
Heimdal distribution?
Cheers,
--
Dan
--- kadmind.c.orig Tue Jun 17 08:49:53 2003
+++ kadmind.c Tue Jun 17 09:04:21 2003
@@ -100,11 +100,13 @@
main(int argc, char **argv)
{
krb5_error_code ret;
- krb5_config_section *cf;
int optind = 0;
int e;
krb5_log_facility *logf;
krb5_keytab keytab;
+ char **files;
+ char *tmp;
+ const char *p;
setprogname(argv[0]);
@@ -136,12 +138,24 @@
if (config_file == NULL)
config_file = HDB_DB_DIR "/kdc.conf";
- if(krb5_config_parse_file(context, config_file, &cf) == 0) {
- const char *p = krb5_config_get_string (context, cf,
- "kdc", "key-file", NULL);
- if (p)
- keyfile = strdup(p);
- }
+ asprintf(&tmp, "%s:%s", config_file, krb5_config_file);
+ if(tmp == NULL)
+ krb5_err(context, 1, ENOMEM, "out of memory");
+
+ krb5_config_file = tmp;
+
+ ret = krb5_get_default_config_files(&files);
+ if(ret)
+ krb5_err(context, 1, ret, "reading configuration files");
+ ret = krb5_set_config_files(context, files);
+ krb5_free_config_files(files);
+ if(ret)
+ krb5_err(context, 1, ret, "reading configuration files");
+
+ p = krb5_config_get_string (context, NULL,
+ "kdc", "key-file", NULL);
+ if (p)
+ keyfile = strdup(p);
ret = krb5_kt_resolve(context, keytab_str, &keytab);
if(ret)
--- kadmin.c.orig Tue Jun 17 09:02:43 2003
+++ kadmin.c Tue Jun 17 09:06:54 2003
@@ -221,9 +221,11 @@
main(int argc, char **argv)
{
krb5_error_code ret;
- krb5_config_section *cf = NULL;
kadm5_config_params conf;
int optind = 0;
+ char **files;
+ char *tmp;
+ const char *p;
setprogname(argv[0]);
@@ -248,12 +250,25 @@
if (config_file == NULL)
config_file = HDB_DB_DIR "/kdc.conf";
- if(krb5_config_parse_file(context, config_file, &cf) == 0) {
- const char *p = krb5_config_get_string (context, cf,
- "kdc", "key-file", NULL);
- if (p)
- keyfile = strdup(p);
- }
+ asprintf(&tmp, "%s:%s", config_file, krb5_config_file);
+ if(tmp == NULL)
+ krb5_err(context, 1, ENOMEM, "out of memory");
+
+ krb5_config_file = tmp;
+
+ ret = krb5_get_default_config_files(&files);
+ if(ret)
+ krb5_err(context, 1, ret, "reading configuration files");
+ ret = krb5_set_config_files(context, files);
+ krb5_free_config_files(files);
+ if(ret)
+ krb5_err(context, 1, ret, "reading configuration files");
+
+ p = krb5_config_get_string (context, NULL,
+ "kdc", "key-file", NULL);
+ if (p)
+ keyfile = strdup(p);
+
krb5_clear_error_string (context);
memset(&conf, 0, sizeof(conf));
@@ -316,7 +331,6 @@
ret = sl_loop (actual_cmds, "kadmin> ") != 0;
kadm5_destroy(kadm_handle);
- krb5_config_file_free (context, cf);
krb5_free_context(context);
return ret;
}