diff options
author | Thomas Haller <thaller@redhat.com> | 2023-01-18 20:08:29 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-01-18 20:21:52 +0100 |
commit | dabfea2fc265e563af85cad62743c1c18738294c (patch) | |
tree | 3105380985c4bb84c0fb7a46ce5c6380acfc062c /src/nm-cloud-setup | |
parent | a60476b27f011cc7609796461a1afd6eefdc1747 (diff) | |
download | NetworkManager-dabfea2fc265e563af85cad62743c1c18738294c.tar.gz |
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] https://github.com/curl/curl/commit/6967571bf20624bc4cfa68fb8f90cbc53a87c6f2
[3] https://github.com/systemd/systemd/pull/25982/commits/e61a4c0b7c79eabbe4eb50ff2e663734fde769f0
Fixes: 7a1734926a4d ('connectivity,cloud-setup: restrict curl protocols to HTTP and HTTPS')
Diffstat (limited to 'src/nm-cloud-setup')
-rw-r--r-- | src/nm-cloud-setup/nm-http-client.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nm-cloud-setup/nm-http-client.c b/src/nm-cloud-setup/nm-http-client.c index a0053d472d..a0964e2165 100644 --- a/src/nm-cloud-setup/nm-http-client.c +++ b/src/nm-cloud-setup/nm-http-client.c @@ -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) { |