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';
67 usage
() unless $op and exists $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') {
87 $val = join(" ", @ARGV) if @ARGV;
88 # values with spaces embedded get flattened by sshd when it passes
89 # SSH_ORIGINAL_COMMAND to gitolite. In this specific instance, we will
90 # pretend we know what the user meant, and join up the last 1+ args into
91 # one space-separated arg.
93 my $user_configs = option
( $repo, 'user-configs' );
94 # this is a space separated list of allowed config keys
95 my @validkeys = split( ' ', ( $user_configs || '' ) );
96 my @matched = grep { $key =~ /^$_$/i } @validkeys;
97 _die
"config '$key' not allowed\n" if ( @matched < 1 );
100 push @ARGV, $val if $val;
103 # ----------------------------------------------------------------------
107 usage
() unless @ARGV == $nargs{$op};
109 _chdir
("$rc{GL_REPO_BASE}/$repo.git");
110 _system
( "git", "config", @ARGV );