From ba56a37e863d0f90e3e953047486905cfb959925 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 22 Mar 2010 00:09:43 +0100 Subject: Add support for environment variable expansion This patch teaches cgit to expand environment variables in certain cgitrc option values (cache_root, scan-path, include) plus when finding the location of cgitrc itself. One use case for this feature is virtual hosting - e.g. by setting $CGIT_CONFIG='/etc/cgitrc/$HTTP_HOST' in httpd.conf, all virtual hosts automatically gets their own cgitrc. Signed-off-by: Lars Hjemli --- cgit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cgit.c') diff --git a/cgit.c b/cgit.c index 9305d0a..37154e3 100644 --- a/cgit.c +++ b/cgit.c @@ -148,7 +148,7 @@ void config_cb(const char *name, const char *value) else if (!strcmp(name, "cache-size")) ctx.cfg.cache_size = atoi(value); else if (!strcmp(name, "cache-root")) - ctx.cfg.cache_root = xstrdup(value); + ctx.cfg.cache_root = xstrdup(expand_macros(value)); else if (!strcmp(name, "cache-root-ttl")) ctx.cfg.cache_root_ttl = atoi(value); else if (!strcmp(name, "cache-repo-ttl")) @@ -177,9 +177,9 @@ void config_cb(const char *name, const char *value) ctx.cfg.max_commit_count = atoi(value); else if (!strcmp(name, "scan-path")) if (!ctx.cfg.nocache && ctx.cfg.cache_size) - process_cached_repolist(value); + process_cached_repolist(expand_macros(value)); else - scan_tree(value, repo_config); + scan_tree(expand_macros(value), repo_config); else if (!strcmp(name, "source-filter")) ctx.cfg.source_filter = new_filter(value, 1); else if (!strcmp(name, "summary-log")) @@ -203,7 +203,7 @@ void config_cb(const char *name, const char *value) else if (!prefixcmp(name, "mimetype.")) add_mimetype(name + 9, value); else if (!strcmp(name, "include")) - parse_configfile(value, config_cb); + parse_configfile(expand_macros(value), config_cb); } static void querystring_cb(const char *name, const char *value) @@ -688,7 +688,7 @@ int main(int argc, const char **argv) cgit_repolist.repos = NULL; cgit_parse_args(argc, argv); - parse_configfile(ctx.env.cgit_config, config_cb); + parse_configfile(expand_macros(ctx.env.cgit_config), config_cb); ctx.repo = NULL; http_parse_querystring(ctx.qry.raw, querystring_cb); -- cgit v1.2.3-59-g8ed1b