]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
configure: make NTP and ASYNCDNS support nonoptional
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 19 Mar 2025 15:11:39 +0000 (16:11 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Mar 2025 15:34:35 +0000 (16:34 +0100)
Don't allow the NTP support and asynchronous name resolving to be
disabled. pthreads are now a hard requirement.

NTP is the primary task of chrony. This functionality doesn't seem to be
commonly disabled (allowing only refclocks and manual input).

This removes rarely (if ever) used code and simplifies testing.

13 files changed:
Makefile.in
configure
doc/installation.adoc
stubs.c
test/compilation/001-features
test/simulation/test.common
test/system/test.common
test/unit/clientlog.c
test/unit/keys.c
test/unit/ntp_auth.c
test/unit/ntp_core.c
test/unit/ntp_ext.c
test/unit/ntp_sources.c

index 318109bb468ab0fee6df94f7e24432b3e9900bbb..2153c354e67f5e7a2762ac0b70130a69677e6885 100644 (file)
@@ -37,7 +37,9 @@ GETDATE_CFLAGS = @GETDATE_CFLAGS@
 
 EXTRA_OBJS = @EXTRA_OBJS@
 
-OBJS = array.o cmdparse.o conf.o leapdb.o local.o logging.o main.o memory.o quantiles.o \
+OBJS = addrfilt.o array.o clientlog.o cmdparse.o conf.o keys.o leapdb.o \
+       local.o logging.o main.o memory.o nameserv.o nameserv_async.o \
+       ntp_auth.o ntp_core.o ntp_ext.o ntp_io.o ntp_sources.o quantiles.o \
        reference.o regress.o rtc.o samplefilt.o sched.o socket.o sources.o sourcestats.o \
        stubs.o smooth.o sys.o sys_null.o tempcomp.o util.o $(EXTRA_OBJS)
 
index dbdd72d6684f080654e4082b8a39f60aa5605d07..91893e2ce19a68a64a414ad195c557c963a329ff 100755 (executable)
--- a/configure
+++ b/configure
@@ -116,7 +116,6 @@ For better control, use the options below.
   --without-tomcrypt     Don't use libtomcrypt even if it is available
   --disable-nts          Disable NTS support
   --disable-cmdmon       Disable command and monitoring support
-  --disable-ntp          Disable NTP support
   --disable-refclock     Disable reference clock support
   --disable-phc          Disable PHC refclock driver
   --disable-pps          Disable PPS refclock driver
@@ -126,7 +125,6 @@ For better control, use the options below.
   --without-libcap       Don't use libcap even if it is available
   --enable-scfilter      Enable support for system call filtering
   --without-seccomp      Don't use seccomp even if it is available
-  --disable-asyncdns     Disable asynchronous name resolving
   --disable-forcednsretry Don't retry on permanent DNS error
   --without-aes-gcm-siv  Don't use AES-GCM-SIV for NTS even if it is available
   --without-clock-gettime Don't use clock_gettime() even if it is available
@@ -219,7 +217,6 @@ EXTRA_CLI_OBJECTS=""
 
 feat_debug=0
 feat_cmdmon=1
-feat_ntp=1
 feat_refclock=1
 feat_readline=1
 try_editline=1
@@ -243,7 +240,6 @@ try_phc=0
 feat_pps=1
 try_setsched=0
 try_lockmem=0
-feat_asyncdns=1
 feat_forcednsretry=1
 try_aes_gcm_siv=1
 try_clock_gettime=1
@@ -253,7 +249,6 @@ feat_timestamping=1
 try_timestamping=0
 feat_ntp_signd=0
 ntp_era_split=""
-use_pthread=0
 default_user="root"
 default_hwclockfile=""
 default_pidfile="/var/run/chrony/chronyd.pid"
@@ -308,9 +303,6 @@ do
     --disable-cmdmon)
       feat_cmdmon=0
     ;;
-    --disable-ntp)
-      feat_ntp=0
-    ;;
     --disable-refclock)
       feat_refclock=0
     ;;
@@ -341,9 +333,6 @@ do
     --without-seccomp)
       try_seccomp=0
     ;;
-    --disable-asyncdns)
-      feat_asyncdns=0
-    ;;
     --disable-forcednsretry)
       feat_forcednsretry=0
     ;;
@@ -504,22 +493,9 @@ if [ $feat_cmdmon = "1" ]; then
   EXTRA_OBJECTS="$EXTRA_OBJECTS cmdmon.o manual.o pktlength.o"
 fi
 
