From 1ec1e2efdf4092233ac2136dff5a35cf6c7f4710 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 10 Jun 2016 08:26:53 +0100 Subject: [PATCH] Fix use of keyd backend When keyd is in use any backend configuration is ignored for the clients and keyd contacted instead. The new config changes failed to correctly migrate the overriding mechanism for this and as a result nothing was using keyd. --- keydb_dynamic.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/keydb_dynamic.c b/keydb_dynamic.c index 5bc539c..25a359a 100644 --- a/keydb_dynamic.c +++ b/keydb_dynamic.c @@ -214,6 +214,7 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, char *initname; struct onak_dbctx *(*backend_init)(struct onak_db_config *, bool); struct onak_dynamic_dbctx *privctx; + char *type; if (dbcfg == NULL) { logthing(LOGTHING_CRITICAL, @@ -234,9 +235,9 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, return (NULL); } + type = dbcfg->type; if (config.use_keyd) { - free(config.db_backend); - config.db_backend = strdup("keyd"); + type = "keyd"; } if (!config.db_backend) { @@ -245,21 +246,21 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, } if (config.backends_dir == NULL) { - soname = malloc(strlen(dbcfg->type) + soname = malloc(strlen(type) + strlen("./libkeydb_") + strlen(".so") + 1); - sprintf(soname, "./libkeydb_%s.so", dbcfg->type); + sprintf(soname, "./libkeydb_%s.so", type); } else { - soname = malloc(strlen(dbcfg->type) + soname = malloc(strlen(type) + strlen("/libkeydb_") + strlen(".so") + strlen(config.backends_dir) + 1); sprintf(soname, "%s/libkeydb_%s.so", config.backends_dir, - dbcfg->type); + type); } logthing(LOGTHING_INFO, "Loading dynamic backend: %s", soname); @@ -278,7 +279,7 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg, + strlen("keydb_") + strlen("_init") + 1); - sprintf(initname, "keydb_%s_init", dbcfg->type); + sprintf(initname, "keydb_%s_init", type); *(void **) (&backend_init) = dlsym(privctx->backend_handle, initname); free(initname); -- 2.39.5