]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Drop readline alternatives in favor of libedit
authorOndřej Surý <ondrej@isc.org>
Mon, 3 Mar 2025 11:32:14 +0000 (12:32 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 31 Mar 2025 13:20:40 +0000 (15:20 +0200)
The libedit is now ubiquitous and has a licences compatible with
MPL 2.0.  Drop readline (GPL 3.0) and editline (obsolete) support
in favor of libedit.

.gitlab-ci.yml
bin/dig/Makefile.am
bin/dig/nslookup.c
bin/nsupdate/Makefile.am
bin/nsupdate/nsupdate.c
configure.ac
doc/arm/build.inc.rst
lib/isc/Makefile.am
lib/isc/include/isc/readline.h [moved from bin/dig/readline.h with 60% similarity]

index fda94aa60e8ada06e71e6fe405e017d94c6de369..33985b21d97efef25b674e3f5b2917fe43497f13 100644 (file)
@@ -36,11 +36,8 @@ variables:
 
   AM_COLOR_TESTS: always
 
-  WITHOUT_READLINE: "--without-readline"
-  WITH_READLINE: "--with-readline"
-  WITH_READLINE_EDITLINE: "--with-readline=editline"
-  WITH_READLINE_LIBEDIT: "--with-readline=libedit"
-  WITH_READLINE_READLINE: "--with-readline=readline"
+  WITHOUT_LIBEDIT: "--without-libedit"
+  WITH_LIBEDIT: "--with-libedit"
 
   INSTALL_PATH: "${CI_PROJECT_DIR}/.local"
 
@@ -153,7 +150,7 @@ stages:
     GIT_CLONE_PATH: "/home/ec2-user/builds/${CI_PROJECT_PATH}/"
     # Use MIT Kerberos5 for BIND 9 GSS-API support because of FreeBSD Heimdal
     # incompatibility; see https://bugs.freebsd.org/275241.
-    EXTRA_CONFIGURE: "${WITH_READLINE_EDITLINE} --with-gssapi=/usr/local/bin/krb5-config"
+    EXTRA_CONFIGURE: "${WITH_LIBEDIT} --with-gssapi=/usr/local/bin/krb5-config"
 
 # Autoscaling GitLab Runner on AWS EC2 (FreeBSD 13)
 
@@ -313,18 +310,10 @@ stages:
     - find -name 'tsan.*' -exec "$PYTHON" util/parse_tsan.py {} \;
 
 .check_readline_setup: &check_readline_setup
-    - if [[ -n "${WITHOUT_READLINE}" ]]; then
-        ! grep "^#define HAVE_READLINE" config.h;
-      elif [[ -n "${WITH_READLINE}" ]]; then
-        grep -e "^#define HAVE_READLINE_READLINE"
-             -e "^#define HAVE_READLINE_LIBEDIT"
-             -e "^#define HAVE_READLINE_EDITLINE" config.h;
-      elif [[ -n "${WITH_READLINE_EDITLINE}" ]]; then
-        grep "^#define HAVE_READLINE_EDITLINE" config.h;
-      elif [[ -n "${WITH_READLINE_LIBEDIT}" ]]; then
-        grep "^#define HAVE_READLINE_LIBEDIT" config.h;
-      elif [[ -n "${WITH_READLINE_READLINE}" ]]; then
-        grep "^#define HAVE_READLINE_READLINE" config.h;
+    - if [[ -n "${WITHOUT_LIBEDIT}" ]]; then
+        ! grep "^#define HAVE_LIBEDIT" config.h;
+      elif [[ -n "${WITH_LIBEDIT}" ]]; then
+        grep -e "^#define HAVE_LIBEDIT" config.h;
       fi
 
 # Unpack release tarball and continue work in the extracted directory.
@@ -831,7 +820,7 @@ gcc:alpine3.21:amd64:
   variables:
     CC: gcc
     CFLAGS: "${CFLAGS_COMMON}"
-    EXTRA_CONFIGURE: "${WITHOUT_READLINE}"
+    EXTRA_CONFIGURE: "${WITHOUT_LIBEDIT}"
   <<: *alpine_3_21_amd64_image
   <<: *build_job
 
@@ -971,7 +960,7 @@ gcc:bookworm:amd64:
     CC: gcc
     CFLAGS: "${CFLAGS_COMMON} --coverage -O0"
     # Tracing needs to be disabled otherwise gcovr fails
-    EXTRA_CONFIGURE: "--with-libidn2 ${WITH_READLINE_LIBEDIT} --disable-tracing"
+    EXTRA_CONFIGURE: "--with-libidn2 ${WITH_LIBEDIT} --disable-tracing"
     RUN_MAKE_INSTALL: 1
   <<: *debian_bookworm_amd64_image
   <<: *build_job
@@ -1028,7 +1017,7 @@ gcc:bookworm:amd64cross32:
   variables:
     CFLAGS: "${CFLAGS_COMMON}"
     CROSS_COMPILATION: 1
-    EXTRA_CONFIGURE: "--build=x86_64-linux-gnu --host=i686-linux-gnu --with-libidn2 ${WITH_READLINE_LIBEDIT}"
+    EXTRA_CONFIGURE: "--build=x86_64-linux-gnu --host=i686-linux-gnu --with-libidn2 ${WITH_LIBEDIT}"
   <<: *debian_bookworm_amd64cross32_image
   <<: *build_job
 
@@ -1099,7 +1088,7 @@ gcc:sid:amd64:
   variables:
     CC: gcc
     CFLAGS: "${CFLAGS_COMMON} -O3"
-    EXTRA_CONFIGURE: "--with-libidn2 --without-lmdb ${WITH_READLINE}"
+    EXTRA_CONFIGURE: "--with-libidn2 --without-lmdb ${WITH_LIBEDIT}"
     RUN_MAKE_INSTALL: 1
   <<: *debian_sid_amd64_image
   <<: *build_job
@@ -1198,7 +1187,7 @@ gcc:tumbleweed:amd64:
   variables:
     CC: gcc
     CFLAGS: "${CFLAGS_COMMON} -DDEBUG"
-    EXTRA_CONFIGURE: "--with-libidn2 ${WITH_READLINE_READLINE}"
+    EXTRA_CONFIGURE: "--with-libidn2 ${WITH_LIBEDIT}"
   <<: *tumbleweed_latest_amd64_image
   <<: *build_job
 
index 18af2407c2e6a696d925b00ff0b8e798be7b1574..0aadcd3bc22d9060d9da48c9cc4ba945b2d59e02 100644 (file)
@@ -6,6 +6,7 @@ AM_CPPFLAGS +=                  \
        $(LIBISCCFG_CFLAGS)     \
        $(LIBIDN2_CFLAGS)       \
        $(OPENSSL_CFLAGS)       \
+       $(LIBEDIT_CFLAGS)       \
        $(LIBUV_CFLAGS)         \
        $(OPENSSL_CFLAGS)
 
@@ -15,6 +16,7 @@ LDADD +=                      \
        $(LIBDNS_LIBS)          \
        $(LIBISCCFG_LIBS)       \
        $(OPENSSL_LIBS)         \
+       $(LIBEDIT_LIBS)         \
        $(LIBIDN2_LIBS)
 
 noinst_LTLIBRARIES = libdighost.la
@@ -24,16 +26,3 @@ libdighost_la_SOURCES =              \
        dighost.c
 
 bin_PROGRAMS = dig host nslookup
-
-nslookup_CPPFLAGS =            \
-       $(AM_CPPFLAGS)
-
-nslookup_LDADD =               \
-       $(LDADD)
-
-if HAVE_READLINE
-nslookup_CPPFLAGS +=           \
-       $(READLINE_CFLAGS)
-nslookup_LDADD +=              \
-       $(READLINE_LIBS)
-endif HAVE_READLINE
index 5001c0dfeb5112a2ad43a00629288b2be589c768..a6b30183f455e52d1fce6e806b66b334bd708808 100644 (file)
@@ -24,6 +24,7 @@
 #include <isc/loop.h>
 #include <isc/netaddr.h>
 #include <isc/parseint.h>
+#include <isc/readline.h>
 #include <isc/string.h>
 #include <isc/util.h>
 #include <isc/work.h>
@@ -40,7 +41,6 @@
 #include <dns/rdatatype.h>
 
 #include "dighost.h"
-#include "readline.h"
 
 static char cmdlinebuf[COMMSIZE];
 static char *cmdline = NULL;
index 4ef15ed799e2b834f028405a29333920cadc5d77..c37189a7efff84ec4f821294d3d10f16552c1459 100644 (file)
@@ -6,7 +6,7 @@ AM_CPPFLAGS +=                  \
        $(LIBISCCFG_CFLAGS)     \
        $(GSSAPI_CFLAGS)        \
        $(KRB5_CFLAGS)          \
-       $(READLINE_CFLAGS)
+       $(LIBEDIT_CFLAGS)
 
 AM_CPPFLAGS +=                 \
        -DSESSION_KEYFILE=\"${localstatedir}/run/named/session.key\"
@@ -16,15 +16,7 @@ LDADD +=                     \
        $(LIBDNS_LIBS)          \
        $(LIBISCCFG_LIBS)       \
        $(GSSAPI_LIBS)          \
-       $(KRB5_LIBS)
-
-if HAVE_READLINE
-LDADD +=                       \
-       $(READLINE_LIBS)
-endif
+       $(KRB5_LIBS)            \
+       $(LIBEDIT_LIBS)
 
 bin_PROGRAMS = nsupdate
-
-nsupdate_SOURCES =             \
-       nsupdate.c              \
-       ../dig/readline.h
index be1d720c4a0b51f26c4f11af507ab6bf7bb85cb2..30bf9a15c36989dd1bf2433a4211b58f61192b0c 100644 (file)
@@ -40,6 +40,7 @@
 #include <isc/parseint.h>
 #include <isc/portset.h>
 #include <isc/random.h>
+#include <isc/readline.h>
 #include <isc/region.h>
 #include <isc/result.h>
 #include <isc/sockaddr.h>
@@ -93,8 +94,6 @@
 
 #endif /* HAVE_GSSAPI */
 
-#include "../dig/readline.h"
-
 #define MAXCMD  (128 * 1024)
 #define MAXWIRE         (64 * 1024)
 #define INITTEXT (2 * 1024)
index c3c16f69db3a2cbb9881ef0f602a797ac9c5192b..46de92c5ddaf51a06f10dedcb5ea6807588ca6e2 100644 (file)
@@ -886,45 +886,26 @@ AS_IF([test "$enable_tcp_fastopen" = "yes"],
 AC_CHECK_FUNCS([strlcpy strlcat strnstr])
 
 #
-# Check for readline support
-#
-
-# editline is not included in pairwise testing as the library
-# is not present in the relevant Docker image.
-#
-# GNU Readline is not included in pairwise testing as the library
-# in the relevant Docker image does not support pkg-config.
-#
-# [pairwise: --with-readline=auto, --with-readline=yes, --with-readline=libedit, --without-readline]
-AC_ARG_WITH([readline],
-           [AS_HELP_STRING([--with-readline=yes|no|libedit|readline],
-                           [specify readline library [default auto]])],
-           [], [with_readline="auto"])
-
-AS_CASE([$with_readline],
-       [no],[],
-       [auto|yes],
-       [PKG_CHECK_MODULES([READLINE], [libedit],
-                          [AC_DEFINE([HAVE_READLINE_LIBEDIT], [1], [Build with libedit support])],
-                          [PKG_CHECK_MODULES([READLINE], [libeditline],
-                                             [AC_DEFINE([HAVE_READLINE_EDITLINE], [1], [Build with editline support.])],
-                                             [PKG_CHECK_MODULES([READLINE], [readline],
-                                                                [AC_DEFINE([HAVE_READLINE_READLINE], [1], [Build with readline support.])],
-                                                                [AS_IF([test "$with_readline" = "yes"],
-                                                                       [AC_MSG_ERROR([readline support requested, but none of the libraries have been found.])])])])])],
-       [libedit],
-       [PKG_CHECK_MODULES([READLINE], [libedit],
-                          [AC_DEFINE([HAVE_READLINE_LIBEDIT], [1], [Build with libedit support])])],
-       [editline],
-       [PKG_CHECK_MODULES([READLINE], [libeditline],
-                          [AC_DEFINE([HAVE_READLINE_EDITLINE], [1], [Build with editline support])])],
-       [readline],
-       [PKG_CHECK_MODULES([READLINE], [readline],
-                          [AC_DEFINE([HAVE_READLINE_READLINE], [1], [Build with readline support])])],
-       [AC_MSG_ERROR([Unknown readline '$with_readline' library requested.])])
-AM_CONDITIONAL([HAVE_READLINE], [test -n "$READLINE_LIBS"])
-AC_SUBST([READLINE_CFLAGS])
-AC_SUBST([READLINE_LIBS])
+# Check for libedit support
+#
+# [pairwise: --with-libedit=auto, --with-libedit=yes, --without-libedit]
+AC_ARG_WITH([libedit],
+           [AS_HELP_STRING([--with-libedit=auto|yes|no],
+                           [specify libedit library [default auto]])],
+           [], [with_libedit="auto"])
+
+AS_CASE([$with_libedit],
+       [no],   [],
+       [auto], [PKG_CHECK_MODULES([LIBEDIT], [libedit],
+                                  [AC_DEFINE([HAVE_LIBEDIT], [1], [Build with libedit support])],
+                                  [:])],
+
+       [yes],  [PKG_CHECK_MODULES([LIBEDIT], [libedit],
+                                  [AC_DEFINE([HAVE_LIBEDIT], [1], [Build with libedit support])])],
+       [AC_MSG_ERROR([Specifying libedit installation path is not supported, adjust PKG_CONFIG_PATH instead])])
+AM_CONDITIONAL([HAVE_LIBEDIT], [test -n "$LIBEDIT_LIBS"])
+AC_SUBST([LIBEDIT_CFLAGS])
+AC_SUBST([LIBEDIT_LIBS])
 
 #
 # Security Stuff
index b87b82c9ce193ecd933e51d229db43c9e561ee85..bbceecb546b2adee88ec6c9bac7e19633460254c 100644 (file)
@@ -139,12 +139,10 @@ To support internationalized domain names in :iscman:`dig`, ``libidn2``
 library is installed in a nonstandard location, specify the prefix using
 ``--with-libidn2=/prefix`` or adjust ``PKG_CONFIG_PATH``.
 
-For line editing in :iscman:`nsupdate` and :iscman:`nslookup`, either the
-``readline`` (https://tiswww.case.edu/php/chet/readline/rltop.html) or
+For line editing in :iscman:`nsupdate` and :iscman:`nslookup`,
 the ``libedit`` library (https://www.thrysoee.dk/editline/) must be
 installed. If these are installed at a nonstandard location, adjust
-``PKG_CONFIG_PATH``. ``readline`` is used by default, and ``libedit``
-can be explicitly requested using ``--with-readline=libedit``.
+``PKG_CONFIG_PATH``.
 
 On some platforms it is necessary to explicitly request large file
 support to handle files bigger than 2GB. This can be done by using
index 1cdc540fb24474e5d79eb97271a54493c7f77df1..ad3d69a05ba71e053cc300004212fc4f1dd5f7a6 100644 (file)
@@ -68,6 +68,7 @@ libisc_la_HEADERS =                   \
        include/isc/radix.h             \
        include/isc/random.h            \
        include/isc/ratelimiter.h       \
+       include/isc/readline.h          \
        include/isc/refcount.h          \
        include/isc/regex.h             \
        include/isc/region.h            \
similarity index 60%
rename from bin/dig/readline.h
rename to lib/isc/include/isc/readline.h
index 5341994586f8873fbfacd8ba8f357e8fe171089b..a3979d56bbd636c478ef04c9d7436d02c4225d80 100644 (file)
 #pragma once
 
 /*
- * A little wrapper around readline(), add_history() and free() to make using
+ * A little wrapper around readline(), and add_history() to make using
  * the readline code simpler.
  */
 
-#if defined(HAVE_READLINE_LIBEDIT)
+#ifdef HAVE_LIBEDIT
+
 #include <editline/readline.h>
-#elif defined(HAVE_READLINE_EDITLINE)
-#include <editline.h>
-#elif defined(HAVE_READLINE_READLINE)
-/* Prevent deprecated functions being declared. */
-#define _FUNCTION_DEF 1
-/* Ensure rl_message() gets prototype. */
-#define USE_VARARGS   1
-#define PREFER_STDARG 1
-#include <readline/history.h>
-#include <readline/readline.h>
-#endif
-
-#if !defined(HAVE_READLINE_LIBEDIT) && !defined(HAVE_READLINE_EDITLINE) && \
-       !defined(HAVE_READLINE_READLINE)
+
+#else /* HAVE_LIBEDIT */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -55,4 +44,4 @@ readline(const char *prompt) {
 
 #define add_history(line)
 
-#endif
+#endif /* HAVE_LIBEDIT */