From afbab1dd8d981dc3c71b8054e868f1efb9af8029 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Wed, 6 Oct 2010 20:32:48 +0530 Subject: [PATCH] "sudo" adc The sudo adc should make life easier for any admin wishing to run an adc as some other user. As a result, the rmrepo adc also goes back to its simple roots. Now you just run it via the sudo adc if you (as gitolite admin) needs to rmrepo some user's repo. --- contrib/adc/rmrepo | 11 ----------- contrib/adc/sudo | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100755 contrib/adc/sudo diff --git a/contrib/adc/rmrepo b/contrib/adc/rmrepo index 21b70e2..d18a612 100755 --- a/contrib/adc/rmrepo +++ b/contrib/adc/rmrepo @@ -6,19 +6,8 @@ delete=$1 get_rights_and_owner $delete -# please choose one alternative and delete the other para - -# alternative 1 -- only creator can delete [ "$owner" = "$GL_USER" ] || die "$delete is not yours to delete!" -# alternative 2 -- creator or anyone with W access to admin repo can delete -[ "$owner" = "$GL_USER" ] || { - # but only if it is wild - [ "$owner" = "" ] && die "$delete is not a wild repo" - get_rights_and_owner gitolite-admin - [ -z "$perm_write" ] && die "$delete is not yours to delete and you're not the admin" -} - cd $GL_REPO_BASE_ABS rm -rf $delete.git diff --git a/contrib/adc/sudo b/contrib/adc/sudo new file mode 100755 index 0000000..818db75 --- /dev/null +++ b/contrib/adc/sudo @@ -0,0 +1,23 @@ +#!/bin/sh + +# this command is pretty cool, even if I may say so myself :) + +# for any ADC that a normal user can run, like + +# ssh git@server adc arguments + +# this adc lets a "super user" (defined as "have write access to the +# gitolite-admin repo"), do this + +# ssh git@server sudo normal_user adc arguments + +. $(dirname $0)/adc.common-functions + +get_rights_and_owner gitolite-admin +[ -z "$perm_write" ] && die "just *what* are you trying to pull, young man?" + +user="$1"; shift +cmd="$1"; shift + +GL_USER=$user; export GL_USER +exec $(dirname $0)/$cmd "$@"