From 91461f0b21b98d66824c8c89359b18a809818c7c Mon Sep 17 00:00:00 2001 From: Dany LE Date: Tue, 4 Oct 2022 13:02:20 +0200 Subject: [PATCH] Infer plugin realpath from configuration --- http_server.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/http_server.c b/http_server.c index 422daae..3025b79 100644 --- a/http_server.c +++ b/http_server.c @@ -111,11 +111,20 @@ static int config_handler(void *conf, const char *section, const char *name, // char * ppath = NULL; if (MATCH("SERVER", "plugins")) { - if (pconfig->plugins_dir) - free(pconfig->plugins_dir); - pconfig->plugins_dir = strdup(value); - if (stat(pconfig->plugins_dir, &st) == -1) - mkdirp(pconfig->plugins_dir, 0755); + if (stat(value, &st) == -1) + mkdirp(value, 0755); + tmp = realpath(value, NULL); + if(!tmp) + { + ERROR("Unable to query real path for %s: %s", value, strerror(errno)); + } + else + { + if (pconfig->plugins_dir) + free(pconfig->plugins_dir); + pconfig->plugins_dir = tmp; + LOG("Database root is %s", pconfig->plugins_dir); + } } else if (MATCH("SERVER", "plugins_ext")) {