diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Keep snapshots working under a global git config
cgit unsets HOME to isolate git from the calling user, but git still finds the global config through its getpwuid fallback and then dies expanding a `~` in `core.excludesfile`. That die happened after the snapshot headers and the gzip filter were already in place, so the error page was compressed into the archive and every snapshot came out undecompressable.
Diffstat (limited to 'source/cgit.c')
-rw-r--r--source/cgit.c8
1 file changed, 7 insertions, 1 deletion
diff --git a/source/cgit.c b/source/cgit.c
index 156d2a7..909e120 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -24,8 +24,14 @@ const char *cgit_version = CGIT_VERSION;
__attribute__((constructor))
static void constructor_environment()
{
- /* Do not look in /etc/ for gitconfig and gitattributes. */
+ /*
+ * Isolate git from the calling user's configuration. Ignore the
+ * system and global config and attributes, so a snapshot cannot be
+ * broken by something like a core.excludesfile pointing at a "~" path
+ * that git can no longer expand once HOME is unset below.
+ */
setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
+ setenv("GIT_CONFIG_GLOBAL", "/dev/null", 1);
setenv("GIT_ATTR_NOSYSTEM", "1", 1);
unsetenv("HOME");
unsetenv("XDG_CONFIG_HOME");