From: Kyle J. McKay Date: Sat, 12 Apr 2014 04:32:46 +0000 (-0700) Subject: config: make the leading $jailreporoot/ prefix optional on ssh: URLs X-Git-Url: https://repo.or.cz/w/girocco.git/commitdiff_plain/6b124b797a453decd731af6bcdeacaadeb458a42 config: make the leading $jailreporoot/ prefix optional on ssh: URLs Automatically add the $jailreporoot prefix for clients connecting over the ssh protocol. The prefix is still allowed if given, but it makes for a cleaner user experience without it. --- diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 9ece320..c62ac92 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -276,6 +276,9 @@ our $httpspushurl = undef; our $gitpullurl = "git://repo.or.cz"; # Pushy SSH URL of the repository collection (undef if N/A) +# Note that the "/$jailreporoot" portion is optional and will be automatically +# added if appropriate when omitted by the client so this URL can typically +# be made the same as $gitpullurl with git: replaced with ssh: our $pushurl = "ssh://repo.or.cz/$jailreporoot"; # URL of gitweb of this Girocco instance (set to undef if you're not nice diff --git a/bin/git-shell-verify b/bin/git-shell-verify index df8c6ed..72c4df8 100755 --- a/bin/git-shell-verify +++ b/bin/git-shell-verify @@ -20,15 +20,17 @@ webadmurl=@webadmurl@ # Only the following commands are allowed: # -# git-shell -c 'git-receive-pack dir' -# git-shell -c 'git receive-pack dir' -# git-shell -c 'git-upload-pack dir' -# git-shell -c 'git upload-pack dir' -# git-shell -c 'git-upload-archive dir' -# git-shell -c 'git upload-archive dir' +# git-shell -c "git-receive-pack 'dir'" +# git-shell -c "git receive-pack 'dir'" +# git-shell -c "git-upload-pack 'dir'" +# git-shell -c "git upload-pack 'dir'" +# git-shell -c "git-upload-archive 'dir'" +# git-shell -c "git upload-archive 'dir'" # # where dir must start with $reporoot/ but a leading/trailing '/' is optional -# as well as the final .git +# as well as the final .git however if $dir does not start with $reporoot but +# adding a $reporoot prefix makes it work then the $reporoot prefix will be +# silently added. if [ "$1" != "-c" ]; then echo forbidden >&2 @@ -95,8 +97,13 @@ esac case "$dir" in "$reporoot/"*) :;; *) - echo forbidden >&2 - exit 1 + # Allow it if prefixing with $reporoot matches an existing directory + if [ -d "$reporoot$dir" ]; then + dir="$reporoot$dir" + else + echo forbidden >&2 + exit 1 + fi esac if ! [ -d "$dir" ] || ! [ -f "$dir/HEAD" ] || ! [ -d "$dir/objects" ]; then @@ -129,5 +136,5 @@ if ! [ -x /usr/bin/perl ] && [ "$type" = 'receive-pack' ]; then fi fi -exec git-shell "$@" +exec git-shell -c "git-$type '$dir'" exit 1