Skip to content

Commit

Permalink
http/ftp: optionally ask curl to not use EPSV command
Browse files Browse the repository at this point in the history
If http.noEPSV config variable is defined and true, or if
GIT_CURL_FTP_NO_EPSV environment variable is defined, disable using
of EPSV ftp command (PASV will be used instead). This is helpful with
some "poor" ftp servers which does not support EPSV mode.

Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Sasha Khapyorsky authored and Junio C Hamano committed Sep 29, 2006
1 parent 77e565d commit 3ea099d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ http.lowSpeedLimit, http.lowSpeedTime::
Can be overridden by the 'GIT_HTTP_LOW_SPEED_LIMIT' and
'GIT_HTTP_LOW_SPEED_TIME' environment variables.

http.noEPSV::
A boolean which disables using of EPSV ftp command by curl.
This can helpful with some "poor" ftp servers which doesn't
support EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'
environment variable. Default is false (curl will use EPSV).

i18n.commitEncoding::
Character encoding the commit messages are stored in; git itself
does not care per se, but this information is necessary e.g. when
Expand Down
4 changes: 4 additions & 0 deletions git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ clone_dumb_http () {
cd "$2" &&
clone_tmp="$GIT_DIR/clone-tmp" &&
mkdir -p "$clone_tmp" || exit 1
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-repo-config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv"
fi
http_fetch "$1/info/refs" "$clone_tmp/refs" || {
echo >&2 "Cannot get remote repository information.
Perhaps git-update-server-info needs to be run there?"
Expand Down
6 changes: 5 additions & 1 deletion git-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ fetch_main () {
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
curl_extra_args="-k"
fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-repo-config --bool http.noEPSV`" = true ]; then
noepsv_opt="--disable-epsv"
fi
max_depth=5
depth=0
head="ref: $remote_name"
Expand All @@ -300,7 +304,7 @@ fetch_main () {
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
print "$u";
' "$head")
head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted")
head=$(curl -nsfL $curl_extra_args $noepsv_opt "$remote/$remote_name_quoted")
depth=$( expr \( $depth + 1 \) )
done
expr "z$head" : "z$_x40\$" >/dev/null ||
Expand Down
4 changes: 4 additions & 0 deletions git-ls-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ http://* | https://* | ftp://* )
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
curl_extra_args="-k"
fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
"`git-repo-config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv"
fi
curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||
echo "failed slurping"
;;
Expand Down
12 changes: 12 additions & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ char *ssl_capath = NULL;
char *ssl_cainfo = NULL;
long curl_low_speed_limit = -1;
long curl_low_speed_time = -1;
int curl_ftp_no_epsv = 0;

struct curl_slist *pragma_header;

Expand Down Expand Up @@ -155,6 +156,11 @@ static int http_options(const char *var, const char *value)
return 0;
}

if (!strcmp("http.noepsv", var)) {
curl_ftp_no_epsv = git_config_bool(var, value);
return 0;
}

/* Fall back on the default ones */
return git_default_config(var, value);
}
Expand Down Expand Up @@ -196,6 +202,9 @@ static CURL* get_curl_handle(void)

curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);

if (curl_ftp_no_epsv)
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);

return result;
}

Expand Down Expand Up @@ -251,6 +260,9 @@ void http_init(void)
max_requests = DEFAULT_MAX_REQUESTS;
#endif

if (getenv("GIT_CURL_FTP_NO_EPSV"))
curl_ftp_no_epsv = 1;

#ifndef NO_CURL_EASY_DUPHANDLE
curl_default = get_curl_handle();
#endif
Expand Down

0 comments on commit 3ea099d

Please sign in to comment.