You could probably take this a step further by making it configurable instead.
On Tue, Aug 2, 2011 at 5:54 PM, Max Christian Pohle <[email protected]> wrote: > i ran into troubles using cgit on a virtual/shared host. > My modification uses getcwd to determine the path, > where cgit.cgi ist loctated, because my host disallowed > the modification of bash-enviroment-vars by prepending > text to any setting I tryed to modify. This made it > impossible to tell cgit, where it finds 'cgitrc'. > while this is not thought to be a mainstream patch, it > worked for me and might be an inspiration for others. > > --- > cgit.c | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/cgit.c b/cgit.c > index b7807ad..cdd9624 100644 > --- a/cgit.c > +++ b/cgit.c > @@ -314,6 +314,14 @@ char *xstrdupn(const char *str) > > static void prepare_context(struct cgit_context *ctx) > { > + char cfg_file[] = "/cgitrc"; > + char cfg_path[PATH_MAX]; > + > + if(getcwd(cfg_path, PATH_MAX) == NULL) > + { strcpy(cfg_path, cfg_file); } > + else > + { strcat(cfg_path, cfg_file); } > + > memset(ctx, 0, sizeof(*ctx)); > ctx->cfg.agefile = "info/web/last-modified"; > ctx->cfg.nocache = 0; > @@ -354,6 +362,7 @@ static void prepare_context(struct cgit_context *ctx) > ctx->cfg.max_atom_items = 10; > ctx->cfg.ssdiff = 0; > ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); > + ctx->env.cgit_config = xstrdupn(cfg_path); > Won't this override the environment variable for those that want to use SetEnv? Couldn't you just add SetEnv to all your vhosts instead? SetEnv CGIT_CONFIG /path/to/docroot/cgitrc Admittedly, my suggestion is not elegant to manage, say, 100 vhosts. What if people want to drop cgitrc in some other directory that's a deeper a child of DocumentRoot, or Directory depending on what is set? I would hate to start walking directories to find cgitrc, something akin to directory-walking when finding .htaccess - hence the need to specify AllowOverride None to avoid finding .htaccess. What about adding configuration that's read in /etc/cgitrc that tells cgit to check alternative paths, specifically using getcwd(). After loading main config, we'll try searching for cgitrc based on getcwed() for some VirtualHost. I'd prefer not to directory walk when locating cgitrc under some DocumentRoot. Why not, based on configuration, check DocumentRoot instead of using getcwd() when locating additional configuration to parse: getenv("DOCUMENT_ROOT")/cgitrc I suspect your intention is to allow each vhosts' cgitrc to configure where to find appropriate git repos anyway. > ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); > ctx->env.https = xstrdupn(getenv("HTTPS")); > ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); > > ______________________________**_________________ > cgit mailing list > [email protected] > http://hjemli.net/mailman/**listinfo/cgit<http://hjemli.net/mailman/listinfo/cgit> > _______________________________________________ cgit mailing list [email protected] http://hjemli.net/mailman/listinfo/cgit
