1
package Gitolite::Triggers::Kindergarten;
3
# http://www.great-quotes.com/quote/424177
4
# "Doctor, it hurts when I do this."
5
# "Then don't do that!"
7
# Prevent various things that sensible people shouldn't be doing anyway. List
8
# of things it prevents is at the end of the program.
10
# If you were forced to enable this module because someone is *constantly*
11
# doing things that need to be caught, consider getting rid of that person.
12
# Because, really, who knows what *else* he/she is doing that can't be caught
13
# with some clever bit of code?
23
# in rc, you either see just 'Kindergarten' to activate all features, or
24
# 'Kindergarten U0 CREATOR' (i.e., a space sep list of features after the
25
# word Kindergarten) to activate only those named features.
27
# no features specifically activated; implies all of them are active
28
return 1 if not %active;
29
# else check if this specific feature is active
30
return 1 if $active{ +shift };
35
my ( $verb, $repo, $cmd, $args );
37
# get the features to be activated, if supplied
38
while ( $_[0] ne 'INPUT' ) {
39
$active{ +shift } = 1;
42
# generally fill up variables you might use later
43
my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
44
if ( $ENV{SSH_ORIGINAL_COMMAND} =~ /($git_commands) '\/?(\S+)'$/ ) {
47
} elsif ( $ENV{SSH_ORIGINAL_COMMAND} =~ /^(\S+) (.*)$/ ) {
52
prevent_CREATOR($repo) if active('CREATOR') and $verb;
53
prevent_0(@ARGV) if active('U0') and @ARGV;
58
_die "'CREATOR' not allowed as part of reponame" if $repo =~ /\bCREATOR\b/;
63
_die "'0' is not a valid username" if $user eq '0';
72
prevent literal 'CREATOR' from being part of a repo name
74
a quirk deep inside gitolite would let this config
79
allow the creation of repos like "foo/CREATOR/bar", i.e., the word CREATOR is
82
I consider this a totally pathological situation to check for. The worst that
83
can happen is someone ends up cluttering the server with useless repos.
85
One solution could be to prevent this only for wild repos, but I can't be
86
bothered to fine tune this, so this module prevents even normal repos from
87
having the literal CREATOR in them.
89
See https://groups.google.com/forum/#!topic/gitolite/cS34Vxix0Us for more.
93
prevent a user from being called literal '0'
95
Ideally we should prevent keydir/0.pub (or variants) from being created,
96
but for "Then don't do that" purposes it's enough to prevent the user from
99
See https://groups.google.com/forum/#!topic/gitolite/F1IBenuSTZo for more.