curl: use CURLOPT_PROTOCOLS_STR instead of deprecated CURLOPT_PROTOCOLS
CURLOPT_PROTOCOLS [0] was deprecated in libcurl 7.85.0 with CURLOPT_PROTOCOLS_STR [1] as a replacement. Well, technically it was only deprecated in 7.87.0, and retroactively marked as deprecated since 7.85.0 [2]. But CURLOPT_PROTOCOLS_STR exists since 7.85.0, so that's what we want to use. This causes compiler warnings and build errors: ../src/core/nm-connectivity.c: In function 'do_curl_request': ../src/core/nm-connectivity.c:770:5: error: 'CURLOPT_PROTOCOLS' is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations] 770 | curl_easy_setopt(ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); | ^~~~~~~~~~~~~~~~ In file included from ../src/core/nm-connectivity.c:13: /usr/include/curl/curl.h:1749:3: note: declared here 1749 | CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181, | ^~~~~~~~~~~~~~~~~ This patch is largely taken from systemd patch [2]. Based-on-patch-by: Frantisek Sumsal <frantisek@sumsal.cz> [0] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html [1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html [2]6967571bf2
[3]e61a4c0b7c
Fixes:7a1734926a
('connectivity,cloud-setup: restrict curl protocols to HTTP and HTTPS')
This commit is contained in:
@@ -767,7 +767,13 @@ do_curl_request(NMConnectivityCheckHandle *cb_data, const char *hosts)
|
||||
curl_easy_setopt(ehandle, CURLOPT_INTERFACE, cb_data->ifspec);
|
||||
curl_easy_setopt(ehandle, CURLOPT_RESOLVE, cb_data->concheck.hosts);
|
||||
curl_easy_setopt(ehandle, CURLOPT_IPRESOLVE, resolve);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500 /* libcurl 7.85.0 */
|
||||
curl_easy_setopt(ehandle, CURLOPT_PROTOCOLS_STR, "HTTP,HTTPS");
|
||||
#else
|
||||
curl_easy_setopt(ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
#endif
|
||||
|
||||
if (_LOGT_ENABLED() && easy_debug_enabled()) {
|
||||
curl_easy_setopt(ehandle, CURLOPT_DEBUGFUNCTION, easy_debug_cb);
|
||||
curl_easy_setopt(ehandle, CURLOPT_DEBUGDATA, cb_data);
|
||||
|
@@ -305,7 +305,12 @@ nm_http_client_get(NMHttpClient *self,
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_WRITEFUNCTION, _get_writefunction_cb);
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_WRITEDATA, edata);
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_PRIVATE, edata);
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500 /* libcurl 7.85.0 */
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_PROTOCOLS_STR, "HTTP,HTTPS");
|
||||
#else
|
||||
curl_easy_setopt(edata->ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
#endif
|
||||
|
||||
if (http_headers) {
|
||||
for (i = 0; http_headers[i]; ++i) {
|
||||
|
Reference in New Issue
Block a user