Is it possible to modify git config options for wild respos without manually editing the gitolite.conf file?

merlin2011

Suppose I have pushed to and configured the wild repo foo/bar.

If I want to add a mailing list option to this repo, one way is to add the following to my gitolite.conf file.

repo foo/ba[r]
    config hooks.mailinglist = [email protected]

However, this requires that I have access to the gitolite.conf which is part of gitolite-admin repository.

Is there any way an ordinary user could make this modification, without access to the admin configuration file?

Note that I have already perused the documentation to no avail.

merlin2011

I got the following answer from the gitolite mailing list. However, this answer does not handle wild cards in GIT_CONFIG_KEYS, so I modified it to handle this the same way gitolite does.

It sufficed the insert the following inside commands/config and then add config to the list of enabled options in .gitolite.rc.

#!/bin/bash

# Usage:    ssh git@host config <repo> --get <name>
#           ssh git@host config <repo> --set <name> <value>
#           ssh git@host config <repo> --unset <name>
#
# Set a "git config" option on a repo. You must be an owner of the
# repo, and the config option name must be allowed by the gitolite.rc
# configuration.

die() { echo "$@" >&2; exit 1; }
usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
[ -z "$1" ] && usage
[ "$1" = "-h" ] && usage
[ -z "$GL_USER" ] && die GL_USER not set

repo="$1"; shift

gitolite owns "$repo" || die "repository '$repo' missing or you do not own it"
cd `gitolite query-rc GL_REPO_BASE`/"$repo".git || die "missing repository '$1'";

case $1 in
--get)  action='--get'
        shift
        [ "$#" -eq 1 ] || usage
        ;;
--set)  action='--set'
        shift
        [ "$#" -gt 1 ] || usage
        ;;
--unset)
        action='--unset'
        shift
        [ "$#" -eq 1 ] || usage
        ;;
*)      if [ "$#" -eq 1 ]
        then action='--get'
        else action='--set'
        fi
        ;;
esac

name="$1"; shift

ALLOWED_CONFIG=$(gitolite query-rc GIT_CONFIG_KEYS)

export ALLOWED_CONFIG                                             
export name                                                       

deny=$(perl -e '                                                  
     my @validkeys = split( " ", ( $ENV{ALLOWED_CONFIG} || "" ) );
     my @matched = grep { $ENV{name} =~ /^$_$/i } @validkeys;     
     if (@matched < 1) {print "Denied\n";}')                      

if [[ -n "$deny" ]]; then                                         
        die "config option '$name' not allowed by gitolite.rc"    
        exit 1                                                    
fi 



# there is not much need to sanitise the input; by default all
# arguments to commands are restricted to these: -0-9a-zA-Z._\@/+ :,\%=
# (see Gitolite::Rc.pm, the variable is $REMOTE_COMMAND_PATT) however
# for safety we will check the value for consistency with $UNSAFE_PATT

UNSAFE_PATT='.*[`~#\$\&()|;<>]'

case $action in
--set)  if expr "$*" : "$UNSAFE_PATT" >/dev/null
        then
                die "value '$*' contains unsafe characters"
        else
                git config "$name" "$*"
        fi
        ;;
*)      git config $action "$name"
        ;;
esac

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Gitolite: manually compile the conf file?

From Dev

Modify git config file globally

From Dev

netplan: usage by command line (without manually editing this annoying yaml file)?

From Dev

How can I edit a Deployment without modify the file manually?

From Dev

GVIM : Possible to begin editing the file without having to press "i"?

From Dev

Modify keyboard config file

From Dev

modify KMail config file

From Dev

Modify keyboard config file

From Dev

chkrootkit config file options

From Dev

Editing nsswitch.conf file safely

From Dev

List wild repos I have access to with gitolite

From Dev

How to change QtCurve style/theme without KDE via config file editing?

From Dev

How to prevent remote branch deletion in git without using gitolite

From Dev

How to prevent remote branch deletion in git without using gitolite

From Dev

modify and apply limits.conf without reboot

From Dev

Is it possible to move .tmux.conf to ~/.config folder?

From Dev

Is it possible to define a mesh with User-Elements and specify their properties with Python in Abaqus/CAE without editing the input file?

From Dev

Modify config file during release

From Dev

Configure a trackball under Linux without editing Xorg.conf

From Dev

Editing config file via a bash script

From Dev

Editing a config file in linux using sed command

From Dev

Is it possible to prevent users to modify printer options in CUPS?

From Dev

Is it possible to prevent users to modify printer options in CUPS?

From Dev

how to parse a config file (*.conf) in shell script?

From Dev

Scala Config: Include another file.conf

From Dev

Is it possible to reload lvm.conf without reboot?

From Dev

Is it possible to git without master?

From Dev

Ubuntu 14.04 Nvidia Configuration file Location for editing refresh rate manually

From Dev

Is it possible to modify an xml file in Terminal?

Related Related

  1. 1

    Gitolite: manually compile the conf file?

  2. 2

    Modify git config file globally

  3. 3

    netplan: usage by command line (without manually editing this annoying yaml file)?

  4. 4

    How can I edit a Deployment without modify the file manually?

  5. 5

    GVIM : Possible to begin editing the file without having to press "i"?

  6. 6

    Modify keyboard config file

  7. 7

    modify KMail config file

  8. 8

    Modify keyboard config file

  9. 9

    chkrootkit config file options

  10. 10

    Editing nsswitch.conf file safely

  11. 11

    List wild repos I have access to with gitolite

  12. 12

    How to change QtCurve style/theme without KDE via config file editing?

  13. 13

    How to prevent remote branch deletion in git without using gitolite

  14. 14

    How to prevent remote branch deletion in git without using gitolite

  15. 15

    modify and apply limits.conf without reboot

  16. 16

    Is it possible to move .tmux.conf to ~/.config folder?

  17. 17

    Is it possible to define a mesh with User-Elements and specify their properties with Python in Abaqus/CAE without editing the input file?

  18. 18

    Modify config file during release

  19. 19

    Configure a trackball under Linux without editing Xorg.conf

  20. 20

    Editing config file via a bash script

  21. 21

    Editing a config file in linux using sed command

  22. 22

    Is it possible to prevent users to modify printer options in CUPS?

  23. 23

    Is it possible to prevent users to modify printer options in CUPS?

  24. 24

    how to parse a config file (*.conf) in shell script?

  25. 25

    Scala Config: Include another file.conf

  26. 26

    Is it possible to reload lvm.conf without reboot?

  27. 27

    Is it possible to git without master?

  28. 28

    Ubuntu 14.04 Nvidia Configuration file Location for editing refresh rate manually

  29. 29

    Is it possible to modify an xml file in Terminal?

HotTag

Archive