mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 12:05:06 -05:00
TFTP: add option to suppress TFTP option requests (Part 2)
- Add tests. - Add an example to CURLOPT_TFTP_NO_OPTIONS.3. - Add --tftp-no-options to expose CURLOPT_TFTP_NO_OPTIONS. Bug: https://github.com/curl/curl/issues/481
This commit is contained in:
parent
9dc3eaee29
commit
186546f1c5
@ -1730,6 +1730,14 @@ default 512 bytes will be used.
|
|||||||
If this option is used several times, the last one will be used.
|
If this option is used several times, the last one will be used.
|
||||||
|
|
||||||
(Added in 7.20.0)
|
(Added in 7.20.0)
|
||||||
|
.IP "--tftp-no-options"
|
||||||
|
(TFTP) Tells curl not to send TFTP options requests.
|
||||||
|
|
||||||
|
This option improves interop with some legacy servers that do not acknowledge
|
||||||
|
or properly implement TFTP options. When this option is used
|
||||||
|
\fI--tftp-blksize\fP is ignored.
|
||||||
|
|
||||||
|
(Added in 7.48.0)
|
||||||
.IP "--tlsauthtype <authtype>"
|
.IP "--tlsauthtype <authtype>"
|
||||||
Set TLS authentication type. Currently, the only supported option is "SRP",
|
Set TLS authentication type. Currently, the only supported option is "SRP",
|
||||||
for TLS-SRP (RFC 5054). If \fI--tlsuser\fP and \fI--tlspassword\fP are
|
for TLS-SRP (RFC 5054). If \fI--tlsuser\fP and \fI--tlspassword\fP are
|
||||||
|
@ -315,7 +315,7 @@ Authentication address. See \fICURLOPT_MAIL_AUTH(3)\fP
|
|||||||
.IP CURLOPT_TFTP_BLKSIZE
|
.IP CURLOPT_TFTP_BLKSIZE
|
||||||
TFTP block size. See \fICURLOPT_TFTP_BLKSIZE(3)\fP
|
TFTP block size. See \fICURLOPT_TFTP_BLKSIZE(3)\fP
|
||||||
.IP CURLOPT_TFTP_NO_OPTIONS
|
.IP CURLOPT_TFTP_NO_OPTIONS
|
||||||
Prevents TFTP options to be send with RRQs/WRQs. See \fICURLOPT_TFTP_NO_OPTIONS(3)\fP
|
Do not send TFTP options requests. See \fICURLOPT_TFTP_NO_OPTIONS(3)\fP
|
||||||
.SH FTP OPTIONS
|
.SH FTP OPTIONS
|
||||||
.IP CURLOPT_FTPPORT
|
.IP CURLOPT_FTPPORT
|
||||||
Use active FTP. See \fICURLOPT_FTPPORT(3)\fP
|
Use active FTP. See \fICURLOPT_FTPPORT(3)\fP
|
||||||
|
@ -20,24 +20,51 @@
|
|||||||
.\" *
|
.\" *
|
||||||
.\" **************************************************************************
|
.\" **************************************************************************
|
||||||
.\"
|
.\"
|
||||||
.TH CURLOPT_TFTP_NO_OPTIONS 3 "19 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
|
.TH CURLOPT_TFTP_NO_OPTIONS 3 "23 Feb 2016" "libcurl 7.48.0" "curl_easy_setopt options"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
CURLOPT_TFTP_NO_OPTIONS \- Prevents TFTP options to be send with RRQs/WRQs
|
CURLOPT_TFTP_NO_OPTIONS \- Do not send TFTP options requests.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_NO_OPTIONS, long sendoptions);
|
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TFTP_NO_OPTIONS, long onoff);
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Set \fIsendoptions\fP to 1 to exclude all TFTP options defined in RFC2347,
|
Set \fIonoff\fP to 1L to exclude all TFTP options defined in RFC2347, RFC2348
|
||||||
RFC2348, RFC2349 from read and write requests.
|
and RFC2349 from read and write requests (RRQs/WRQs).
|
||||||
libcurl will behave like a client implementing only RFC1350, ignoring any
|
|
||||||
protocol extensions.
|
This option improves interop with some legacy servers that do not acknowledge
|
||||||
|
or properly implement TFTP options. When this option is used
|
||||||
|
\fICURLOPT_TFTP_BLKSIZE(3)\fP is ignored.
|
||||||
.SH DEFAULT
|
.SH DEFAULT
|
||||||
0
|
0
|
||||||
.SH PROTOCOLS
|
.SH PROTOCOLS
|
||||||
TFTP
|
TFTP
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
TODO
|
.nf
|
||||||
|
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *fp)
|
||||||
|
{
|
||||||
|
return fwrite(ptr, size, nmemb, (FILE *)fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
if(curl) {
|
||||||
|
FILE *fp = fopen("foo.bin", "wb");
|
||||||
|
if(fp) {
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)fp);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "tftp://example.com/foo.bin");
|
||||||
|
|
||||||
|
/* do not send TFTP options requests */
|
||||||
|
curl_easy_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
|
||||||
|
|
||||||
|
/* Perform the request */
|
||||||
|
curl_easy_perform(curl);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
.fi
|
||||||
.SH AVAILABILITY
|
.SH AVAILABILITY
|
||||||
Added in 7.48.0
|
Added in 7.48.0
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
|
@ -97,11 +97,12 @@ man_MANS = CURLOPT_ACCEPT_ENCODING.3 CURLOPT_ACCEPTTIMEOUT_MS.3 \
|
|||||||
CURLOPT_SSL_VERIFYPEER.3 CURLOPT_SSL_VERIFYSTATUS.3 \
|
CURLOPT_SSL_VERIFYPEER.3 CURLOPT_SSL_VERIFYSTATUS.3 \
|
||||||
CURLOPT_SSLVERSION.3 CURLOPT_STDERR.3 CURLOPT_TCP_KEEPALIVE.3 \
|
CURLOPT_SSLVERSION.3 CURLOPT_STDERR.3 CURLOPT_TCP_KEEPALIVE.3 \
|
||||||
CURLOPT_TCP_KEEPIDLE.3 CURLOPT_TCP_KEEPINTVL.3 CURLOPT_TCP_NODELAY.3 \
|
CURLOPT_TCP_KEEPIDLE.3 CURLOPT_TCP_KEEPINTVL.3 CURLOPT_TCP_NODELAY.3 \
|
||||||
CURLOPT_TELNETOPTIONS.3 CURLOPT_TFTP_BLKSIZE.3 CURLOPT_TIMECONDITION.3 \
|
CURLOPT_TELNETOPTIONS.3 CURLOPT_TFTP_BLKSIZE.3 \
|
||||||
CURLOPT_TIMEOUT.3 CURLOPT_TIMEOUT_MS.3 CURLOPT_TIMEVALUE.3 \
|
CURLOPT_TFTP_NO_OPTIONS.3 CURLOPT_TIMECONDITION.3 CURLOPT_TIMEOUT.3 \
|
||||||
CURLOPT_TLSAUTH_PASSWORD.3 CURLOPT_TLSAUTH_TYPE.3 \
|
CURLOPT_TIMEOUT_MS.3 CURLOPT_TIMEVALUE.3 CURLOPT_TLSAUTH_PASSWORD.3 \
|
||||||
CURLOPT_TLSAUTH_USERNAME.3 CURLOPT_TRANSFER_ENCODING.3 \
|
CURLOPT_TLSAUTH_TYPE.3 CURLOPT_TLSAUTH_USERNAME.3 \
|
||||||
CURLOPT_TRANSFERTEXT.3 CURLOPT_UNRESTRICTED_AUTH.3 CURLOPT_UPLOAD.3 \
|
CURLOPT_TRANSFER_ENCODING.3 CURLOPT_TRANSFERTEXT.3 \
|
||||||
|
CURLOPT_UNRESTRICTED_AUTH.3 CURLOPT_UPLOAD.3 \
|
||||||
CURLOPT_URL.3 CURLOPT_USERAGENT.3 CURLOPT_USERNAME.3 CURLOPT_USERPWD.3 \
|
CURLOPT_URL.3 CURLOPT_USERAGENT.3 CURLOPT_USERNAME.3 CURLOPT_USERPWD.3 \
|
||||||
CURLOPT_USE_SSL.3 CURLOPT_VERBOSE.3 CURLOPT_WILDCARDMATCH.3 \
|
CURLOPT_USE_SSL.3 CURLOPT_VERBOSE.3 CURLOPT_WILDCARDMATCH.3 \
|
||||||
CURLOPT_WRITEDATA.3 CURLOPT_WRITEFUNCTION.3 CURLOPT_XFERINFODATA.3 \
|
CURLOPT_WRITEDATA.3 CURLOPT_WRITEFUNCTION.3 CURLOPT_XFERINFODATA.3 \
|
||||||
@ -224,8 +225,9 @@ HTMLPAGES = CURLOPT_ACCEPT_ENCODING.html CURLOPT_ACCEPTTIMEOUT_MS.html \
|
|||||||
CURLOPT_SSLVERSION.html CURLOPT_STDERR.html CURLOPT_TCP_KEEPALIVE.html \
|
CURLOPT_SSLVERSION.html CURLOPT_STDERR.html CURLOPT_TCP_KEEPALIVE.html \
|
||||||
CURLOPT_TCP_KEEPIDLE.html CURLOPT_TCP_KEEPINTVL.html \
|
CURLOPT_TCP_KEEPIDLE.html CURLOPT_TCP_KEEPINTVL.html \
|
||||||
CURLOPT_TCP_NODELAY.html CURLOPT_TELNETOPTIONS.html \
|
CURLOPT_TCP_NODELAY.html CURLOPT_TELNETOPTIONS.html \
|
||||||
CURLOPT_TFTP_BLKSIZE.html CURLOPT_TIMECONDITION.html \
|
CURLOPT_TFTP_BLKSIZE.html CURLOPT_TFTP_NO_OPTIONS.html \
|
||||||
CURLOPT_TIMEOUT.html CURLOPT_TIMEOUT_MS.html CURLOPT_TIMEVALUE.html \
|
CURLOPT_TIMECONDITION.html CURLOPT_TIMEOUT.html \
|
||||||
|
CURLOPT_TIMEOUT_MS.html CURLOPT_TIMEVALUE.html \
|
||||||
CURLOPT_TLSAUTH_PASSWORD.html CURLOPT_TLSAUTH_TYPE.html \
|
CURLOPT_TLSAUTH_PASSWORD.html CURLOPT_TLSAUTH_TYPE.html \
|
||||||
CURLOPT_TLSAUTH_USERNAME.html CURLOPT_TRANSFER_ENCODING.html \
|
CURLOPT_TLSAUTH_USERNAME.html CURLOPT_TRANSFER_ENCODING.html \
|
||||||
CURLOPT_TRANSFERTEXT.html CURLOPT_UNRESTRICTED_AUTH.html \
|
CURLOPT_TRANSFERTEXT.html CURLOPT_UNRESTRICTED_AUTH.html \
|
||||||
@ -354,7 +356,8 @@ PDFPAGES = CURLOPT_ACCEPT_ENCODING.pdf CURLOPT_ACCEPTTIMEOUT_MS.pdf \
|
|||||||
CURLOPT_SSLVERSION.pdf CURLOPT_STDERR.pdf CURLOPT_TCP_KEEPALIVE.pdf \
|
CURLOPT_SSLVERSION.pdf CURLOPT_STDERR.pdf CURLOPT_TCP_KEEPALIVE.pdf \
|
||||||
CURLOPT_TCP_KEEPIDLE.pdf CURLOPT_TCP_KEEPINTVL.pdf \
|
CURLOPT_TCP_KEEPIDLE.pdf CURLOPT_TCP_KEEPINTVL.pdf \
|
||||||
CURLOPT_TCP_NODELAY.pdf CURLOPT_TELNETOPTIONS.pdf \
|
CURLOPT_TCP_NODELAY.pdf CURLOPT_TELNETOPTIONS.pdf \
|
||||||
CURLOPT_TFTP_BLKSIZE.pdf CURLOPT_TIMECONDITION.pdf CURLOPT_TIMEOUT.pdf \
|
CURLOPT_TFTP_BLKSIZE.pdf CURLOPT_TFTP_NO_OPTIONS.pdf \
|
||||||
|
CURLOPT_TIMECONDITION.pdf CURLOPT_TIMEOUT.pdf \
|
||||||
CURLOPT_TIMEOUT_MS.pdf CURLOPT_TIMEVALUE.pdf \
|
CURLOPT_TIMEOUT_MS.pdf CURLOPT_TIMEVALUE.pdf \
|
||||||
CURLOPT_TLSAUTH_PASSWORD.pdf CURLOPT_TLSAUTH_TYPE.pdf \
|
CURLOPT_TLSAUTH_PASSWORD.pdf CURLOPT_TLSAUTH_TYPE.pdf \
|
||||||
CURLOPT_TLSAUTH_USERNAME.pdf CURLOPT_TRANSFER_ENCODING.pdf \
|
CURLOPT_TLSAUTH_USERNAME.pdf CURLOPT_TRANSFER_ENCODING.pdf \
|
||||||
|
@ -978,7 +978,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we don't keep TFTP connections up bascially because there's none or very
|
/* we don't keep TFTP connections up basically because there's none or very
|
||||||
* little gain for UDP */
|
* little gain for UDP */
|
||||||
connclose(conn, "TFTP");
|
connclose(conn, "TFTP");
|
||||||
|
|
||||||
|
@ -183,6 +183,7 @@ struct OperationConfig {
|
|||||||
char *ftp_alternative_to_user; /* send command if USER/PASS fails */
|
char *ftp_alternative_to_user; /* send command if USER/PASS fails */
|
||||||
int ftp_filemethod;
|
int ftp_filemethod;
|
||||||
long tftp_blksize; /* TFTP BLKSIZE option */
|
long tftp_blksize; /* TFTP BLKSIZE option */
|
||||||
|
bool tftp_no_options; /* do not send TFTP options requests */
|
||||||
bool ignorecl; /* --ignore-content-length */
|
bool ignorecl; /* --ignore-content-length */
|
||||||
bool disable_sessionid;
|
bool disable_sessionid;
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ static const struct LongShort aliases[]= {
|
|||||||
{"$P", "service-name", TRUE},
|
{"$P", "service-name", TRUE},
|
||||||
{"$Q", "proto-default", TRUE},
|
{"$Q", "proto-default", TRUE},
|
||||||
{"$R", "expect100-timeout", TRUE},
|
{"$R", "expect100-timeout", TRUE},
|
||||||
|
{"$S", "tftp-no-options", FALSE},
|
||||||
{"0", "http1.0", FALSE},
|
{"0", "http1.0", FALSE},
|
||||||
{"01", "http1.1", FALSE},
|
{"01", "http1.1", FALSE},
|
||||||
{"02", "http2", FALSE},
|
{"02", "http2", FALSE},
|
||||||
@ -1005,6 +1006,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
if(err)
|
if(err)
|
||||||
return err;
|
return err;
|
||||||
break;
|
break;
|
||||||
|
case 'S': /* --tftp-no-options */
|
||||||
|
config->tftp_no_options = toggle;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#': /* --progress-bar */
|
case '#': /* --progress-bar */
|
||||||
|
@ -221,6 +221,7 @@ static const char *const helptext[] = {
|
|||||||
" --tcp-nodelay Use the TCP_NODELAY option",
|
" --tcp-nodelay Use the TCP_NODELAY option",
|
||||||
" -t, --telnet-option OPT=VAL Set telnet option",
|
" -t, --telnet-option OPT=VAL Set telnet option",
|
||||||
" --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)",
|
" --tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)",
|
||||||
|
" --tftp-no-options Do not send TFTP options requests",
|
||||||
" -z, --time-cond TIME Transfer based on a time condition",
|
" -z, --time-cond TIME Transfer based on a time condition",
|
||||||
" -1, --tlsv1 Use >= TLSv1 (SSL)",
|
" -1, --tlsv1 Use >= TLSv1 (SSL)",
|
||||||
" --tlsv1.0 Use TLSv1.0 (SSL)",
|
" --tlsv1.0 Use TLSv1.0 (SSL)",
|
||||||
|
@ -1354,6 +1354,10 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||||||
my_setopt_str(curl, CURLOPT_EXPECT_100_TIMEOUT_MS,
|
my_setopt_str(curl, CURLOPT_EXPECT_100_TIMEOUT_MS,
|
||||||
(long)(config->expect100timeout*1000));
|
(long)(config->expect100timeout*1000));
|
||||||
|
|
||||||
|
/* new in 7.48.0 */
|
||||||
|
if(config->tftp_no_options)
|
||||||
|
my_setopt(curl, CURLOPT_TFTP_NO_OPTIONS, 1L);
|
||||||
|
|
||||||
/* initialize retry vars for loop below */
|
/* initialize retry vars for loop below */
|
||||||
retry_sleep_default = (config->retry_delay) ?
|
retry_sleep_default = (config->retry_delay) ?
|
||||||
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
|
config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
|
||||||
|
@ -126,7 +126,7 @@ test1208 test1209 test1210 test1211 test1212 test1213 test1214 test1215 \
|
|||||||
test1216 test1217 test1218 test1219 \
|
test1216 test1217 test1218 test1219 \
|
||||||
test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 \
|
test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 \
|
||||||
test1228 test1229 test1230 test1231 test1232 test1233 test1234 test1235 \
|
test1228 test1229 test1230 test1231 test1232 test1233 test1234 test1235 \
|
||||||
test1236 test1237 test1238 test1239 test1240 test1241 \
|
test1236 test1237 test1238 test1239 test1240 test1241 test1242 test1243 \
|
||||||
\
|
\
|
||||||
test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
|
test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
|
||||||
test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
|
test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
|
||||||
|
43
tests/data/test1242
Normal file
43
tests/data/test1242
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
TFTP
|
||||||
|
TFTP RRQ
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
a chunk of
|
||||||
|
data
|
||||||
|
returned
|
||||||
|
to client
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
tftp
|
||||||
|
</server>
|
||||||
|
<name>
|
||||||
|
TFTP retrieve without TFTP options requests
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
tftp://%HOSTIP:%TFTPPORT//1242 --tftp-no-options --trace-ascii log/traceit
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify pseudo protocol after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
opcode: 1
|
||||||
|
mode: octet
|
||||||
|
filename: /1242
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
44
tests/data/test1243
Normal file
44
tests/data/test1243
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
TFTP
|
||||||
|
TFTP WRQ
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
tftp
|
||||||
|
</server>
|
||||||
|
<name>
|
||||||
|
TFTP send without TFTP options requests
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
-T log/test1243.txt tftp://%HOSTIP:%TFTPPORT// --tftp-no-options --trace-ascii log/traceit
|
||||||
|
</command>
|
||||||
|
<file name="log/test1243.txt">
|
||||||
|
a chunk of
|
||||||
|
data
|
||||||
|
sent
|
||||||
|
to server
|
||||||
|
</file>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify pseudo protocol after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<upload>
|
||||||
|
a chunk of
|
||||||
|
data
|
||||||
|
sent
|
||||||
|
to server
|
||||||
|
</upload>
|
||||||
|
<protocol>
|
||||||
|
opcode: 2
|
||||||
|
mode: octet
|
||||||
|
filename: /test1243.txt
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
Loading…
Reference in New Issue
Block a user