-if [ $feat_ntp = "1" ]; then
-  add_def FEAT_NTP
-  EXTRA_OBJECTS="$EXTRA_OBJECTS ntp_auth.o ntp_core.o ntp_ext.o ntp_io.o ntp_sources.o"
-  if [ $feat_ntp_signd = "1" ]; then
-    add_def FEAT_SIGND
-    EXTRA_OBJECTS="$EXTRA_OBJECTS ntp_signd.o"
-  fi
-else
-  feat_asyncdns=0
-  feat_timestamping=0
-fi
-
-if [ "$feat_cmdmon" = "1" ] || [ $feat_ntp = "1" ]; then
-  EXTRA_OBJECTS="$EXTRA_OBJECTS addrfilt.o clientlog.o keys.o nameserv.o"
-else
-  feat_ipv6=0
+if [ $feat_ntp_signd = "1" ]; then
+  add_def FEAT_SIGND
+  EXTRA_OBJECTS="$EXTRA_OBJECTS ntp_signd.o"
 fi
 
 if [ $feat_refclock = "1" ]; then
@@ -706,15 +682,15 @@ then
   exit 1
 fi
 
-if [ $feat_asyncdns = "1" ] && \
-  test_code 'pthread' 'pthread.h' '-pthread' '' '
-    pthread_t thread;
-    return (int)pthread_create(&thread, NULL, (void *)1, NULL);'
+if test_code 'pthread' 'pthread.h' '-pthread' '' '
+  pthread_t thread;
+  return (int)pthread_create(&thread, NULL, (void *)1, NULL);'
 then
-  add_def FEAT_ASYNCDNS
   add_def USE_PTHREAD_ASYNCDNS
-  EXTRA_OBJECTS="$EXTRA_OBJECTS nameserv_async.o"
-  use_pthread=1
+  MYCFLAGS="$MYCFLAGS -pthread"
+else
+  echo "error: pthread_create() not found"
+  exit 1
 fi
 
 if [ $try_arc4random = "1" ] && \
@@ -817,12 +793,10 @@ if [ $feat_scfilter = "1" ] && [ $try_seccomp = "1" ] && \
     'seccomp_init(SCMP_ACT_KILL);'
 then
   add_def FEAT_SCFILTER
-  if [ $feat_ntp = "1" ]; then
-    # NAME2IPADDRESS shouldn't be enabled together with a privops operation
-    # used by the main thread as the helper process works on one request at
-    # a time and the async resolver would block the main thread
-    priv_ops="NAME2IPADDRESS RELOADDNS"
-  fi
+  # NAME2IPADDRESS shouldn't be enabled together with a privops operation
+  # used by the main thread as the helper process works on one request at
+  # a time and the async resolver would block the main thread
+  priv_ops="NAME2IPADDRESS RELOADDNS"
   EXTRA_LIBS="$EXTRA_LIBS -lseccomp"
 fi
 
@@ -861,7 +835,6 @@ if [ $try_setsched = "1" ] && \
      pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched);'
 then
   add_def HAVE_PTHREAD_SETSCHEDPARAM
-  use_pthread=1
 fi
 
 if [ $try_lockmem = "1" ] && \
@@ -978,7 +951,7 @@ EXTRA_OBJECTS="$EXTRA_OBJECTS $HASH_OBJ"
 EXTRA_CLI_OBJECTS="$EXTRA_CLI_OBJECTS $HASH_OBJ"
 LIBS="$LIBS $HASH_LINK"
 
-if [ $feat_ntp = "1" ] && [ $feat_nts = "1" ] && [ $try_gnutls = "1" ]; then
+if [ $feat_nts = "1" ] && [ $try_gnutls = "1" ]; then
   if [ "$HASH_OBJ" = "hash_gnutls.o" ]; then
     test_cflags=""
     test_link=""
@@ -1038,10 +1011,6 @@ if [ $feat_ntp = "1" ] && [ $feat_nts = "1" ] && [ $try_gnutls = "1" ]; then
   fi
 fi
 
-if [ $use_pthread = "1" ]; then
-  MYCFLAGS="$MYCFLAGS -pthread"
-fi
-
 SYSCONFDIR=/etc
 if [ "x$SETSYSCONFDIR" != "x" ]; then
   SYSCONFDIR=$SETSYSCONFDIR
@@ -1107,7 +1076,7 @@ add_def MAIL_PROGRAM "\"$mail_program\""
 
 common_features="`get_features SECHASH IPV6 DEBUG`"
 chronyc_features="`get_features READLINE`"
