author | Lars Hjemli <hjemli@gmail.com> | 2010-03-21 23:09:43 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-03-21 23:09:43 (UTC) |
commit | ba56a37e863d0f90e3e953047486905cfb959925 (patch) (unidiff) | |
tree | 965e2c917f472264de35125eec35c361984eba4f /cgit.c | |
parent | ff3a3b4e2b7463bb8cb370bdda393e8b3526fcb9 (diff) | |
download | cgit-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>
-rw-r--r-- | cgit.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -150,3 +150,3 @@ void config_cb(const char *name, const char *value) | |||
150 | else if (!strcmp(name, "cache-root")) | 150 | else if (!strcmp(name, "cache-root")) |
151 | ctx.cfg.cache_root = xstrdup(value); | 151 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); |
152 | else if (!strcmp(name, "cache-root-ttl")) | 152 | else if (!strcmp(name, "cache-root-ttl")) |
@@ -179,5 +179,5 @@ void config_cb(const char *name, const char *value) | |||
179 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) | 179 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
180 | process_cached_repolist(value); | 180 | process_cached_repolist(expand_macros(value)); |
181 | else | 181 | else |
182 | scan_tree(value, repo_config); | 182 | scan_tree(expand_macros(value), repo_config); |
183 | else if (!strcmp(name, "source-filter")) | 183 | else if (!strcmp(name, "source-filter")) |
@@ -205,3 +205,3 @@ void config_cb(const char *name, const char *value) | |||
205 | else if (!strcmp(name, "include")) | 205 | else if (!strcmp(name, "include")) |
206 | parse_configfile(value, config_cb); | 206 | parse_configfile(expand_macros(value), config_cb); |
207 | } | 207 | } |
@@ -690,3 +690,3 @@ int main(int argc, const char **argv) | |||
690 | cgit_parse_args(argc, argv); | 690 | cgit_parse_args(argc, argv); |
691 | parse_configfile(ctx.env.cgit_config, config_cb); | 691 | parse_configfile(expand_macros(ctx.env.cgit_config), config_cb); |
692 | ctx.repo = NULL; | 692 | ctx.repo = NULL; |