From 9d9355a379f8a9922645ecd87b66f68acbb6bc89 Mon Sep 17 00:00:00 2001 From: Matthias Lucas Jaros Date: Mon, 20 Oct 2025 10:20:42 +0200 Subject: Moved files to src and renamed variables --- src/run | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 src/run (limited to 'src/run') diff --git a/src/run b/src/run new file mode 100755 index 0000000..a1ae7d5 --- /dev/null +++ b/src/run @@ -0,0 +1,25 @@ +#!/usr/bin/env fish + +set REPO_PERMISSIONS_FILE /etc/repo-permissions +# unify repo regex somehow +set GIT_VALIDATION_REGEX "^(git-(?:upload-pack|receive-pack|upload-archive)) '((?:\/[a-zA-Z-]+)+.git)'\$" + +# check given git command +set -l matcher (string match -r -g $GIT_VALIDATION_REGEX "$argv") +if test (count $matcher) -ne 2 + # there should be two groups otherwise something is wrong + exit 1 +end + +# echo check for permissions +set -l checkUser (whoami) +set -l gitCommand $matcher[1] +set -l repo $matcher[2] +# adjust repo path to /srv/repos +set -l repoDir srv repos +set -l repoDir /(string join -n '/' $repoDir (string split '/' $repo)) +cat $REPO_PERMISSIONS_FILE | grep -q -E "^$repoDir:$checkUser\$" +or exit 1; + +# execute parsed git command +/usr/bin/sudo -u git /usr/bin/git-shell -c "$gitCommand '$repoDir'" -- cgit v1.3.1