From 54907ac1b769c24cce818d84cba66fd134b8197f Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 6 Feb 2018 05:44:07 -0800 Subject: [PATCH] hooks: adopt v_get_proj_from_dir Adopt the v_get_proj_from_dir function as the means to translate a directory into a Girocco project. Obviously this requires the presence of the shlib.sh script which is not available in the chroot jail. When running in the chroot jail retain the previous logic which, while not quite as robust, generally suffices quite will for the more simple chroot jail setup. Signed-off-by: Kyle J. McKay --- hooks/post-receive | 11 ++++++----- hooks/update | 8 ++++---- jobd/generate-auto-gc-update.sh | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hooks/post-receive b/hooks/post-receive index d25a499..59f397c 100755 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -45,15 +45,13 @@ if [ "$mob" = "mob" ] && [ -d mob ]; then fi sockpath=/etc/taskd.socket -reporoot=/@jailreporoot@ authuser="$LOGNAME" -cwd="$(pwd -P)" if [ -x @perlbin@ ]; then # Not in chroot... . @basedir@/shlib.sh sockpath="$cfg_chroot$sockpath" - reporoot="$cfg_reporoot" + v_get_proj_from_dir projname # authuser needs to be set if not running in the chroot. # Currently that can only be the case with https push in @@ -65,10 +63,13 @@ if [ -x @perlbin@ ]; then [ -n "$authuser" ] || authuser="%$cfg_mirror_user%" else # In chroot... + reporoot=/@jailreporoot@ + reporoot="$(cd "$reporoot" && pwd -P)" + cwd="$(pwd -P)" + projname="${cwd#$reporoot/}" + nc_openbsd() { /bin/nc.openbsd "$@"; } fi -reporoot="$(cd "$reporoot" && pwd -P)" -projname="${cwd#$reporoot/}" if [ "${autogchack:-0}" != "0" ] && diff --git a/hooks/update b/hooks/update index f46f92a..ad6cbb1 100755 --- a/hooks/update +++ b/hooks/update @@ -124,11 +124,12 @@ fi # We are NOT inside the chroot . @basedir@/shlib.sh -reporoot="$(cd "$cfg_reporoot" && pwd -P)" +reporoot="$cfg_reporoot" +v_get_proj_from_dir proj +projbare="${proj%.git}" if [ "$cfg_permission_control" = "Hooks" ]; then # We have some permission control to do! - proj="$(pwd -P)"; proj="${proj#$reporoot/}"; projbare="${proj%.git}" # XXX: Sanity check on project name and $USER here? Seems superfluous. if ! "$cfg_basedir/bin/can_user_push_http" "$projbare" "$USER"; then echo "The user '$USER' does not have push permissions for project '$proj'" >&2 @@ -140,13 +141,12 @@ fi if [ -n "$GIT_PROJECT_ROOT" ]; then # We are doing a smart HTTP push - proj="$(pwd -P)"; proj="${proj#$reporoot/}" mobdir= case "$proj" in *?/mob) mobdir=1 proj="${proj%/mob}" + projbare="${proj%.git}" esac - projbare="${proj%.git}" if ! [ -f "$reporoot/$proj/.nofetch" ]; then echo "The $proj project is a mirror and may not be pushed to, sorry" >&2 diff --git a/jobd/generate-auto-gc-update.sh b/jobd/generate-auto-gc-update.sh index 1ac6d27..b6685c3 100755 --- a/jobd/generate-auto-gc-update.sh +++ b/jobd/generate-auto-gc-update.sh @@ -59,8 +59,7 @@ generate_auto_gc_update() { loghhmmss="${loghhmmss%??????}" logname="reflogs/$lognamets.$$" lognametmp="reflogs/tmp_$lognamets.$$" - reporoot="$(cd "$cfg_reporoot" && pwd -P)" - proj="$(pwd -P)" && proj="${proj#$reporoot/}" && proj="${proj%.git}" + v_get_proj_from_dir proj && proj="${proj%.git}" { echo "ref-changes %@local% $proj" LC_ALL=C join .refs-last .refs-new.$$ | -- 2.11.4.GIT