From 50e4aeb22f499d1a2f955bd7d88a78606eb4e48f Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 25 Sep 2015 12:00:58 +0200 Subject: [PATCH] libtnccs: Optionally use RTLD_NOW to load IMC/IMVs with dlopen() --- conf/options/charon.opt | 4 ++-- src/libtnccs/plugins/tnc_imc/tnc_imc.c | 8 +++++++- src/libtnccs/plugins/tnc_imv/tnc_imv.c | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/conf/options/charon.opt b/conf/options/charon.opt index 808e368b6..816f3250c 100644 --- a/conf/options/charon.opt +++ b/conf/options/charon.opt @@ -66,8 +66,8 @@ charon.dh_exponent_ansi_x9_42 = yes strength. charon.dlopen_use_rtld_now = no - Use RTLD_NOW with dlopen when loading plugins to reveal missing symbols - immediately. + Use RTLD_NOW with dlopen when loading plugins and IMV/IMCs to reveal missing + symbols immediately. charon.dns1 DNS server assigned to peer via configuration payload (CP). diff --git a/src/libtnccs/plugins/tnc_imc/tnc_imc.c b/src/libtnccs/plugins/tnc_imc/tnc_imc.c index 623da7f62..822df3f27 100644 --- a/src/libtnccs/plugins/tnc_imc/tnc_imc.c +++ b/src/libtnccs/plugins/tnc_imc/tnc_imc.c @@ -349,10 +349,16 @@ static private_tnc_imc_t* tnc_imc_create_empty(char *name) imc_t* tnc_imc_create(char *name, char *path) { private_tnc_imc_t *this; + int flag = RTLD_LAZY; this = tnc_imc_create_empty(name); - this->handle = dlopen(path, RTLD_LAZY); + if (lib->settings->get_bool(lib->settings, "%s.dlopen_use_rtld_now", + lib->ns, FALSE)) + { + flag = RTLD_NOW; + } + this->handle = dlopen(path, flag); if (!this->handle) { DBG1(DBG_TNC, "IMC \"%s\" failed to load: %s", name, dlerror()); diff --git a/src/libtnccs/plugins/tnc_imv/tnc_imv.c b/src/libtnccs/plugins/tnc_imv/tnc_imv.c index 039f1fcf1..9a0304172 100644 --- a/src/libtnccs/plugins/tnc_imv/tnc_imv.c +++ b/src/libtnccs/plugins/tnc_imv/tnc_imv.c @@ -345,10 +345,16 @@ static private_tnc_imv_t* tnc_imv_create_empty(char *name) imv_t* tnc_imv_create(char *name, char *path) { private_tnc_imv_t *this; + int flag = RTLD_LAZY; this = tnc_imv_create_empty(name); - this->handle = dlopen(path, RTLD_LAZY); + if (lib->settings->get_bool(lib->settings, "%s.dlopen_use_rtld_now", + lib->ns, FALSE)) + { + flag = RTLD_NOW; + } + this->handle = dlopen(path, flag); if (!this->handle) { DBG1(DBG_TNC, "IMV \"%s\" failed to load: %s", name, dlerror());