summaryrefslogtreecommitdiffabout
path: root/cgit.c
authorLars Hjemli <hjemli@gmail.com>2010-03-21 23:09:43 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-03-21 23:09:43 (UTC)
commitba56a37e863d0f90e3e953047486905cfb959925 (patch) (side-by-side diff)
tree965e2c917f472264de35125eec35c361984eba4f /cgit.c
parentff3a3b4e2b7463bb8cb370bdda393e8b3526fcb9 (diff)
downloadcgit-ba56a37e863d0f90e3e953047486905cfb959925.zip
cgit-ba56a37e863d0f90e3e953047486905cfb959925.tar.gz
cgit-ba56a37e863d0f90e3e953047486905cfb959925.tar.bz2
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 <hjemli@gmail.com>
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cgit.c b/cgit.c
index 9305d0a..37154e3 100644
--- a/cgit.c
+++ b/cgit.c
@@ -150,3 +150,3 @@ void config_cb(const char *name, const char *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"))
@@ -179,5 +179,5 @@ void config_cb(const char *name, const char *value)
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"))
@@ -205,3 +205,3 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "include"))
- parse_configfile(value, config_cb);
+ parse_configfile(expand_macros(value), config_cb);
}
@@ -690,3 +690,3 @@ int main(int argc, const char **argv)
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;