From dfdab0f3c81a73bc4309588edaa7e39b512c28b7 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Mon, 14 Feb 2011 22:20:38 +0530 Subject: [PATCH] allow gitolite_rc.mkd values to be overridden by ~/.gitolite.rc you might wonder why these are different from all the other variables in the rc file... it's just that I never thought people would want to change these! --- doc/gitolite.rc.mkd | 18 ++++++++++++++++++ src/gitolite_rc.pm | 30 +++++++++++++++--------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/doc/gitolite.rc.mkd b/doc/gitolite.rc.mkd index 0d94f09..47fcd50 100644 --- a/doc/gitolite.rc.mkd +++ b/doc/gitolite.rc.mkd @@ -16,6 +16,7 @@ In this document: * variables with a security impact * less used/changed variables * rarely changed variables + * constants that aren't! [Note: in perl, there is no actual boolean. The undefined value, the number '0', and the empty string, are all 'false'. Everything else is 'true'. It is @@ -340,6 +341,23 @@ on feedback from my users to find or fix issues. install has completed is doable: just [disable writes][dwr] to gitolite, move `~/repositories/*`, change this variable, then re-enable writes. + + +### constants that aren't! + +The source file `src/gitolite_rc.pm` defines a few "constants", for example: + + $R_COMMANDS=qr/^(git[ -]upload-pack|git[ -]upload-archive)$/; + +Let's say you want to disallow the archive feature, you would need to change +this constant. + +As of this version, you can now change these "constants" also, simply by +defining a new value for any or all of them in your `~/.gitolite.rc` file. + +If you use this to relax some of the patterns involved (for example, the value +of `ADC_CMD_ARGS_PATT`), please be sure you know what you're doing. + [wild]: http://sitaramc.github.com/gitolite/doc/wildcard-repositories.html [bc]: http://sitaramc.github.com/gitolite/doc/big-config.html [faq]: http://sitaramc.github.com/gitolite/doc/3-faq-tips-etc.html diff --git a/src/gitolite_rc.pm b/src/gitolite_rc.pm index f3ebade..09cd172 100644 --- a/src/gitolite_rc.pm +++ b/src/gitolite_rc.pm @@ -26,21 +26,6 @@ use Exporter 'import'; $GL_HTTP_ANON_USER ); -# ------------------------------------------------------------------------------ -# bring in the rc vars and allow querying them -# ------------------------------------------------------------------------------ - -# in case we're running under Apache using smart http -$ENV{HOME} = $ENV{GITOLITE_HTTP_HOME} if $ENV{GITOLITE_HTTP_HOME}; - -# we also need to "bring in" the rc variables. The rc can only be in one of -# these two places; the first one we find, wins -for ("$ENV{HOME}/.gitolite.rc", "/etc/gitolite/gitolite.rc") { - $ENV{GL_RC} ||= $_ if -f; -} -die "no rc file found\n" unless $ENV{GL_RC}; -do $ENV{GL_RC} or die "error parsing $ENV{GL_RC}\n"; - # ------------------------------------------------------------------------------ # real constants # ------------------------------------------------------------------------------ @@ -65,6 +50,21 @@ $REPOPATT_PATT=qr(^\@?[0-9a-zA-Z[][\\^.$|()[\]*+?{}0-9a-zA-Z._\@/-]*$); # ADC commands and arguments must match this pattern $ADC_CMD_ARGS_PATT=qr(^[0-9a-zA-Z._\@/+:-]*$); +# ------------------------------------------------------------------------------ +# bring in the rc vars and allow querying them +# ------------------------------------------------------------------------------ + +# in case we're running under Apache using smart http +$ENV{HOME} = $ENV{GITOLITE_HTTP_HOME} if $ENV{GITOLITE_HTTP_HOME}; + +# we also need to "bring in" the rc variables. The rc can only be in one of +# these two places; the first one we find, wins +for ("$ENV{HOME}/.gitolite.rc", "/etc/gitolite/gitolite.rc") { + $ENV{GL_RC} ||= $_ if -f; +} +die "no rc file found\n" unless $ENV{GL_RC}; +do $ENV{GL_RC} or die "error parsing $ENV{GL_RC}\n"; + # ------------------------------------------------------------------------------ # per perl rules, this should be the last line in such a file: 1;