Skip to content

Commit d7e4084

Browse files
committed
oauth: Disallow synchronous DNS in libcurl
There is concern that a blocking DNS lookup in libpq could stall a backend process (say, via FDW). Since there's currently no strong evidence that synchronous DNS is a popular option, disallow it entirely rather than warning at configure time. We can revisit if anyone complains. Per query from Andres Freund. Author: Jacob Champion <jacob.champion@enterprisedb.com> Discussion: https://postgr.es/m/p4bd7mn6dxr2zdak74abocyltpfdxif4pxqzixqpxpetjwt34h%40qc6jgfmoddvq
1 parent 434dbf6 commit d7e4084

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

config/programs.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ AC_DEFUN([PGAC_CHECK_LIBCURL],
316316
[Define to 1 if curl_global_init() is guaranteed to be thread-safe.])
317317
fi
318318
319-
# Warn if a thread-friendly DNS resolver isn't built.
319+
# Fail if a thread-friendly DNS resolver isn't built.
320320
AC_CACHE_CHECK([for curl support for asynchronous DNS], [pgac_cv__libcurl_async_dns],
321321
[AC_RUN_IFELSE([AC_LANG_PROGRAM([
322322
#include <curl/curl.h>
@@ -332,10 +332,10 @@ AC_DEFUN([PGAC_CHECK_LIBCURL],
332332
[pgac_cv__libcurl_async_dns=yes],
333333
[pgac_cv__libcurl_async_dns=no],
334334
[pgac_cv__libcurl_async_dns=unknown])])
335-
if test x"$pgac_cv__libcurl_async_dns" != xyes ; then
336-
AC_MSG_WARN([
335+
if test x"$pgac_cv__libcurl_async_dns" = xno ; then
336+
AC_MSG_ERROR([
337337
*** The installed version of libcurl does not support asynchronous DNS
338-
*** lookups. Connection timeouts will not be honored during DNS resolution,
339-
*** which may lead to hangs in client programs.])
338+
*** lookups. Rebuild libcurl with the AsynchDNS feature enabled in order
339+
*** to use it with libpq.])
340340
fi
341341
])# PGAC_CHECK_LIBCURL

configure

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12493,7 +12493,7 @@ $as_echo "#define HAVE_THREADSAFE_CURL_GLOBAL_INIT 1" >>confdefs.h
1249312493

1249412494
fi
1249512495

12496-
# Warn if a thread-friendly DNS resolver isn't built.
12496+
# Fail if a thread-friendly DNS resolver isn't built.
1249712497
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl support for asynchronous DNS" >&5
1249812498
$as_echo_n "checking for curl support for asynchronous DNS... " >&6; }
1249912499
if ${pgac_cv__libcurl_async_dns+:} false; then :
@@ -12535,15 +12535,11 @@ fi
1253512535
fi
1253612536
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__libcurl_async_dns" >&5
1253712537
$as_echo "$pgac_cv__libcurl_async_dns" >&6; }
12538-
if test x"$pgac_cv__libcurl_async_dns" != xyes ; then
12539-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
12540-
*** The installed version of libcurl does not support asynchronous DNS
12541-
*** lookups. Connection timeouts will not be honored during DNS resolution,
12542-
*** which may lead to hangs in client programs." >&5
12543-
$as_echo "$as_me: WARNING:
12538+
if test x"$pgac_cv__libcurl_async_dns" = xno ; then
12539+
as_fn_error $? "
1254412540
*** The installed version of libcurl does not support asynchronous DNS
12545-
*** lookups. Connection timeouts will not be honored during DNS resolution,
12546-
*** which may lead to hangs in client programs." >&2;}
12541+
*** lookups. Rebuild libcurl with the AsynchDNS feature enabled in order
12542+
*** to use it with libpq." "$LINENO" 5
1254712543
fi
1254812544

1254912545
fi

meson.build

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,7 @@ if not libcurlopt.disabled()
909909
cdata.set('HAVE_THREADSAFE_CURL_GLOBAL_INIT', 1)
910910
endif
911911

912-
# Warn if a thread-friendly DNS resolver isn't built.
913-
libcurl_async_dns = false
914-
912+
# Fail if a thread-friendly DNS resolver isn't built.
915913
if not meson.is_cross_build()
916914
r = cc.run('''
917915
#include <curl/curl.h>
@@ -931,16 +929,12 @@ if not libcurlopt.disabled()
931929
)
932930

933931
assert(r.compiled())
934-
if r.returncode() == 0
935-
libcurl_async_dns = true
936-
endif
937-
endif
938-
939-
if not libcurl_async_dns
940-
warning('''
932+
if r.returncode() != 0
933+
error('''
941934
*** The installed version of libcurl does not support asynchronous DNS
942-
*** lookups. Connection timeouts will not be honored during DNS resolution,
943-
*** which may lead to hangs in client programs.''')
935+
*** lookups. Rebuild libcurl with the AsynchDNS feature enabled in order
936+
*** to use it with libpq.''')
937+
endif
944938
endif
945939
endif
946940

0 commit comments

Comments
 (0)