blob: 55e8b551646ff3c8ca3be8fc612091019f8be09d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/usr/bin/env fish
set REPO_PERMISSIONS /etc/repo-permissions
set GIT_COMMAND_REGEX "^(git-(?:upload-pack|receive-pack|upload-archive)) '((?:\/[a-zA-Z-]+)+.git)'\$"
# echo check for permissions
set -l checkUser (whoami)
set -l matcher (string match -r -g $GIT_COMMAND_REGEX "$argv")
set -l gitCommand $matcher[1]
set -l repo $matcher[2]
set -l repoDir srv repos
set -l repoDir /(string join -n '/' $repoDir (string split '/' $repo))
cat $REPO_PERMISSIONS | grep -q -E "^$repoDir:$checkUser"
or exit 1;
# run command
/usr/bin/sudo -u git /usr/bin/git-shell -c "$gitCommand '$repoDir'"
|