summaryrefslogtreecommitdiff
path: root/run
diff options
context:
space:
mode:
authorGravatar Matthias Lucas Jaros <jarlucmat@mailbox.org>2025-10-19 18:19:14 +0200
committerGravatar Matthias Lucas Jaros <jarlucmat@mailbox.org>2025-10-19 18:19:14 +0200
commit2294af355a549070544eb49638eda6b05cd61a05 (patch)
tree5a3d22211bd6e3d14f939ebc410ffc640b27f478 /run
parentd9fc214c094bdb4ae4f7a855a1cc61134a5b519e (diff)
Cleaned up file structure and script
Diffstat (limited to 'run')
-rwxr-xr-xrun14
1 files changed, 10 insertions, 4 deletions
diff --git a/run b/run
index 061b5a3..55e8b55 100755
--- a/run
+++ b/run
@@ -1,10 +1,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 USER (whoami)
-set matcher (string match -r -g "^.*'(.*)'\$" "$argv")
-cat /srv/repos/permissions | grep -q -E "^$matcher[1]:$USER"
+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 "$argv"
+/usr/bin/sudo -u git /usr/bin/git-shell -c "$gitCommand '$repoDir'"