mirror of
https://github.com/curl/curl.git
synced 2025-03-31 16:00:35 +08:00
curl: error out when options need features not present in libcurl
Trying to use a proxy when libcurl was built with proxy support disabled should make curl error out properly. Remove knowledge of disabled features from the tool code and instead make it properly respond to what libcurl returns. Update all tests to properly require the necessary features to be present/absent so that the test suite can still be run even with libcurl builds with disabled features. Ref: https://curl.se/mail/archive-2022-03/0013.html Closes #8565
This commit is contained in:
parent
96edc7954f
commit
95e8515ca0
@ -1259,45 +1259,51 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
||||
if(config->oauth_bearer)
|
||||
my_setopt_str(curl, CURLOPT_XOAUTH2_BEARER, config->oauth_bearer);
|
||||
|
||||
{
|
||||
my_setopt_str(curl, CURLOPT_PROXY, config->proxy);
|
||||
/* new in libcurl 7.5 */
|
||||
if(config->proxy)
|
||||
my_setopt_enum(curl, CURLOPT_PROXYTYPE, config->proxyver);
|
||||
my_setopt_str(curl, CURLOPT_PROXY, config->proxy);
|
||||
|
||||
my_setopt_str(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
||||
|
||||
/* new in libcurl 7.3 */
|
||||
my_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel?1L:0L);
|
||||
|
||||
/* new in libcurl 7.52.0 */
|
||||
if(config->preproxy)
|
||||
my_setopt_str(curl, CURLOPT_PRE_PROXY, config->preproxy);
|
||||
|
||||
/* new in libcurl 7.10.6 */
|
||||
if(config->proxyanyauth)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_ANY);
|
||||
else if(config->proxynegotiate)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_GSSNEGOTIATE);
|
||||
else if(config->proxyntlm)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_NTLM);
|
||||
else if(config->proxydigest)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_DIGEST);
|
||||
else if(config->proxybasic)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_BASIC);
|
||||
|
||||
/* new in libcurl 7.19.4 */
|
||||
my_setopt_str(curl, CURLOPT_NOPROXY, config->noproxy);
|
||||
|
||||
my_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS,
|
||||
config->suppress_connect_headers?1L:0L);
|
||||
if(config->proxy && result) {
|
||||
errorf(global, "proxy support is disabled in this libcurl\n");
|
||||
config->synthetic_error = TRUE;
|
||||
result = CURLE_NOT_BUILT_IN;
|
||||
break;
|
||||
}
|
||||
|
||||
/* new in libcurl 7.5 */
|
||||
if(config->proxy)
|
||||
my_setopt_enum(curl, CURLOPT_PROXYTYPE, config->proxyver);
|
||||
|
||||
my_setopt_str(curl, CURLOPT_PROXYUSERPWD, config->proxyuserpwd);
|
||||
|
||||
/* new in libcurl 7.3 */
|
||||
my_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config->proxytunnel?1L:0L);
|
||||
|
||||
/* new in libcurl 7.52.0 */
|
||||
if(config->preproxy)
|
||||
my_setopt_str(curl, CURLOPT_PRE_PROXY, config->preproxy);
|
||||
|
||||
/* new in libcurl 7.10.6 */
|
||||
if(config->proxyanyauth)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_ANY);
|
||||
else if(config->proxynegotiate)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_GSSNEGOTIATE);
|
||||
else if(config->proxyntlm)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_NTLM);
|
||||
else if(config->proxydigest)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_DIGEST);
|
||||
else if(config->proxybasic)
|
||||
my_setopt_bitmask(curl, CURLOPT_PROXYAUTH,
|
||||
(long)CURLAUTH_BASIC);
|
||||
|
||||
/* new in libcurl 7.19.4 */
|
||||
my_setopt_str(curl, CURLOPT_NOPROXY, config->noproxy);
|
||||
|
||||
my_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS,
|
||||
config->suppress_connect_headers?1L:0L);
|
||||
|
||||
my_setopt(curl, CURLOPT_FAILONERROR, config->failonerror?1L:0L);
|
||||
my_setopt(curl, CURLOPT_REQUEST_TARGET, config->request_target);
|
||||
my_setopt(curl, CURLOPT_UPLOAD, per->uploadfile?1L:0L);
|
||||
@ -1469,8 +1475,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
||||
}
|
||||
/* For the time being if --proxy-capath is not set then we use the
|
||||
--capath value for it, if any. See #1257 */
|
||||
if((config->proxy_capath || config->capath) &&
|
||||
!tool_setopt_skip(CURLOPT_PROXY_CAPATH)) {
|
||||
if(config->proxy_capath || config->capath) {
|
||||
result = res_setopt_str(curl, CURLOPT_PROXY_CAPATH,
|
||||
(config->proxy_capath ?
|
||||
config->proxy_capath :
|
||||
@ -1665,8 +1670,9 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
||||
|
||||
my_setopt_enum(curl, CURLOPT_SSLVERSION,
|
||||
config->ssl_version | config->ssl_version_max);
|
||||
my_setopt_enum(curl, CURLOPT_PROXY_SSLVERSION,
|
||||
config->proxy_ssl_version);
|
||||
if(config->proxy)
|
||||
my_setopt_enum(curl, CURLOPT_PROXY_SSLVERSION,
|
||||
config->proxy_ssl_version);
|
||||
|
||||
{
|
||||
long mask =
|
||||
|
@ -739,123 +739,3 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
|
||||
#include "tool_setopt.h"
|
||||
|
||||
#endif /* CURL_DISABLE_LIBCURL_OPTION */
|
||||
|
||||
/*
|
||||
* tool_setopt_skip() allows the curl tool code to avoid setopt options that
|
||||
* are explicitly disabled in the build.
|
||||
*/
|
||||
bool tool_setopt_skip(CURLoption tag)
|
||||
{
|
||||
#ifdef CURL_DISABLE_PROXY
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_HAPROXYPROTOCOL:
|
||||
case CURLOPT_HTTPPROXYTUNNEL:
|
||||
case CURLOPT_NOPROXY:
|
||||
case CURLOPT_PRE_PROXY:
|
||||
case CURLOPT_PROXY:
|
||||
case CURLOPT_PROXYAUTH:
|
||||
case CURLOPT_PROXY_CAINFO:
|
||||
case CURLOPT_PROXY_CAPATH:
|
||||
case CURLOPT_PROXY_CRLFILE:
|
||||
case CURLOPT_PROXYHEADER:
|
||||
case CURLOPT_PROXY_KEYPASSWD:
|
||||
case CURLOPT_PROXYPASSWORD:
|
||||
case CURLOPT_PROXY_PINNEDPUBLICKEY:
|
||||
case CURLOPT_PROXYPORT:
|
||||
case CURLOPT_PROXY_SERVICE_NAME:
|
||||
case CURLOPT_PROXY_SSLCERT:
|
||||
case CURLOPT_PROXY_SSLCERTTYPE:
|
||||
case CURLOPT_PROXY_SSL_CIPHER_LIST:
|
||||
case CURLOPT_PROXY_SSLKEY:
|
||||
case CURLOPT_PROXY_SSLKEYTYPE:
|
||||
case CURLOPT_PROXY_SSL_OPTIONS:
|
||||
case CURLOPT_PROXY_SSL_VERIFYHOST:
|
||||
case CURLOPT_PROXY_SSL_VERIFYPEER:
|
||||
case CURLOPT_PROXY_SSLVERSION:
|
||||
case CURLOPT_PROXY_TLS13_CIPHERS:
|
||||
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
|
||||
case CURLOPT_PROXY_TLSAUTH_TYPE:
|
||||
case CURLOPT_PROXY_TLSAUTH_USERNAME:
|
||||
case CURLOPT_PROXY_TRANSFER_MODE:
|
||||
case CURLOPT_PROXYTYPE:
|
||||
case CURLOPT_PROXYUSERNAME:
|
||||
case CURLOPT_PROXYUSERPWD:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef CURL_DISABLE_FTP
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_FTPPORT:
|
||||
case CURLOPT_FTP_ACCOUNT:
|
||||
case CURLOPT_FTP_ALTERNATIVE_TO_USER:
|
||||
case CURLOPT_FTP_FILEMETHOD:
|
||||
case CURLOPT_FTP_SKIP_PASV_IP:
|
||||
case CURLOPT_FTP_USE_EPRT:
|
||||
case CURLOPT_FTP_USE_EPSV:
|
||||
case CURLOPT_FTP_USE_PRET:
|
||||
case CURLOPT_KRBLEVEL:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef CURL_DISABLE_RTSP
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_INTERLEAVEDATA:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_COOKIES)
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_COOKIE:
|
||||
case CURLOPT_COOKIEFILE:
|
||||
case CURLOPT_COOKIEJAR:
|
||||
case CURLOPT_COOKIESESSION:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#if defined(CURL_DISABLE_TELNET)
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_TELNETOPTIONS:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef CURL_DISABLE_TFTP
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_TFTP_BLKSIZE:
|
||||
case CURLOPT_TFTP_NO_OPTIONS:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef CURL_DISABLE_NETRC
|
||||
#define USED_TAG
|
||||
switch(tag) {
|
||||
case CURLOPT_NETRC:
|
||||
case CURLOPT_NETRC_FILE:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USED_TAG
|
||||
(void)tag;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -29,17 +29,10 @@
|
||||
* Macros used in operate()
|
||||
*/
|
||||
|
||||
#define SETOPT_CHECK(v,opt) do { \
|
||||
if(!tool_setopt_skip(opt)) { \
|
||||
result = (v); \
|
||||
if(result) \
|
||||
break; \
|
||||
} \
|
||||
#define SETOPT_CHECK(v,opt) do { \
|
||||
result = (v); \
|
||||
} while(0)
|
||||
|
||||
/* allow removed features to simulate success: */
|
||||
bool tool_setopt_skip(CURLoption tag);
|
||||
|
||||
#ifndef CURL_DISABLE_LIBCURL_OPTION
|
||||
|
||||
/* Associate symbolic names with option values */
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
|
@ -25,6 +25,7 @@ none
|
||||
<features>
|
||||
idn
|
||||
http
|
||||
proxy
|
||||
</features>
|
||||
<setenv>
|
||||
LC_ALL=
|
||||
|
@ -23,6 +23,7 @@ none
|
||||
<features>
|
||||
idn
|
||||
http
|
||||
proxy
|
||||
</features>
|
||||
<setenv>
|
||||
LC_ALL=
|
||||
|
@ -23,6 +23,9 @@ boo
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
|
@ -22,6 +22,9 @@ foo
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
|
@ -22,6 +22,9 @@ foo
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
|
@ -23,6 +23,9 @@ foo
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
socks4
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
socks5
|
||||
|
@ -20,6 +20,9 @@ response 91
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
socks4
|
||||
</server>
|
||||
|
@ -31,6 +31,9 @@ dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
socks4
|
||||
|
@ -31,6 +31,9 @@ dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
socks5
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
socks4
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
socks5
|
||||
|
@ -29,6 +29,9 @@ Funny-head: yesyes
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
socks5
|
||||
|
@ -22,6 +22,9 @@ silly content
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
socks5
|
||||
|
@ -19,6 +19,9 @@ silly content
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
socks5
|
||||
|
@ -20,6 +20,9 @@ silly content
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
socks5
|
||||
|
@ -35,6 +35,9 @@ silly content
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
http-proxy
|
||||
|
@ -36,6 +36,9 @@ silly content
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<server>
|
||||
ftp
|
||||
http-proxy
|
||||
|
Loading…
x
Reference in New Issue
Block a user