2011-01-15 16:39:56 +01:00
|
|
|
# stuff to help pull in the rc file, plus various constants
|
|
|
|
|
|
|
|
package gitolite_rc;
|
|
|
|
use Exporter 'import';
|
|
|
|
|
|
|
|
# the first set (before the blank line) are constants defined right here in
|
|
|
|
# this program. The second set are from the 'rc'; We're clubbing all in
|
|
|
|
# because they're all "constants" in a programmatic sense
|
|
|
|
@EXPORT = qw(
|
|
|
|
$ABRT $WARN
|
|
|
|
$R_COMMANDS $W_COMMANDS
|
|
|
|
$REPONAME_PATT $USERNAME_PATT $REPOPATT_PATT
|
|
|
|
$ADC_CMD_ARGS_PATT
|
2011-03-24 02:45:35 +01:00
|
|
|
$BIG_INFO_CAP
|
2011-01-15 16:39:56 +01:00
|
|
|
$current_data_version
|
|
|
|
|
|
|
|
$ADMIN_POST_UPDATE_CHAINS_TO $ENV $GITOLITE_BASE $GITOLITE_PATH $GIT_PATH
|
|
|
|
$GL_ADC_PATH $GL_ADMINDIR $GL_ALL_INCLUDES_SPECIAL $GL_ALL_READ_ALL
|
|
|
|
$GL_BIG_CONFIG $GL_CONF $GL_CONF_COMPILED $GL_GET_MEMBERSHIPS_PGM
|
|
|
|
$GL_GITCONFIG_KEYS $GL_GITCONFIG_WILD $GL_KEYDIR $GL_LOGT $GL_NICE_VALUE
|
|
|
|
$GL_NO_CREATE_REPOS $GL_NO_DAEMON_NO_GITWEB $GL_NO_SETUP_AUTHKEYS
|
|
|
|
$GL_PACKAGE_CONF $GL_PACKAGE_HOOKS $GL_PERFLOGT $GL_SITE_INFO
|
|
|
|
$GL_SLAVE_MODE $GL_WILDREPOS $GL_WILDREPOS_DEFPERMS
|
|
|
|
$GL_WILDREPOS_PERM_CATS $HTPASSWD_FILE $PROJECTS_LIST $REPO_BASE
|
2011-05-31 17:18:27 +02:00
|
|
|
$REPO_UMASK $RSYNC_BASE $SVNSERVE $UPDATE_CHAINS_TO $AUTH_OPTIONS
|
2011-01-17 15:06:26 +01:00
|
|
|
|
|
|
|
$GL_HTTP_ANON_USER
|
2011-01-15 16:39:56 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# real constants
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
$current_data_version = '1.7';
|
|
|
|
|
|
|
|
$ABRT = "\n\t\t***** ABORTING *****\n ";
|
|
|
|
$WARN = "\n\t\t***** WARNING *****\n ";
|
|
|
|
|
|
|
|
# commands we're expecting
|
|
|
|
$R_COMMANDS=qr/^(git[ -]upload-pack|git[ -]upload-archive)$/;
|
|
|
|
$W_COMMANDS=qr/^git[ -]receive-pack$/;
|
|
|
|
|
|
|
|
# note that REPONAME_PATT allows "/", while USERNAME_PATT does not
|
|
|
|
# also, the reason REPONAME_PATT is a superset of USERNAME_PATT is (duh!)
|
|
|
|
# because a repo can have "CREATOR" in the name
|
|
|
|
$REPONAME_PATT=qr(^\@?[0-9a-zA-Z][0-9a-zA-Z._\@/+-]*$);
|
|
|
|
$USERNAME_PATT=qr(^\@?[0-9a-zA-Z][0-9a-zA-Z._\@+-]*$);
|
|
|
|
# same as REPONAME, but used for wildcard repos, allows some common regex metas
|
|
|
|
$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._\@/+:-]*$);
|
|
|
|
|
2011-03-24 02:45:35 +01:00
|
|
|
# maximum number of output lines from info under GL_BIG_CONFIG
|
|
|
|
$BIG_INFO_CAP = 20;
|
|
|
|
|
2011-02-14 17:50:38 +01:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# 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";
|
|
|
|
|
make REPO_BASE absolute early
$ENV{GL_REPO_BASE_ABS} is meant to point to the same directory as
$REPO_BASE, except it is meant to be passed to hooks, ADCs and other
child programs. And since you can't be sure where the child program
starts in, this became an absolute path.
Gradually, however, I started using it wherever I needed an absolute
path (mostly in code that jumps around various directories to do stuff).
Which is silly, because there's no reason $REPO_BASE cannot also be made
an absolute, even if the rc file has a relative path.
So that's what I did now: made $REPO_BASE absolute very early on, and
then systematically changed all uses of the longer form to the shorter
form when appropriate. And so the only thing we now use the longer one
for is to pass to child programs.
(Implementation note: The actual change is not very big, but while I was
about it I decided to make the test suite able to test with an absolute
REPO_BASE also, which is why the commit seems so large.)
----
This all started with a complaint from Damien Regad. He had an
extremely odd setup where his bashrc changed PWD to something other than
$HOME before anything else ran. This caused those two variables to
beceom inconsistent, and he had a 1-line fix he wanted me to apply.
I generally don't like making special fixes for for non-standard setups,
and anyway all he had to do was set the full path to REPO_BASE in the rc
file to get around this. Which is what I told him and he very politely
left it at that.
However, this did get me thinking, and I soon realised I was needlessly
conflating "relative versus absolute" with "able to be passed to child
programs". Fixing that solved his problem also, as a side-effect.
So I guess this is all thanks to Damien!
2011-03-18 06:29:52 +01:00
|
|
|
# fix up REPO_BASE
|
|
|
|
$REPO_BASE = "$ENV{HOME}/$REPO_BASE" unless $REPO_BASE =~ m(^/);
|
|
|
|
|
2011-01-15 16:39:56 +01:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# per perl rules, this should be the last line in such a file:
|
|
|
|
1;
|