[PATCH] running cgit on a shared host
Max Christian Pohle
coderz at gmx.de
Tue Aug 2 23:54:34 CEST 2011
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);
ctx->env.http_host = xstrdupn(getenv("HTTP_HOST"));
ctx->env.https = xstrdupn(getenv("HTTPS"));
ctx->env.no_http = xstrdupn(getenv("NO_HTTP"));
More information about the CGit
mailing list