-chronyd_features="`get_features CMDMON NTP REFCLOCK RTC PRIVDROP SCFILTER SIGND ASYNCDNS NTS`"
+chronyd_features="`get_features CMDMON REFCLOCK RTC PRIVDROP SCFILTER SIGND NTS`"
 add_def CHRONYC_FEATURES "\"$chronyc_features $common_features\""
 add_def CHRONYD_FEATURES "\"$chronyd_features $common_features\""
 echo "Features : $chronyd_features $chronyc_features $common_features"
index b683911c62899a7bf67fc0736d47165980443115..0014f7e4e71c334f4721f33f56dd324a14e404d5 100644 (file)
@@ -85,13 +85,6 @@ will be built with support for dropping root privileges. On other systems no
 extra library is needed. The default user which `chronyd` should run as can be
 specified with the `--with-user` option of the `configure` script.
 
-If development files for the POSIX threads library are available, `chronyd`
-will be built with support for asynchronous resolving of hostnames specified in
-the `server`, `peer`, and `pool` directives. This allows `chronyd` operating as
-a server to respond to client requests when resolving a hostname. If you don't
-want to enable the support, specify the `--disable-asyncdns` flag to
-`configure`.
-
 If development files for the https://www.lysator.liu.se/~nisse/nettle/[Nettle],
 https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS[NSS], or
 https://www.libtom.net/LibTomCrypt/[libtomcrypt] library are available,
diff --git a/stubs.c b/stubs.c
index 9d0f848109ee9c19b024456daea74b81c997796a..f7c85abf5c7926138d5fab89d68bac58ce2dbbe4 100644 (file)
--- a/stubs.c
+++ b/stubs.c
 #include "sched.h"
 #include "util.h"
 
-#if defined(FEAT_NTP) && !defined(FEAT_ASYNCDNS)
-
-/* This is a blocking implementation used when asynchronous resolving is not available */
-
-struct DNS_Async_Instance {
-  const char *name;
-  DNS_NameResolveHandler handler;
-  void *arg;
-  int pipe[2];
-};
-
-static void
-resolve_name(int fd, int event, void *anything)
-{
-  struct DNS_Async_Instance *inst;
-  IPAddr addrs[DNS_MAX_ADDRESSES];
-  DNS_Status status;
-  int i;
-
-  inst = (struct DNS_Async_Instance *)anything;
-
-  SCH_RemoveFileHandler(inst->pipe[0]);
-  close(inst->pipe[0]);
-  close(inst->pipe[1]);
-
-  status = PRV_Name2IPAddress(inst->name, addrs, DNS_MAX_ADDRESSES);
-
-  for (i = 0; status == DNS_Success && i < DNS_MAX_ADDRESSES &&
-       addrs[i].family != IPADDR_UNSPEC; i++)
-    ;
-
-  (inst->handler)(status, i, addrs, inst->arg);
-
-  Free(inst);
-}
-
-void
-DNS_Name2IPAddressAsync(const char *name, DNS_NameResolveHandler handler, void *anything)
-{
-  struct DNS_Async_Instance *inst;
-
-  inst = MallocNew(struct DNS_Async_Instance);
-  inst->name = name;
-  inst->handler = handler;
-  inst->arg = anything;
-
-  if (pipe(inst->pipe))
-    LOG_FATAL("pipe() failed");
-
-  UTI_FdSetCloexec(inst->pipe[0]);
-  UTI_FdSetCloexec(inst->pipe[1]);
-
-  SCH_AddFileHandler(inst->pipe[0], SCH_FILE_INPUT, resolve_name, inst);
-
-  if (write(inst->pipe[1], "", 1) < 0)
-    ;
-}
-
-#endif /* !FEAT_ASYNCDNS */
-
 #ifndef FEAT_CMDMON
 
 void
@@ -144,259 +84,6 @@ MNL_Finalise(void)
 
 #endif /* !FEAT_CMDMON */
 
