summaryrefslogtreecommitdiffstats
path: root/debuginfod
diff options
context:
space:
mode:
authorNorbert Lange <[email protected]>2024-04-12 22:03:08 +0200
committerFrank Ch. Eigler <[email protected]>2024-04-15 11:49:36 -0400
commit229aac471bb96035a4558db0dc74ff00d0aa08d1 (patch)
treea2541316df973503635d33148bb6219e95648c26 /debuginfod
parentd9f38a7052c22c7762aa5b98b401e8a324336bce (diff)
PR31620: debuginfod-client.c: Test for https support in libcurl
libcurl will fail if a protocol is requested that is not available. Signed-off-by: Norbert Lange <[email protected]>
Diffstat (limited to 'debuginfod')
-rw-r--r--debuginfod/debuginfod-client.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index 0ee7db3d..4e7a8a2a 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -115,11 +115,19 @@ void debuginfod_end (debuginfod_client *c) { }
#include <pthread.h>
static pthread_once_t init_control = PTHREAD_ONCE_INIT;
+static bool curl_has_https; // = false
static void
libcurl_init(void)
{
curl_global_init(CURL_GLOBAL_DEFAULT);
+
+ for (const char *const *protocol = curl_version_info(CURLVERSION_NOW)->protocols;
+ *protocol != NULL; ++protocol)
+ {
+ if(strcmp("https", *protocol) == 0)
+ curl_has_https = true;
+ }
}
struct debuginfod_client
@@ -1368,13 +1376,15 @@ debuginfod_query_server (debuginfod_client *c,
} while (0)
/* Only allow http:// + https:// + file:// so we aren't being
- redirected to some unsupported protocol. */
+ redirected to some unsupported protocol.
+ libcurl will fail if we request a single protocol that is not
+ available. https missing is the most likely issue */
#if CURL_AT_LEAST_VERSION(7, 85, 0)
curl_easy_setopt_ck(data[i].handle, CURLOPT_PROTOCOLS_STR,
- "http,https,file");
+ curl_has_https ? "https,http,file" : "http,file");
#else
curl_easy_setopt_ck(data[i].handle, CURLOPT_PROTOCOLS,
- (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_FILE));
+ ((curl_has_https ? CURLPROTO_HTTPS : 0) | CURLPROTO_HTTP | CURLPROTO_FILE));
#endif
curl_easy_setopt_ck(data[i].handle, CURLOPT_URL, data[i].url);
if (vfd >= 0)