6 # If your site makes a distinction between "right to push the admin repo" and
7 # "right to run arbitrary commands on the server" (i.e., if not all of your
8 # "admins" have shell access to the server), this is a security risk. If that
9 # is the case, DO NOT ENABLE THIS COMMAND.
11 # ----------------------------------------------------------------------
12 # gitolite command to allow "git config" on repos (with some restrictions)
14 # (Not to be confused with the 'git-config' command, which is used only in
15 # server-side scripts, not remotely.)
18 # 1. Enable the command by adding it to the COMMANDS section in the ENABLE
19 # list in the rc file. (Have you read the warning above?)
21 # 2. Specify configs allowed to be changed by the user. This is a space
22 # separated regex list. For example:
25 # ... (various rules) ...
26 # option user-configs = hook\..* foo.bar[0-9].*
31 use lib
$ENV{GL_LIBDIR
};
35 # ----------------------------------------------------------------------
39 Usage: ssh git@host config <repo> [git config options]
41 Runs "git config" in the repo. Only the following 3 syntaxes are supported
42 (see 'man git-config'):
49 Your administrator should tell you what keys are allowed for the "name".
52 # ----------------------------------------------------------------------
62 usage
() if not @ARGV or $ARGV[0] eq '-h';
66 my ($op, $key, $val) = @ARGV;
67 usage
() unless $op and exists $nargs{$op} and @ARGV == $nargs{$op};
69 # ----------------------------------------------------------------------
70 # authorisation checks
72 die "sorry, you are not authorised\n" unless
75 ( ( $op eq '--get-all' or $op eq '--list' )
77 : ( can_write
($repo) and option
( $repo, 'writer-is-owner' ) )
80 # ----------------------------------------------------------------------
83 unless ($op eq '--list') {
84 my $user_configs = option
( $repo, 'user-configs' );
85 # this is a space separated list of allowed config keys
86 my @validkeys = split( ' ', ( $user_configs || '' ) );
87 my @matched = grep { $key =~ /^$_$/i } @validkeys;
88 _die
"config '$key' not allowed\n" if ( @matched < 1 );
91 # ----------------------------------------------------------------------
94 _chdir
("$rc{GL_REPO_BASE}/$repo.git");
95 _system
( "git", "config", @ARGV );