diff --git a/Makefile b/Makefile index d13c5bd..977b898 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ all:: CGIT_VERSION = v1.2.3 CGIT_SCRIPT_NAME = cgit.cgi -CGIT_SCRIPT_PATH = /var/www/htdocs/cgit +CGIT_SCRIPT_PATH = /srv/cgit/ CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) -CGIT_CONFIG = /etc/cgitrc +CGIT_CONFIG = /dev/null CACHE_ROOT = /var/cache/cgit -prefix = /usr/local +prefix = /usr/server/cgit libdir = $(prefix)/lib filterdir = $(libdir)/cgit/filters docdir = $(prefix)/share/doc/cgit diff --git a/configfile.c b/configfile.c index e039109..da0d0d7 100644 --- a/configfile.c +++ b/configfile.c @@ -9,6 +9,8 @@ #include #include "configfile.h" +#define CONFIG_GENERATOR_EXEC "/srv/etc/cgit-config-gen" + static int next_char(FILE *f) { int c = fgetc(f); @@ -66,6 +68,23 @@ static int read_config_line(FILE *f, struct strbuf *name, struct strbuf *value) return 1; } +void gen_config(FILE *f){ + + pid_t cmdGenPid=fork(); + if (cmdGenPid==0) { /* child process */ + char * const theArgv[] = {CONFIG_GENERATOR_EXEC}; + + close(1); + dup(fileno(f)); + + execve(CONFIG_GENERATOR_EXEC, theArgv, (char *const []){NULL}); // Pas d'environement + exit(127); /* only if execv fails */ + } + else { /* pid!=0; parent process */ + waitpid(cmdGenPid,0,0); /* wait for child to exit */ + } +} + int parse_configfile(const char *filename, configfile_value_fn fn) { static int nesting; @@ -76,8 +95,10 @@ int parse_configfile(const char *filename, configfile_value_fn fn) /* cancel deeply nested include-commands */ if (nesting > 8) return -1; - if (!(f = fopen(filename, "r"))) + if (!(f = tmpfile())) return -1; + gen_config(f); + rewind(f); nesting++; while (read_config_line(f, &name, &value)) fn(name.buf, value.buf);