-#ifndef FEAT_NTP
-
-void
-NCR_AddBroadcastDestination(NTP_Remote_Address *addr, int interval)
-{
-}
-
-void
-NCR_Initialise(void)
-{
-}
-
-void
-NCR_Finalise(void)
-{
-}
-
-int
-NCR_AddAccessRestriction(IPAddr *ip_addr, int subnet_bits, int allow, int all)
-{
-  return 1;
-}
-
-int
-NCR_CheckAccessRestriction(IPAddr *ip_addr)
-{
-  return 0;
-}
-
-void
-NIO_Initialise(void)
-{
-}
-
-void
-NIO_Finalise(void)
-{
-}
-
-void
-NSR_Initialise(void)
-{
-}
-
-void
-NSR_Finalise(void)
-{
-}
-
-NSR_Status
-NSR_AddSource(NTP_Remote_Address *remote_addr, NTP_Source_Type type,
-              SourceParameters *params, uint32_t *conf_id)
-{
-  return NSR_TooManySources;
-}
-
-NSR_Status
-NSR_AddSourceByName(char *name, int family, int port, int pool, NTP_Source_Type type,
-                    SourceParameters *params, uint32_t *conf_id)
-{
-  return NSR_TooManySources;
-}
-
-const char *
-NSR_StatusToString(NSR_Status status)
-{
-  return "NTP not supported";
-}
-
-NSR_Status
-NSR_RemoveSource(IPAddr *address)
-{
-  return NSR_NoSuchSource;
-}
-
-void
-NSR_RemoveSourcesById(uint32_t conf_id)
-{
-}
-
-void
-NSR_RemoveAllSources(void)
-{
-}
-
-void
-NSR_HandleBadSource(IPAddr *address)
-{
-}
-
-void
-NSR_RefreshAddresses(void)
-{
-}
-
-char *
-NSR_GetName(IPAddr *address)
-{
-  return NULL;
-}
-
-void
-NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler)
-{
-  if (handler)
-    (handler)();
-}
-
-void
-NSR_ResolveSources(void)
-{
-}
-
-void NSR_StartSources(void)
-{
-}
-
-void NSR_AutoStartSources(void)
-{
-}
-
-int
-NSR_InitiateSampleBurst(int n_good_samples, int n_total_samples,
-                        IPAddr *mask, IPAddr *address)
-{
-  return 0;
-}
-
-uint32_t
-NSR_GetLocalRefid(IPAddr *address)
-{
-  return 0;
-}
-
-int
-NSR_SetConnectivity(IPAddr *mask, IPAddr *address, SRC_Connectivity connectivity)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMinpoll(IPAddr *address, int new_minpoll)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMaxpoll(IPAddr *address, int new_maxpoll)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMaxdelay(IPAddr *address, double new_max_delay)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMaxdelayratio(IPAddr *address, double new_max_delay_ratio)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMaxdelaydevratio(IPAddr *address, double new_max_delay_dev_ratio)
-{
-  return 0;
-}
-
-int
-NSR_ModifyMinstratum(IPAddr *address, int new_min_stratum)
-{
-  return 0;
-}
-
-int
-NSR_ModifyOffset(IPAddr *address, double new_offset)
-{
-  return 0;
-}
-
-int
-NSR_ModifyPolltarget(IPAddr *address, int new_poll_target)
-{
-  return 0;
-}
-
-void
-NSR_ReportSource(RPT_SourceReport *report, struct timespec *now)
-{
-  memset(report, 0, sizeof (*report));
-}
-  
-int
-NSR_GetAuthReport(IPAddr *address, RPT_AuthReport *report)
-{
-  return 0;
-}
-
-int
-NSR_GetNTPReport(RPT_NTPReport *report)
-{
-  return 0;
-}
-
-void
-NSR_GetActivityReport(RPT_ActivityReport *report)
-{
-  memset(report, 0, sizeof (*report));
-}
-
-void
-NSR_DumpAuthData(void)
-{
-}
-
-#ifndef FEAT_CMDMON
-
-void
-CLG_Initialise(void)
-{
-}
-
-void
-CLG_Finalise(void)
-{
-}
-
-void
-DNS_SetAddressFamily(int family)
-{
-}
-
-DNS_Status
-DNS_Name2IPAddress(const char *name, IPAddr *ip_addrs, int max_addrs)
-{
-  return DNS_Failure;
-}
-
-void
-KEY_Initialise(void)
-{
-}
-
-void
-KEY_Finalise(void)
-{
-}
-
-#endif /* !FEAT_CMDMON */
-#endif /* !FEAT_NTP */
-
 #ifndef FEAT_REFCLOCK
 void
 RCL_Initialise(void)
index 282ce57bd6b18410462a994c5d9090da827b5e02..f50c7a5020b2640f59e9930b2838827022c15a77 100755 (executable)
@@ -10,7 +10,6 @@ for opts in \
        "--enable-debug" \
        "--enable-ntp-signd" \
        "--enable-scfilter" \
-       "--disable-asyncdns" \
        "--disable-ipv6" \
        "--disable-privdrop" \
        "--disable-readline" \
@@ -18,16 +17,10 @@ for opts in \
        "--disable-sechash" \
        "--disable-cmdmon" \
        "--disable-cmdmon --enable-scfilter" \
-       "--disable-ntp" \
-       "--disable-ntp --enable-scfilter" \
        "--disable-nts" \
        "--disable-refclock" \
        "--disable-timestamping" \
