Skip to content

Commit

Permalink
oidc_child: use CURLOPT_PROTOCOLS_STR if available
Browse files Browse the repository at this point in the history
Since curl version 7.85.0 CURLOPT_PROTOCOLS is deprecated and should be
replaced by CURLOPT_PROTOCOLS_STR.

Resolves: #6922
  • Loading branch information
sumit-bose committed Sep 6, 2024
1 parent 604be8d commit e12a1e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/external/libcurl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@ AC_SUBST(CURL_LIBS)
AC_SUBST(CURL_CFLAGS)

PKG_CHECK_MODULES([CURL], [libcurl], [found_libcurl=yes], [found_libcurl=no])

AC_MSG_CHECKING([whether libcurl knows CURLOPT_PROTOCOLS_STR])

AC_LINK_IFELSE(
[AC_LANG_SOURCE([
#include <curl/curl.h>
int main () {
return CURLOPT_PROTOCOLS_STR;
}])],
[AC_MSG_RESULT([yes]); AC_DEFINE_UNQUOTED([HAVE_CURLOPT_PROTOCOLS_STR], [1], [CURLOPT_PROTOCOLS_STR available]) ],
[AC_MSG_RESULT([no])]
)
4 changes: 4 additions & 0 deletions src/oidc_child/oidc_child_curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ static errno_t set_http_opts(CURL *curl_ctx, struct devicecode_ctx *dc_ctx,
int ret;

/* Only allow https */
#ifdef HAVE_CURLOPT_PROTOCOLS_STR
res = curl_easy_setopt(curl_ctx, CURLOPT_PROTOCOLS_STR, "https");
#else
res = curl_easy_setopt(curl_ctx, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
#endif
if (res != CURLE_OK) {
DEBUG(SSSDBG_OP_FAILURE, "Failed to enforce HTTPS.\n");
ret = EIO;
Expand Down

0 comments on commit e12a1e4

Please sign in to comment.