Infer plugin realpath from configuration
All checks were successful
gitea-sync/ant-http/pipeline/head This commit looks good

This commit is contained in:
Dany LE 2022-10-04 13:02:20 +02:00 committed by GitHub
parent 0d9d6b5497
commit 91461f0b21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,11 +111,20 @@ static int config_handler(void *conf, const char *section, const char *name,
// char * ppath = NULL; // char * ppath = NULL;
if (MATCH("SERVER", "plugins")) if (MATCH("SERVER", "plugins"))
{ {
if (pconfig->plugins_dir) if (stat(value, &st) == -1)
free(pconfig->plugins_dir); mkdirp(value, 0755);
pconfig->plugins_dir = strdup(value); tmp = realpath(value, NULL);
if (stat(pconfig->plugins_dir, &st) == -1) if(!tmp)
mkdirp(pconfig->plugins_dir, 0755); {
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")) else if (MATCH("SERVER", "plugins_ext"))
{ {