-       "--disable-timestamping --disable-ntp" \
-       "--disable-cmdmon --disable-ntp" \
-       "--disable-cmdmon --disable-ntp --enable-scfilter" \
-       "--disable-cmdmon --disable-refclock" \
-       "--disable-cmdmon --disable-ntp --disable-refclock"
+       "--disable-cmdmon --disable-refclock"
 do
        ./configure $opts || exit 1
        make clean
index 604df61ae6744eaf1c491eaafaff422c92e0a30b..ec39a7ccfd134c7cc66946c303f14ba484311613 100644 (file)
@@ -91,8 +91,6 @@ done
 test_start() {
        rm -rf tmp/*
        echo "Testing $@:"
-
-       check_config_h 'FEAT_NTP 1' || test_skip
 }
 
 test_pass() {
index 9eb2382b21efd468b6859815d25bbac54a950d45..43bf48007a8194c82f8cac7a9aeb8d299858986b 100644 (file)
@@ -27,7 +27,7 @@ TEST_PRIVDROP_USER=${TEST_PRIVDROP_USER:-nobody}
 test_start() {
        local user=$(get_user)
 
-       check_chronyd_features NTP CMDMON || test_skip "NTP/CMDMON support disabled"
+       check_chronyd_features CMDMON || test_skip "CMDMON support disabled"
 
        [ "${#TEST_DIR}" -ge 5 ] || test_skip "invalid TEST_DIR"
 
index 96818b2416f0828aa355b91aafea211a28c2ec46..9a9f4a6f3930f3afe7b7d2720b300f8a68264586 100644 (file)
@@ -21,8 +21,6 @@
 #include <config.h>
 #include "test.h"
 
-#if defined(FEAT_NTP) || defined(FEAT_CMDMON)
-
 #include <clientlog.c>
 
 static uint64_t
@@ -321,10 +319,3 @@ test_unit(void)
   LCL_Finalise();
   CNF_Finalise();
 }
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif
index aa5e6491f78d34202d5edb50c370fbed09d7777e..47d907b56370b3243328605e64e34ea62f4df37d 100644 (file)
@@ -21,8 +21,6 @@
 #include <config.h>
 #include "test.h"
 
-#if defined(FEAT_NTP) || defined(FEAT_CMDMON)
-
 #include <keys.c>
 
 #define KEYS 100
@@ -164,10 +162,3 @@ test_unit(void)
   CNF_Finalise();
   HSH_Finalise();
 }
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif
index 5f2a9bc322a71d7a9f21f1346c30f1094457fbdf..e2924a3348b12077329d64cca9c110774a7d2fb9 100644 (file)
@@ -29,8 +29,6 @@
 #include <socket.h>
 #include "test.h"
 
-#ifdef FEAT_NTP
-
 #include <ntp_auth.c>
 
 static void
@@ -279,11 +277,3 @@ test_unit(void)
   CNF_Finalise();
   HSH_Finalise();
 }
-
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif
index 989b294bc76606b0581ef0245cb1d2963cacbded..7bcc34a7747e82d16f13a30b3cfc2c90b709af20 100644 (file)
@@ -29,8 +29,6 @@
 #include <local.h>
 #include "test.h"
 
-#ifdef FEAT_NTP
-
 static struct timespec current_time;
 static NTP_Packet req_buffer, res_buffer;
 static int req_length, res_length;
@@ -638,11 +636,3 @@ test_unit(void)
   CNF_Finalise();
   HSH_Finalise();
 }
-
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif
index c37e702f91ec573af22c8a48defccfb08dae44f3..8fec08304d7511a238740e7d2ba482d55148a66d 100644 (file)
@@ -21,8 +21,6 @@
 #include <config.h>
 #include "test.h"
 
-#ifdef FEAT_NTP
-
 #include <util.h>
 #include <logging.h>
 
@@ -157,11 +155,3 @@ test_unit(void)
 
   }
 }
-
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif
index a9bdbad519e41e9f9a0359916097b0192c528bf3..be5d2ea860055da4fe1df8b771d38ef1fbf2f830 100644 (file)
@@ -21,8 +21,6 @@
 #include <config.h>
 #include "test.h"
 
-#ifdef FEAT_NTP
-
 #include <conf.h>
 #include <cmdparse.h>
 #include <nameserv_async.h>
@@ -372,11 +370,3 @@ test_unit(void)
   CNF_Finalise();
   HSH_Finalise();
 }
-
-#else
-void
-test_unit(void)
-{
-  TEST_REQUIRE(0);
-}
-#endif