diff --git a/lib/kadm5/ChangeLog b/lib/kadm5/ChangeLog index 81c3ce633..07ec49184 100644 --- a/lib/kadm5/ChangeLog +++ b/lib/kadm5/ChangeLog @@ -1,3 +1,7 @@ +2007-12-07 Love Hörnquist Åstrand + + * use hdb_db_dir() and hdb_default_db() + 2007-10-18 Love * init_c.c: We are getting default_client, not client. this way diff --git a/lib/kadm5/context_s.c b/lib/kadm5/context_s.c index 3d4400eae..8081f75d6 100644 --- a/lib/kadm5/context_s.c +++ b/lib/kadm5/context_s.c @@ -107,13 +107,13 @@ find_db_spec(kadm5_server_context *ctx) /* If any of the values was unset, pick up the default value */ if (ctx->config.dbname == NULL) - ctx->config.dbname = strdup(HDB_DEFAULT_DB); + ctx->config.dbname = strdup(hdb_default_db(context)); if (ctx->config.acl_file == NULL) - ctx->config.acl_file = strdup(HDB_DB_DIR "/kadmind.acl"); + asprintf(&ctx->config.acl_file, "%s/kadmind.acl", hdb_db_dir(context)); if (ctx->config.stash_file == NULL) - ctx->config.stash_file = strdup(HDB_DB_DIR "/m-key"); + asprintf(&ctx->config.stash_file, "%s/m-key", hdb_db_dir(context)); if (ctx->log_context.log_file == NULL) - ctx->log_context.log_file = strdup(HDB_DB_DIR "/log"); + asprintf(&ctx->log_context.log_file, "%s/log", hdb_db_dir(context)); set_socket_name(context, &ctx->log_context.socket_name); diff --git a/lib/kadm5/iprop-log.c b/lib/kadm5/iprop-log.c index 1b282a3cb..d39ec9d0b 100644 --- a/lib/kadm5/iprop-log.c +++ b/lib/kadm5/iprop-log.c @@ -48,8 +48,13 @@ get_kadmin_context(const char *config_file, char *realm) void *kadm_handle; char **files; - if (config_file == NULL) - config_file = HDB_DB_DIR "/kdc.conf"; + if (config_file == NULL) { + char *file; + asprintf(&file, "%s/kdc.conf", hdb_db_dir(context)); + if (file == NULL) + errx(1, "out of memory"); + config_file = file; + } ret = krb5_prepend_config_files_default(config_file, &files); if (ret) diff --git a/lib/kadm5/iprop.h b/lib/kadm5/iprop.h index a456335ab..acdf863a6 100644 --- a/lib/kadm5/iprop.h +++ b/lib/kadm5/iprop.h @@ -49,10 +49,6 @@ #define IPROP_VERSION "iprop-0.0" -#define KADM5_SLAVE_ACL HDB_DB_DIR "/slaves" - -#define KADM5_SLAVE_STATS HDB_DB_DIR "/slaves-stats" - #define IPROP_NAME "iprop" #define IPROP_SERVICE "iprop" diff --git a/lib/kadm5/ipropd_master.c b/lib/kadm5/ipropd_master.c index 7f1366d58..794f4e31a 100644 --- a/lib/kadm5/ipropd_master.c +++ b/lib/kadm5/ipropd_master.c @@ -128,16 +128,19 @@ check_acl (krb5_context context, const char *name) FILE *fp; char buf[256]; int ret = 1; + char *slavefile; + asprintf(&slavefile, "%s/slaves", hdb_db_dir(context)); fn = krb5_config_get_string_default(context, NULL, - KADM5_SLAVE_ACL, + slavefile, "kdc", "iprop-acl", NULL); fp = fopen (fn, "r"); + free(slavefile); if (fp == NULL) return 1; while (fgets(buf, sizeof(buf), fp) != NULL) { @@ -592,19 +595,26 @@ process_msg (krb5_context context, slave *s, int log_fd, static FILE * open_stats(krb5_context context) { + char *statfile = NULL; const char *fn; + FILE *f; if (slave_stats_file) fn = slave_stats_file; - else + else { + asprintf(&statfile, "%s/slaves-stats", hdb_db_dir(context)); fn = krb5_config_get_string_default(context, NULL, - KADM5_SLAVE_STATS, + statfile, "kdc", "iprop-stats", NULL); + } + f = fopen(fn, "w"); + if (statfile) + free(statfile); - return fopen(fn, "w"); + return f; } static void @@ -748,8 +758,11 @@ main(int argc, char **argv) setup_signal(); - if (config_file == NULL) - config_file = HDB_DB_DIR "/kdc.conf"; + if (config_file == NULL) { + asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context)); + if (config_file == NULL) + errx(1, "out of memory"); + } ret = krb5_prepend_config_files_default(config_file, &files); if (ret) diff --git a/lib/kadm5/ipropd_slave.c b/lib/kadm5/ipropd_slave.c index d3fbccada..bef10dd5c 100644 --- a/lib/kadm5/ipropd_slave.c +++ b/lib/kadm5/ipropd_slave.c @@ -480,8 +480,11 @@ main(int argc, char **argv) setup_signal(); - if (config_file == NULL) - config_file = HDB_DB_DIR "/kdc.conf"; + if (config_file == NULL) { + asprintf(&config_file, "%s/kdc.conf", hdb_db_dir(context)); + if (config_file == NULL) + errx(1, "out of memory"); + } ret = krb5_prepend_config_files_default(config_file, &files); if (ret) diff --git a/lib/kadm5/log.c b/lib/kadm5/log.c index 99362c6dd..1fec09f3d 100644 --- a/lib/kadm5/log.c +++ b/lib/kadm5/log.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2006 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2007 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -32,6 +32,7 @@ */ #include "kadm5_locl.h" +#include "heim_threads.h" RCSID("$Id$"); @@ -961,12 +962,20 @@ kadm5_log_truncate (kadm5_server_context *server_context) } +static char *default_signal = NULL; +static HEIMDAL_MUTEX signal_mutex = HEIMDAL_MUTEX_INITIALIZER; + const char * kadm5_log_signal_socket(krb5_context context) { + HEIMDAL_MUTEX_lock(&signal_mutex); + if (!default_signal) + asprintf(&default_signal, "%s/signal", hdb_db_dir(context)); + HEIMDAL_MUTEX_unlock(&signal_mutex); + return krb5_config_get_string_default(context, NULL, - KADM5_LOG_SIGNAL, + default_signal, "kdc", "signal_socket", NULL); diff --git a/lib/kadm5/private.h b/lib/kadm5/private.h index 6b773597e..3ef3a2a1b 100644 --- a/lib/kadm5/private.h +++ b/lib/kadm5/private.h @@ -139,8 +139,6 @@ enum kadm_ops { #define KADMIN_APPL_VERSION "KADM0.1" #define KADMIN_OLD_APPL_VERSION "KADM0.0" -#define KADM5_LOG_SIGNAL HDB_DB_DIR "/signal" - #include "kadm5-private.h" #endif /* __kadm5_privatex_h__ */