http/ftp: optionally ask curl to not use EPSV command
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>
Sasha Khapyorsky committed
Sep 29, 2006 at 03:10 UTC
3ea099d48b15f69889f4efe71599c9dfde6bb26a
5 files changed
+31
-1
Documentation/config.txt
+6
@@ -202,6 +202,12 @@ http.lowSpeedLimit, http.lowSpeedTime::
202
Can be overridden by the 'GIT_HTTP_LOW_SPEED_LIMIT' and
203
'GIT_HTTP_LOW_SPEED_TIME' environment variables.
204
205
+http.noEPSV::
206
+ A boolean which disables using of EPSV ftp command by curl.
207
+ This can helpful with some "poor" ftp servers which doesn't
208
+ support EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'
209
+ environment variable. Default is false (curl will use EPSV).
210
+
211
i18n.commitEncoding::
212
Character encoding the commit messages are stored in; git itself
213
does not care per se, but this information is necessary e.g. when
git-clone.sh
+4
@@ -31,6 +31,10 @@ clone_dumb_http () {
31
cd "$2" &&
32
clone_tmp="$GIT_DIR/clone-tmp" &&
33
mkdir -p "$clone_tmp" || exit 1
34
+ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
35
+ "`git-repo-config --bool http.noEPSV`" = true ]; then
36
+ curl_extra_args="${curl_extra_args} --disable-epsv"
37
+ fi
38
http_fetch "$1/info/refs" "$clone_tmp/refs" || {
39
echo >&2 "Cannot get remote repository information.
40
Perhaps git-update-server-info needs to be run there?"
git-fetch.sh
+5
-1
@@ -289,6 +289,10 @@ fetch_main () {
289
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
290
curl_extra_args="-k"
291
fi
292
+ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
293
+ "`git-repo-config --bool http.noEPSV`" = true ]; then
294
+ noepsv_opt="--disable-epsv"
295
+ fi
296
max_depth=5
297
depth=0
298
head="ref: $remote_name"
@@ -300,7 +304,7 @@ fetch_main () {
304
$u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
305
print "$u";
306
' "$head")
303
- head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted")
307
+ head=$(curl -nsfL $curl_extra_args $noepsv_opt "$remote/$remote_name_quoted")
308
depth=$( expr \( $depth + 1 \) )
309
done
310
expr "z$head" : "z$_x40\$" >/dev/null ||
git-ls-remote.sh
+4
@@ -53,6 +53,10 @@ http://* | https://* | ftp://* )
53
if [ -n "$GIT_SSL_NO_VERIFY" ]; then
54
curl_extra_args="-k"
55
fi
56
+ if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
57
+ "`git-repo-config --bool http.noEPSV`" = true ]; then
58
+ curl_extra_args="${curl_extra_args} --disable-epsv"
59
+ fi
60
curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||
61
echo "failed slurping"
62
;;
http.c
+12
@@ -23,6 +23,7 @@ char *ssl_capath = NULL;
23
char *ssl_cainfo = NULL;
24
long curl_low_speed_limit = -1;
25
long curl_low_speed_time = -1;
26
+int curl_ftp_no_epsv = 0;
27
28
struct curl_slist *pragma_header;
29
@@ -155,6 +156,11 @@ static int http_options(const char *var, const char *value)
156
return 0;
157
}
158
159
+ if (!strcmp("http.noepsv", var)) {
160
+ curl_ftp_no_epsv = git_config_bool(var, value);
161
+ return 0;
162
+ }
163
+
164
/* Fall back on the default ones */
165
return git_default_config(var, value);
166
}
@@ -196,6 +202,9 @@ static CURL* get_curl_handle(void)
202
203
curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);
204
205
+ if (curl_ftp_no_epsv)
206
+ curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
207
+
208
return result;
209
}
210
@@ -251,6 +260,9 @@ void http_init(void)
260
max_requests = DEFAULT_MAX_REQUESTS;
261
#endif
262
263
+ if (getenv("GIT_CURL_FTP_NO_EPSV"))
264
+ curl_ftp_no_epsv = 1;
265
+
266
#ifndef NO_CURL_EASY_DUPHANDLE
267
curl_default = get_curl_handle();
268
#endif