From b9053929c38caef7860aeeb29befad10beb7b855 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 3 Feb 2015 12:24:19 -0800 Subject: [PATCH] git-svn: use an 'anonsvn' username and 'anonsvn' password For sites that require a password but support anonymous fetching a username of 'anonsvn' and a password of 'anonsvn' is commonly used. So instead of supplying nothing, use anonsvn and anonsvn. More sites will work and by explicitly always supplying a username no user name from the system itself will ever be sent. --- jobd/update.sh | 13 +++++++++---- taskd/clone.sh | 15 ++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/jobd/update.sh b/jobd/update.sh index c78ae40..9f57d81 100755 --- a/jobd/update.sh +++ b/jobd/update.sh @@ -109,6 +109,10 @@ bang_eval "LC_ALL=C sort -k1b,1 <.refs-temp >.refs-before" case "$url" in svn://* | svn+http://* | svn+https://*) [ -n "$cfg_mirror_svn" ] || { echo "Mirroring svn is disabled" >&2; exit 0; } + # Use an 'anonsvn' username as is commonly used for anonymous svn + # Use an 'anonsvn' password as is commonly used for anonymous svn + GIT_ASKPASS_PASSWORD=anonsvn + export GIT_ASKPASS_PASSWORD # Update the git svn url to match baseurl but be cognizant of any # needed prefix changes. See the comments in taskd/clone.sh about # why we need to put up with a prefix in the first place. @@ -124,15 +128,15 @@ case "$url" in # We require svn info to succeed on the URL otherwise it's # simply not a valid URL and without using -s on the init it # will not otherwise be tested until the fetch - bang eval 'svn --non-interactive info "$svnurl" > /dev/null' + bang eval 'svn --non-interactive --username anonsvn --password anonsvn info "$svnurl" > /dev/null' bang mkdir svn-new-url GIT_DIR=svn-new-url bang git init --bare --quiet # We initially use -s for the init which will possibly shorten # the URL. However, the shortening can fail if a password is # not required for the longer version but is for the shorter, # so try again without -s if the -s version fails. - cmdstr='git svn init --prefix "" -s "$svnurl" < /dev/null > /dev/null 2>&1 || ' - cmdstr="$cmdstr"'git svn init --prefix "" "$svnurl" < /dev/null > /dev/null 2>&1' + cmdstr='git svn init --username=anonsvn --prefix "" -s "$svnurl" < /dev/null > /dev/null 2>&1 || ' + cmdstr="$cmdstr"'git svn init --username=anonsvn --prefix "" "$svnurl" < /dev/null > /dev/null 2>&1' GIT_DIR=svn-new-url bang eval "$cmdstr" gitsvnurl="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.url || :)" gitsvnfetch="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.fetch || :)" @@ -169,7 +173,7 @@ case "$url" in # remove any stale *.lock files greater than 1 hour old in case # git-svn was killed on the last update because it took too long find svn -type f -name '*.lock' -mmin +60 -print0 2>/dev/null | xargs -0 rm -f - GIT_DIR=. bang git svn fetch --quiet < /dev/null + GIT_DIR=. bang git svn fetch --username=anonsvn --quiet < /dev/null # git svn does not preserve group permissions in the svn subdirectory chmod -R ug+rw,o+r svn # git svn also leaves behind ref turds that end with @nnn @@ -184,6 +188,7 @@ case "$url" in git update-ref -d "$ref" esac done; } + unset GIT_ASKPASS_PASSWORD ;; darcs://*) [ -n "$cfg_mirror_darcs" ] || { echo "Mirroring darcs is disabled" >&2; exit 0; } diff --git a/taskd/clone.sh b/taskd/clone.sh index 3e75d27..8e83205 100755 --- a/taskd/clone.sh +++ b/taskd/clone.sh @@ -143,18 +143,22 @@ case "$url" in git config --remove-section svn-remote.svn 2>/dev/null || : # Remove any left-over svn dir from a previous failed attempt rm -rf svn + # Use an 'anonsvn' username as is commonly used for anonymous svn + # Use an 'anonsvn' password as is commonly used for anonymous svn + GIT_ASKPASS_PASSWORD=anonsvn + export GIT_ASKPASS_PASSWORD # We require svn info to succeed on the URL otherwise it's # simply not a valid URL and without using -s on the init it # will not otherwise be tested until the fetch - svn --non-interactive info "$svnurl" > /dev/null + svn --non-interactive --username anonsvn --password anonsvn info "$svnurl" > /dev/null # We initially use -s for the init which will possibly shorten # the URL. However, the shortening can fail if a password is # not required for the longer version but is for the shorter, # so try again without -s if the -s version fails. # We must use GIT_DIR=. here or ever so "helpful" git-svn will # create a .git subdirectory! - GIT_DIR=. git svn init --prefix "" -s "$svnurl" < /dev/null || \ - GIT_DIR=. git svn init --prefix "" "$svnurl" < /dev/null + GIT_DIR=. git svn init --username=anonsvn --prefix "" -s "$svnurl" < /dev/null || \ + GIT_DIR=. git svn init --username=anonsvn --prefix "" "$svnurl" < /dev/null # We need to remember this url so we can detect changes because # ever so "helpful" git-svn may shorten it! config_set svnurl "$svnurl" @@ -182,7 +186,7 @@ case "$url" in # check for standard layout at the same time foundstd= foundfile= - { svn --non-interactive ls "$gitsvnurl/${gitsvnprefix}" 2>/dev/null || :; } | \ + { svn --non-interactive --username anonsvn --password anonsvn ls "$gitsvnurl/${gitsvnprefix}" 2>/dev/null || :; } | \ { while read file; do case $file in # skip the already-handled standard ones and any with a space or tab *' '*|*' '*) :;; @@ -199,7 +203,7 @@ case "$url" in git config --replace-all svn-remote.svn.fetch ':refs/heads/master' fi; } # Again, be careful to use GIT_DIR=. here or else new .git subdirectory! - GIT_DIR=. git svn fetch --quiet < /dev/null + GIT_DIR=. git svn fetch --username=anonsvn --quiet < /dev/null # git svn does not preserve group permissions in the svn subdirectory chmod -R ug+rw,o+r svn # git svn also leaves behind ref turds that end with @nnn @@ -214,6 +218,7 @@ case "$url" in git update-ref -d "$ref" esac done; } + unset GIT_ASKPASS_PASSWORD ;; darcs://*) [ -n "$cfg_mirror_darcs" ] || { echo "Mirroring darcs is disabled" >&2; exit 1; } -- 2.11.4.GIT