pax_global_header 0000666 0000000 0000000 00000000064 11716100125 0014504 g ustar 00root root 0000000 0000000 52 comment=01e789a1e168890c7df592ddf239d95e194661cd
sitaramc-gitolite-6857652/ 0000775 0000000 0000000 00000000000 11716100125 0015335 5 ustar 00root root 0000000 0000000 sitaramc-gitolite-6857652/.gitattributes 0000664 0000000 0000000 00000000214 11716100125 0020225 0 ustar 00root root 0000000 0000000 conf/* crlf=input
src/* crlf=input
hooks/common/* crlf=input
hooks/gitolite-admin/* crlf=input
sitaramc-gitolite-6857652/.gitignore 0000664 0000000 0000000 00000000054 11716100125 0017324 0 ustar 00root root 0000000 0000000 *.tar
*.tgz
*.tar.gz
*.tar.bz2
conf/VERSION
sitaramc-gitolite-6857652/Makefile 0000664 0000000 0000000 00000001144 11716100125 0016775 0 ustar 00root root 0000000 0000000 # this is a simple wrapper around "git archive" using make
# "make [refname].tar" produces a tar of refname, then adds a file containing
# the "git describe" output for that refname to the tar. This lets you say
# "cat .GITOLITE-VERSION" to find out which ref produced this tar
# Note: I'm not sure if that "-r" is a GNU tar extension...
branch := $(shell git rev-parse --abbrev-ref HEAD)
$(branch): $(branch).tar
.GITOLITE-VERSION:
@touch conf/VERSION
%.tar: .GITOLITE-VERSION
git describe --tags --long $* > conf/VERSION
git archive $* > $@
tar -r -f $@ conf/VERSION
rm conf/VERSION
cp -v $@ /tmp
sitaramc-gitolite-6857652/README.mkd 0000664 0000000 0000000 00000001510 11716100125 0016764 0 ustar 00root root 0000000 0000000 # Gitolite README
**Github users: please read the "wiki" link at the top of the page before
submitting issues or pull requests**.
If you're really impatient, and you're familiar with Unix and ssh, follow the
[quick install](http://sitaramc.github.com/gitolite/index.html#qi)
instructions.
But if you want to do anything meaningful with gitolite you have to spend some
time cuddling up to the docs. **The complete online documentation starts
[here](http://sitaramc.github.com/gitolite)** -- this is the best starting
point for general questions about git, such as what it is, why you would need
it, features, contact/mailing list info, and so on.
For convenience, here is a link to the [master table of
contents](http://sitaramc.github.com/gitolite/master-toc.html), which is very
useful to search using your browser's search function.
sitaramc-gitolite-6857652/conf/ 0000775 0000000 0000000 00000000000 11716100125 0016262 5 ustar 00root root 0000000 0000000 sitaramc-gitolite-6857652/conf/example.conf 0000664 0000000 0000000 00000000225 11716100125 0020563 0 ustar 00root root 0000000 0000000 # see doc/gitolite.conf.mkd for help on the syntax and semantics of this file
# online at http://sitaramc.github.com/gitolite/doc/gitolite.conf.html
sitaramc-gitolite-6857652/conf/example.gitolite.rc 0000664 0000000 0000000 00000010114 11716100125 0022057 0 ustar 00root root 0000000 0000000 # configuration variables for gitolite
# PLEASE READ THE DOCUMENTATION BEFORE EDITING OR ASKING QUESTIONS
# ( http://github.com/sitaramc/gitolite/blob/pu/doc/gitolite.rc.mkd )
# ( or http://sitaramc.github.com/gitolite/doc/gitolite.rc.html )
# this file is in perl syntax. However, you do NOT need to know perl to edit
# it; it should be fairly self-explanatory and easy to maintain
# ------------------------------------------------------------------------------
# DO NOT TOUCH THIS SECTION!
# ------------------------------------------------------------------------------
$GL_ADMINDIR=$ENV{HOME} . "/.gitolite";
$GL_CONF="$GL_ADMINDIR/conf/gitolite.conf";
$GL_KEYDIR="$GL_ADMINDIR/keydir";
$GL_CONF_COMPILED="$GL_ADMINDIR/conf/gitolite.conf-compiled.pm";
# DO NOT CHANGE THE NEXT FOUR LINES UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
# These variables are set automatically by the install method you choose.
# (PACKAGE MAINTAINERS: PLEASE READ doc/packaging.mkd)
# $GL_PACKAGE_CONF = "";
# $GL_PACKAGE_HOOKS = "";
# ------------------------------------------------------------------------------
# most often used/changed variables
# ------------------------------------------------------------------------------
$GL_WILDREPOS = 0;
$PROJECTS_LIST = $ENV{HOME} . "/projects.list";
# $WEB_INTERFACE = "gitweb";
# $GITWEB_URI_ESCAPE = 0;
$REPO_UMASK = 0077;
# ------------------------------------------------------------------------------
# variables with an efficiency/performance impact
# ------------------------------------------------------------------------------
$GL_BIG_CONFIG = 0;
$GL_NO_DAEMON_NO_GITWEB = 0;
# $GL_NICE_VALUE = 0;
# $BIG_INFO_CAP = 20;
# ------------------------------------------------------------------------------
# VARIABLES WITH A SECURITY IMPACT. READ DOCS BEFORE CHANGING THESE!
# http://github.com/sitaramc/gitolite/blob/pu/doc/gitolite.rc.mkd#_variables_with_a_security_impact
# (or http://sitaramc.github.com/gitolite/doc/gitolite.rc.html#_variables_with_a_security_impact)
# ------------------------------------------------------------------------------
# $GL_ALL_READ_ALL = 0;
$GIT_PATH="";
$GL_GITCONFIG_KEYS = "";
$GL_NO_CREATE_REPOS = 0;
$GL_NO_SETUP_AUTHKEYS = 0;
# $GL_WILDREPOS_DEFPERMS = 'R @all';
$HTPASSWD_FILE = "";
$RSYNC_BASE = "";
$SVNSERVE = "";
# $UPDATE_CHAINS_TO = "hooks/update.secondary";
# $ADMIN_POST_UPDATE_CHAINS_TO = "hooks/post-update.secondary";
# $GL_ADC_PATH = "";
# $GL_GET_MEMBERSHIPS_PGM = "/usr/local/bin/expand-ldap-user-to-groups"
# $GL_HTTP_ANON_USER = "mob";
# $GL_REF_OR_FILENAME_PATT=qr(^[0-9a-zA-Z][0-9a-zA-Z._\@/+ :,-]*$);
# ------------------------------------------------------------------------------
# less used/changed variables
# ------------------------------------------------------------------------------
# $GL_ALL_INCLUDES_SPECIAL = 0;
# $GL_SLAVE_MODE = 0;
# $ENV{GL_SLAVES} = 'gitolite@server2 gitolite@server3';
# PLEASE USE SINGLE QUOTES ABOVE, NOT DOUBLE QUOTES
$GL_WILDREPOS_PERM_CATS = "READERS WRITERS";
# $GL_SITE_INFO = "XYZ.COM DEVELOPERS: PLEASE SEE http://xyz.com/gitolite/help first";
# $GL_HOSTNAME = "frodo"; # read doc/mirroring.mkd COMPLETELY before setting this
# ------------------------------------------------------------------------------
# rarely changed variables
# ------------------------------------------------------------------------------
$GL_LOGT="$GL_ADMINDIR/logs/gitolite-%y-%m.log";
# $GL_PERFLOGT="$GL_ADMINDIR/logs/perf-gitolite-%y-%m.log";
# ------------------------------------------------------------------------------
# variables that should NOT be changed after the install step completes
# ------------------------------------------------------------------------------
$REPO_BASE="repositories";
# ------------------------------------------------------------------------------
# DO NOT TOUCH ANY THING AFTER THIS LINE
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# per perl rules, this should be the last line in such a file:
1;
# Local variables:
# mode: perl
# End:
# vim: set syn=perl:
sitaramc-gitolite-6857652/contrib/ 0000775 0000000 0000000 00000000000 11716100125 0016775 5 ustar 00root root 0000000 0000000 sitaramc-gitolite-6857652/contrib/adc/ 0000775 0000000 0000000 00000000000 11716100125 0017524 5 ustar 00root root 0000000 0000000 sitaramc-gitolite-6857652/contrib/adc/README-adc.mkd 0000664 0000000 0000000 00000004300 11716100125 0021700 0 ustar 00root root 0000000 0000000 # F=shipped_ADCs brief descriptions of the shipped ADCs (admin-defined commands)
(...with pointers to further information where needed)
----
**able**: enable/disable push access temporarily (such as for taking backups
or other admin chores); details [here][able]. This ADC is meant only for
admins.
**delete-branch**: allow someone to delete a branch that they themselves
created. (i.e., when the user had RWC, but not RWCD, permissions). Details on
this ADC are [here][dbsha]; details on RWC/RWD/RWCD etc are [here][rwcd].
[dbsha]: https://github.com/sitaramc/gitolite/commit/89b68bf5ca99508caaa768c60ce910d7e0a29ccf
**fork**: Think of it as a server-side clone; details [here][fork].
**get-rights-and-owner.in-perl**: Most of the ADCs are in shell, so this is a
sample of how to write an ADC in perl.
**git-annex-shell**: allows git-annex to store and retrieve annexed file content in
repositories. To use, install in `$GL_ADC_PATH/ua/git-annex-shell`
**gl-reflog**: show a fake "reflog" from the server, and allow recovery from
deleted branches and bad force pushes; details in source.
**help**: not all shipped ADCs may be enabled by the site admin. Conversely
the admin may create and install his own ADCs that dont ship with gitolite
itself. This ADC displays site-local help, if the site admin enabled it.
**hub**: allow "pull requests" a la github; details [here][hub].
**rm**, **lock**, and **unlock**:
**trash**, **list-trash**, and **restore**:
> two families of repo deletion commands; details [here][wild_repodel]
**sudo**: allow admin to run ADCs on behalf of a user. Useful in support
situations I guess. Details in source.
Note: the Unix "sudo" and "su" programs are most often used to acquire
*higher* privileges, although they're actually designed to go the other way
also. In gitolite we do not do the former, only the latter (i.e., a normal
gitolite user cannot do admin-stuff using this ADC).
**su-expand**, **su-getperms**, **su-setperms**: as above, but for the
internal commands 'expand', 'getperms', and 'setperms'. (These commands are
not ADCs so you cannot simply use the 'sudo' ADC described above).
**who-pushed**: find the last person to push a given commit; details in
source.
sitaramc-gitolite-6857652/contrib/adc/able 0000775 0000000 0000000 00000002250 11716100125 0020354 0 ustar 00root root 0000000 0000000 #!/bin/sh
. $(dirname $0)/adc.common-functions
is_admin || die "just *what* are you trying to pull, young man?"
op=$1
shift
locs=
while [ -n "$1" ]
do
case $1 in
'@all' )
locs="$locs $HOME"
;;
* )
loc="$GL_REPO_BASE_ABS/$1.git"
[ -d $loc ] && locs="$locs $GL_REPO_BASE_ABS/$1.git"
[ -d $loc ] || echo "ignoring $1..."
;;
esac
shift
done
[ -z "$locs" ] && die "give me '@all' or some reponame"
case $op in
en|enable )
for l in $locs
do
rm -fv $l/.gitolite.down
done
;;
dis|disable )
TEMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
export TEMPDIR
trap "/bin/rm -rf $TEMPDIR" 0
echo 'type the message to be shown to users when they try to push; end with Ctrl-D:'
echo > $TEMPDIR/msg
cat >> $TEMPDIR/msg
echo disabling following locations with message:
cat $TEMPDIR/msg
echo
for l in $locs
do
cat $TEMPDIR/msg > $l/.gitolite.down
echo $l
done
;;
* )
die "argument 1 must be 'en' or 'dis'"
;;
esac
sitaramc-gitolite-6857652/contrib/adc/adc.common-functions 0000664 0000000 0000000 00000007447 11716100125 0023507 0 ustar 00root root 0000000 0000000 #!/bin/sh
# please make sure this file is NOT chmod +x
# this file contains settings for all ADCs at the top, then functions that you
# can call from shell scripts. Other files in this directory have examples.
# all uses require you to "source" this file, like so:
# # at the top of your ADC
# . $(dirname $0)/adc.common-functions
# then you use one of the following functions, like so:
# can_create reponame || die "you can't create reponame"
# can_write reponame || die "you can't write reponame"
# can_read reponame || die "you can't read reponame"
# is_admin || die "you're not an admin"
# IMPORTANT NOTE: all the can_* functions set $repo to the normalised reponame
# (i.e., with '.git' extension removed if it was supplied).
# ------------------------------------------------------------------------------
# settings for various ADCs, collected in one place for ease of keeping local
# settings intact during upgrades (you only have to worry about this file
# now). Documentation for the variables, however, is in the respective ADC
# settings for 'rm' ADC
ARE_YOU_SURE=1
USE_LOCK_UNLOCK=1
# settings for 'trash' ADC
TRASH_CAN=$GL_REPO_BASE_ABS/deleted
TRASH_SUFFIX=`date +%Y-%m-%d_%H:%M:%S`
# settings for 'hub' ADC
BASE_FETCH_URL="git://gl.example.com"
GL_FORKED_FROM="gl-forked-from"
# KDE may set this to kde-cloned-from for historical reasons
# Change to 1 to make -list the default action for the 'help' command
HELP_LIST_DEFAULT=0
# name of "admin" group (see is_admin() below before uncommenting)
# ADMIN_GROUPNAME=admins
# ------------------------------------------------------------------------------
die() { echo "$@"; exit 1; }
# test an option value more concisely
opt() {
[ "$1" = "1" ] && return 0
return 1
}
valid_owned_repo() {
# check that an arg passed is a valid repo and the current user owns it
[ -z "$1" ] && die need a repo name
get_rights_and_owner $1
[ "$owner" = "$GL_USER" ] || die "$repo does not exist or is not yours!"
# and we sneak this in too, quietly :)
cd $GL_REPO_BASE_ABS
}
# NOTE: this also sets $repo to the normalised (without .git suffix) reponame
get_rights_and_owner() {
local ans
repo=${1%.git}
ans=$(perl -I$GL_BINDIR -Mgitolite -e "cli_repo_rights('"$repo"')")
# set shell variables as needed
owner=${ans#* }
rights=${ans% *}
echo $rights | grep C >/dev/null 2>&1 && perm_create=yes || perm_create=
echo $rights | grep R >/dev/null 2>&1 && perm_read=yes || perm_read=
echo $rights | grep W >/dev/null 2>&1 && perm_write=yes || perm_write=
}
can_create() {
get_rights_and_owner ${1%.git}
[ -z "$perm_create" ] && return 1
return 0
}
can_write() {
get_rights_and_owner ${1%.git}
[ -z "$perm_write" ] && return 1
return 0
}
can_read() {
get_rights_and_owner ${1%.git}
[ -z "$perm_read" ] && return 1
return 0
}
# ------------------------------------------------------------------------------
# check if current user is an admin
is_admin() {
# there are two ways to check if someone is an admin. The default (if
# ADMIN_GROUPNAME is not defined) is to check if they have write access to
# the admin repo
if [ -z "$ADMIN_GROUPNAME" ]
then
can_write gitolite-admin || return 1
return 0
fi
# the alternative way is to check membership in $ADMIN_GROUPNAME; please
# remember this method requires GL_BIG_CONFIG to be set
# TODO, pending the code to allow an external query of a user's "group"
# affiliations
in_group $ADMIN_GROUPNAME
}
# ------------------------------------------------------------------------------
grouplist() {
perl -I$GL_BINDIR -Mgitolite -e "cli_grouplist()"
}
in_group() {
local g=$1
grouplist | egrep "(^| )$g( |$)" >/dev/null && return 0
return 1
}
sitaramc-gitolite-6857652/contrib/adc/delete-branch 0000775 0000000 0000000 00000006046 11716100125 0022155 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use strict;
use warnings;
# allow a user to delete a ref if the last create of the ref was done by the
# same user, *and* it was done within a certain time limie
# change this to suit your needs
my $oldest = 60*60*24*7; # in seconds
# use a generic error message to avoid information leak
my $error = "didn't find repo/ref, or the ref is too old, or you did not create it\n";
# ----
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
unshift @INC, $ENV{GL_BINDIR};
require gitolite or die "parse gitolite.pm failed\n";
gitolite->import;
# arg check
die "need two arguments, a reponame and a refname\n" unless @ARGV == 2;
# get the repo name
my $repo = shift;
$repo =~ s/\.git$//;
# get the ref name to be deleted, and allow the same convenience shortcut
# (prefix "refs/heads/" if it doesn't start with "refs/") as in the main
# config file
my $ref = shift;
$ref =~ m(^refs/) or $ref =~ s(^)(refs/heads/);
# XXX WARNING: we do not do any access control checking -- we just go by the
# fact that if *you* created a branch within the last $limit seconds (default
# value is 1 week), you are allowed to delete the branch.
# find the earliest log entry we're willing to look at
my $limit = `date -d '$oldest seconds ago' '+%F.%T'`;
# NOTE: this is the format that gitolite uses in its log entries (see sub
# 'get_logfilename in one of the pm files). The logic also depends on the
# fact that this is sortable, because we read backwards and stop when we
# reach something older than $limit
chomp($limit);
# find the last 2 log files; here also we depend on the fact that the file
# *names* are time ordered when sorted
my ($lf1, $lf2) = reverse sort glob("$ENV{GL_ADMINDIR}/logs/gitolite*log");
my $found = 0;
my($ts, $user, $ip, $cmd, $op, $oldsha, $newsha, $logrepo, $logref, $refrule);
for my $lf ($lf1, $lf2) {
next unless $lf;
open(LF, "-|", "tac", $lf) or die "tac $lf failed: $!\n";
while () {
($ts, $user, $ip, $cmd, $op, $oldsha, $newsha, $logrepo, $logref, $refrule) = split /\t/;
next unless $refrule;
if ($ts le $limit) {
# we don't look at entries earlier than this
$found = -1;
last;
}
if ($op eq 'C' and $oldsha =~ /^0+$/ and $logrepo eq $repo and $logref eq $ref) {
# creation record found; no need to look at any more entries
$found = 1;
last;
}
}
last if $found;
}
# check user in creation record to make sure it is the same one
if ($found == 1 and $user eq $ENV{GL_USER}) {
chdir("$ENV{GL_REPO_BASE_ABS}/$repo.git") or die "chdir $ENV{GL_REPO_BASE_ABS}/$repo.git failed: $!\n";
system("git", "update-ref", "-d", $ref, $newsha) and die "ref deletion failed\n";
warn "deleted $ref from $repo (created on $ts)\n";
# NOTE: we use warn so this gets into the log in some way; perhaps
# later we can adjust the format to more closely resemble a normal
# remote delete operation
exit 0;
}
print STDERR $error;
exit 1;
sitaramc-gitolite-6857652/contrib/adc/fork 0000775 0000000 0000000 00000002060 11716100125 0020411 0 ustar 00root root 0000000 0000000 #!/bin/sh
. $(dirname $0)/adc.common-functions
[ -z "$GL_RC" ] && die "ENV GL_RC not set"
[ -z "$2" ] && die "Usage: fork source_repo target_repo"
# all the can_* functions set $repo
can_read $1 || die "no read permissions on $repo"
from=$repo
can_create $2 || die "no create permissions on $repo"
to=$repo
# clone $from to $to
git clone --bare -l $GL_REPO_BASE_ABS/$from.git $GL_REPO_BASE_ABS/$to.git
[ $? -ne 0 ] && exit 1
echo "$from forked to $to"
# fix up creator, gitweb owner, and hooks
cd $GL_REPO_BASE_ABS/$to.git
echo $GL_USER > gl-creater
git config gitweb.owner "$GL_USER"
( $GL_BINDIR/gl-query-rc GL_WILDREPOS_DEFPERMS ) |
SSH_ORIGINAL_COMMAND="setperms $to" $GL_BINDIR/gl-auth-command $GL_USER
cp -R $GL_REPO_BASE_ABS/$from.git/hooks/* $GL_REPO_BASE_ABS/$to.git/hooks
if [ -n "$GL_WILDREPOS_DEFPERMS" ]; then
echo "$GL_WILDREPOS_DEFPERMS" > gl-perms
fi
echo "$from" > gl-forked-from
# run gitolite's post-init hook if you can (hook code expects GL_REPO to be set)
export GL_REPO; GL_REPO="$to"
[ -x hooks/gl-post-init ] && hooks/gl-post-init
sitaramc-gitolite-6857652/contrib/adc/get-rights-and-owner.in-perl 0000775 0000000 0000000 00000003405 11716100125 0024766 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use strict;
use warnings;
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
unshift @INC, $ENV{GL_BINDIR};
require gitolite or die "parse gitolite.pm failed\n";
gitolite->import;
# get the repo name
my $repo = shift;
$repo =~ s/\.git$//;
# IMPORTANT NOTE: to do any of this inside a hook, you should just use
# $ENV{GL_REPO}, since it's guaranteed to be set to the right value
# to do a "level 1" check (repo level -- not branch level), do this:
my ($perm, $creator) = check_access($repo);
# you can pass in any repo name you wish instead of the active repo
# the first return value looks like one of these, so you can just check for
# the presence of "R" or "W" and be done:
# _____R___W_
# _____R_____
# ___________
# The second value is "" for a normal repo, an actual username for
# a wildrepo, or "" for a non-existent repo.
# to do a "level 2" check (branches), do something like this
my $ret = check_access($repo, 'refs/heads/foo', 'W', 1);
# the 2nd argument must be a *full* refname (i.e., not "master", but
# "refs/heads/master"). The 3rd argument is one of W, +, C, or D. The 4th
# argument should be any non-false perl value, like 1.
# the return value may look like this:
# refs/.*
# or perhaps this, if you were denied
# DENIED by fallthru
# NOTE: do NOT pass "R" as the 3rd argument. It will seem to work because
# you're merely testing the permissions in this code, but an *actual* "git
# fetch" for even a DENIED ref will succeed if the user has read access to at
# least one branch. This is because the information on what ref is being read
# is not made available externally in any useful way (the way the "update"
# hook gets its arguments when a push happens).
sitaramc-gitolite-6857652/contrib/adc/getdesc 0000664 0000000 0000000 00000001042 11716100125 0021062 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
use strict;
use warnings;
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
unshift @INC, $ENV{GL_BINDIR};
require gitolite or die "parse gitolite.pm failed\n";
gitolite->import;
my $repo = shift;
die "need a reponame\n" unless $repo;
my $ret = check_access($repo, 'refs/heads/master', '+', 1);
die "sorry you don't have rights to do this\n" if $ret =~ /DENIED/;
wrap_chdir($ENV{GL_REPO_BASE_ABS});
wrap_chdir("$repo.git");
print slurp("description") if -f "description";
sitaramc-gitolite-6857652/contrib/adc/git 0000775 0000000 0000000 00000010525 11716100125 0020240 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
# READ ALL INSTRUCTIONS **AND** SOURCE CODE BEFORE DEPLOYING.
# run arbitrary git commands on the server
# ----
# WARNING: HIGHLY INFLAMMABLE. FISSILE MATERIAL, RADIATION HAZARD. HANDLE
# WITH CARE. DO NOT REMOVE MANUFACTURER LABEL. NOT TO BE USED WHILE DRIVING
# OR UNDER THE INFLUENCE OF ALCOHOL. PATIENTS WITH HEART PROBLEMS MUST SEE
# THEIR CARDIOLOGIST BEFORE USING.
# ----
# ok, warnings done, here's the saner description.
#
# This ADC lets you run arbirtrary git commands on any repo on the server.
# The first argument will be the repo name, the second and subsequent
# arguments will be the rest of the git command. For example, to run `git
# describe --tags` on repo `foo`, you would run:
#
# ssh git@server git foo describe --tags
#
# If that looks weird to you, you can use
#
# ssh git@server git --repo=foo describe --tags
#
# (the position remains the same: between 'git' and '')
# SECURITY AND SAFETY NOTES:
#
# - ADC arguments are checked (in `sub try_adc`) to fit `ADC_CMD_ARGS_PATT`
# and the only special characters allowed by that pattern are ".", "_", "@",
# "/", "+", ":", and "-". Thus, *this* adc does not check arguments
# anymore. ANY RISK IN THIS LAXITY IS YOURS, NOT MINE, although I believe
# it is safe enough.
#
# - Most commands don't make sense to allow, even among those that do not
# require a work-tree. Avoid commands that can be done using normal git
# remote access (ls-remote, clone, archive, push, etc). Also, avoid
# commands that *write* to the repo if possible, or at least think/test
# thoroughly before enabling them.
#
# - You have to deal with issues like stdin/out, output files created etc.,
# which is another reason to avoid most of the more complex commands.
#
# - Do not enable prune, gc, etc., if your repos are on NFS/CIFS/etc. See
# http://permalink.gmane.org/gmane.comp.version-control.git/122670 for why.
#
# - The list of commands allowed to be executed, and the permissions required
# to do so, are defined here. Feel free to uncomment any of this to make
# things more relaxed. If you add new ones, note that the permissions can
# only be 'R', 'W', or 'A'. The meanings of R and W are obvious; "A" means
# the user must have write access to the *gitolite-admin* repo to run this
# command -- yeah that's a nice twist innit? ;-)
my %GIT_COMMANDS = (
# annotate => 'R',
# blame => 'R',
'count-objects' => 'R',
describe => 'R',
# diff => 'R',
# 'fast-export' => 'R',
# grep => 'R',
# log => 'R',
# shortlog => 'R',
# 'show-branch' => 'R',
# show => 'R',
# whatchanged => 'R',
# config => 'A', # I strongly discourage un-commenting this
# fsck => 'W', # write access required
# gc => 'W', # write access required
# prune => 'A', # admin access required
# repack => 'A', # admin access required
);
# preliminary stuff; indented just to visually get it out of the way
use strict;
use warnings;
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
unshift @INC, $ENV{GL_BINDIR};
require gitolite or die "parse gitolite.pm failed\n";
gitolite->import;
my $no_help = "this command is too dangerous to just show a help message; we don't want anyone\nrunning it without reading the source and understanding the implications!\n";
# get the repo name
my $repo = shift or die $no_help;
$repo =~ s/^--repo=//;
$repo =~ s/\.git$//;
# get the command
my $cmd = shift or die $no_help;
# is it a valid command at all?
exists $GIT_COMMANDS{$cmd} or die "invalid git command\n";
# check access
my $aa = $GIT_COMMANDS{$cmd}; # aa == attempted access
if ($aa eq 'A') {
my ($perm, $creator) = check_access('gitolite-admin');
$perm =~ /W/ or die "no admin access\n";
} else {
my ($perm, $creator) = check_access($repo);
$perm =~ /$aa/ or die "no $aa access to $repo\n";
}
# cd to the repo dir
chdir("$ENV{GL_REPO_BASE_ABS}/$repo.git") or die "chdir failed: $!\n";
# remove or comment the below line to signify you have read and understood all this
die $no_help;
# now run the git command... fingers crossed
unshift @ARGV, "git", $cmd;
print STDERR "+ ", join(" ", @ARGV), "\n";
exec @ARGV;
sitaramc-gitolite-6857652/contrib/adc/git-annex-shell 0000775 0000000 0000000 00000004061 11716100125 0022452 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
# This ADC requires unrestricted arguments, so you need to
# install it into $GL_ADC_PATH/ua/git-annex-shell, instead of
# directly into $GL_ADC_PATH/
#
# This requires git-annex version 20111016 or newer. Older versions won't
# be secure.
use strict;
use warnings;
# pull in modules we need
BEGIN {
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
unshift @INC, $ENV{GL_BINDIR};
}
use gitolite_rc;
use gitolite;
# ignore @ARGV and look at the original unmodified command
my $cmd=$ENV{SSH_ORIGINAL_COMMAND};
# Expect commands like:
# git-annex-shell 'configlist' '/~/repo'
# git-annex-shell 'sendkey' '/~/repo' 'key'
# The parameters are always single quoted, and the repo path is always
# the second parameter.
# Further parameters are not validated here (see below).
die "bad git-annex-shell command: $cmd"
unless $cmd =~ m#^(git-annex-shell '\w+' ')/\~/([0-9a-zA-Z][0-9a-zA-Z._\@/+-]*)('( .*|))$#;
my $start = $1;
my $repo = $2;
my $end = $3;
die "I dont like some of the characters in $repo\n" unless $repo =~ $REPONAME_PATT;
die "I dont like absolute paths in $cmd\n" if $repo =~ /^\//;
die "I dont like '..' paths in $cmd\n" if $repo =~ /\.\./;
# Modify $cmd, fixing up the path to the repo to include REPO_BASE.
my $newcmd="$start$REPO_BASE/$repo$end";
# Rather than keeping track of which git-annex-shell commands
# require write access and which are readonly, we tell it
# when readonly access is needed.
my ($perm, $creator) = check_access($repo);
if ($perm =~ /W/) {
}
elsif ($perm =~ /R/) {
$ENV{GIT_ANNEX_SHELL_READONLY}=1;
}
else {
die "$perm $repo $ENV{GL_USER} DENIED\n";
}
# Further limit git-annex-shell to safe commands (avoid it passing
# unknown commands on to git-shell)
$ENV{GIT_ANNEX_SHELL_LIMITED}=1;
# Note that $newcmd does *not* get evaluated by the unix shell.
# Instead it is passed as a single parameter to git-annex-shell for
# it to parse and handle the command. This is why we do not need to
# fully validate $cmd above.
log_it();
exec "git-annex-shell", "-c", $newcmd;
sitaramc-gitolite-6857652/contrib/adc/gl-reflog 0000775 0000000 0000000 00000006122 11716100125 0021331 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
die "ENV GL_RC not set\n" unless $ENV{GL_RC};
die "ENV GL_BINDIR not set\n" unless $ENV{GL_BINDIR};
# - show fake "reflog" from gitolite server
# - recover deleted branches
# - recover from bad force pushes
# --------------------
# WARNING
# - heavily dependent on the gitolite log file format (duh!)
# - cannot recover if some other commits were made after the force push
sub usage {
print STDERR <<'EOF';
USAGE
ssh git@server gl-reflog show r1 refs/heads/b1
# shows last 10 updates to branch b1 in repo r1
ssh git@server gl-reflog show r1 refs/heads/b1 20
# shows last 20 entries...
ssh git@server gl-reflog recover r1 refs/heads/b1
# recovers the last update to b1 in r1 if it was a "+"
EOF
exit 1;
}
usage unless (@ARGV >= 3);
# NOTES
# - the verb "recover" is used because this is expected to be used most often
# to recover deleted branches. Plus there's enough confusion in git land
# caused by "reset" and "revert" I thought I should add my bit to it ;-)
# - git's internal reflog is NOT recovered, even if you recover the branch.
# I'm good but not *that* good ;-)
# - since this program produces a log entry that satisfies it's own criteria,
# it acts as a "toggle" for its own action for rewinds (but not for deletes)
my($cmd, $repo, $ref, $limit) = @ARGV;
$limit ||= 10;
unshift @INC, $ENV{GL_BINDIR};
require gitolite or die "parse gitolite.pm failed\n";
gitolite->import;
my ($perm, $creator) = check_access($repo);
die "you don't have read access to $repo\n" unless $perm =~ /R/;
my @logfiles = sort glob("$ENV{GL_ADMINDIR}/logs/*");
# TODO figure out how to avoid reading *all* the log files when you really
# only need the last few
our @loglines;
{
my @f;
local(@ARGV) = @logfiles;
while (<>) {
chomp;
@f = split /\t/;
# field 2 is the userid, 5 is W or +, 6/7 are old/new SHAs
# 8 is reponame, 9 is refname (but all those are 1-based)
next unless $f[3] =~ /^(git-receive-pack|gl-reflog recover) /;
next unless $f[8];
next unless $f[7] eq $repo;
next unless $f[8] eq $ref;
push @loglines, $_;
}
}
if ( $cmd eq 'show' ) {
my $start = @loglines - $limit;
$start = 0 if $start < 0;
map { print "$loglines[$_]\n" } $start .. $#loglines;
exit 0;
}
if ( $cmd eq 'recover' ) {
my @f = split /\t/, $loglines[$#loglines];
die "the last push was not yours\n" unless $f[1] eq $ENV{GL_USER};
die "the last push was not a rewind or delete\n" unless $f[4] eq '+';
my($oldsha, $newsha) = @f[5,6];
if ($newsha =~ /^0+$/) {
print "recovering $repo $ref at $oldsha (was deleted)\n";
} else {
print "recovering $repo $ref at $oldsha (was forced to $newsha)\n";
}
chdir("$ENV{GL_REPO_BASE_ABS}/$repo.git");
my $newsha2 = $newsha;
$newsha2 = '' if $newsha =~ /^0+$/;
system("git", "update-ref", $ref, $oldsha, $newsha2) and
die "repo $repo, update-ref $ref $oldsha $newsha failed...\n";
log_it("", "+\t$newsha\t$oldsha\t$repo\t$ref");
}
sitaramc-gitolite-6857652/contrib/adc/help 0000775 0000000 0000000 00000003505 11716100125 0020405 0 ustar 00root root 0000000 0000000 #!/bin/sh
. $(dirname $0)/adc.common-functions
# the help adc now takes some options; we need to process them first
[ "$1" = "-list" -o "$HELP_LIST_DEFAULT" = "1" ] && {
# the GL_ADC_PATH directory has files other than ADCs also, notably the
# include file for shell ADCs, and maybe a README or two. Those should be
# chmod -x.
# if you want to temporarily hide any ADC from being listed, do the same
# thing: chmod -x
cd $($GL_BINDIR/gl-query-rc GL_ADC_PATH)
for i in *
do
[ -x $i ] && echo $i
done
exit 0
}
# the local site can have a file called gl-adc-help.txt, which will be used as
# the *entire* help text for this site...
[ -f $HOME/gl-adc-help.txt ] && {
cat $HOME/gl-adc-help.txt
exit 0
}
# or the local site will use the default help text in this file, with an
# optional pre- and post- text that is site local (like maybe the admin's
# contact details)
# pre
[ -f $HOME/gl-adc-pre-help.txt ] && cat $HOME/gl-adc-pre-help.txt
# default help text
cat <