Potential licensing issue with libreadline
Hi,
the debian nftables package got a bug report about a potential licensing issue related to libreadline. More info here:
https://bugs.debian.org/979103 Legally problematic GPL-3+ readline dependency
This may or may not be a Debian-specific problem, but I wanted to notify you and collect your ideas before trying to work out a solution myself.
Happy new year!
Pablo Neira Ayuso
maintainerHi Arturo,
Quoted 9 lines · Arturo Borrero Gonzalez
Hi,
the debian nftables package got a bug report about a potential licensing issue related to libreadline. More info here:
https://bugs.debian.org/979103 Legally problematic GPL-3+ readline dependency
This may or may not be a Debian-specific problem, but I wanted to notify you and collect your ideas before trying to work out a solution myself.
I'm attaching a quick patch to use libeditreadline shim as suggested.
INSTALL +1 -1
@@ -16,7 +16,7 @@ Installation instructions for nftables - libgmp - - libreadline + - libedit - pkg-config
configure.ac +6 -6
@@ -68,13 +68,13 @@ AC_CHECK_LIB([gmp],[__gmpz_init], , AC_MSG_ERROR([No suitable version of libgmp AM_CONDITIONAL([BUILD_MINIGMP], [test "x$with_mini_gmp" = xyes]) AC_ARG_WITH([cli], [AS_HELP_STRING([--without-cli], - [disable interactive CLI (libreadline or linenoise support)])], - [], [with_cli=readline]) + [disable interactive CLI (libedit or linenoise support)])], + [], [with_cli=edit]) -AS_IF([test "x$with_cli" = xreadline], [ -AC_CHECK_LIB([readline], [readline], , - AC_MSG_ERROR([No suitable version of libreadline found])) -AC_DEFINE([HAVE_LIBREADLINE], [1], []) +AS_IF([test "x$with_cli" = xedit], [ +AC_CHECK_LIB([edit], [read_history], , + AC_MSG_ERROR([No suitable version of libedit found])) +AC_DEFINE([HAVE_LIBEDIT], [1], []) ], [test "x$with_cli" = xlinenoise], [ AC_CHECK_LIB([linenoise], [linenoise], ,
doc/nft.txt +1 -1
@@ -46,7 +46,7 @@ understanding of their meaning. You can get information about options by running *-i*:: *--interactive*:: - Read input from an interactive readline CLI. You can use quit to exit, or use the EOF marker, + Read input from an interactive CLI. You can use quit to exit, or use the EOF marker, normally this is CTRL-D. *-I*::
include/cli.h +1 -1
@@ -4,7 +4,7 @@#include <nftables/libnftables.h> #include <config.h> -#if defined(HAVE_LIBREADLINE ) || defined(HAVE_LIBLINENOISE ) +#if defined(HAVE_LIBEDIT ) || defined(HAVE_LIBLINENOISE )extern int cli_init (struct nft_ctx *nft);#else static inline int cli_init (struct nft_ctx *nft)
src/cli.c +11 -10
@@ -21,9 +21,9 @@#include <string.h> #include <ctype.h> #include <limits.h> -#ifdef HAVE_LIBREADLINE -#include <readline/readline.h> -#include <readline/history.h> +#ifdef HAVE_LIBEDIT +#include <editline/readline.h> +#include <editline/history.h> #else #include <linenoise.h> #endif
@@ -48,7 +48,7 @@ init_histfile(void)snprintf (histfile,sizeof (histfile),"%s/%s" , home,CMDLINE_HISTFILE ); } -#ifdef HAVE_LIBREADLINE +#ifdef HAVE_LIBEDIT static struct nft_ctx *cli_nft;static char *multiline;
@@ -72,8 +72,6 @@ static char *cli_append_multiline(char *line)if (multiline ==NULL ) { multiline = line; -rl_save_prompt (); -rl_clear_message ();rl_set_prompt (".... " ); }else { len +=strlen (multiline);
@@ -93,7 +91,7 @@ static char *cli_append_multiline(char *line)if (complete) { line = multiline; multiline =NULL ; -rl_restore_prompt (); +rl_set_prompt ("nft> " ); }return line; }
@@ -139,10 +137,13 @@ static char **cli_completion(const char *text, int start, int end)return NULL ; } +static char nft_readline_name[4 ]; +int cli_init (struct nft_ctx *nft) { cli_nft = nft; - rl_readline_name ="nft" ; +sprintf (nft_readline_name,"nft" ); + rl_readline_name = nft_readline_name; rl_instream = stdin; rl_outstream = stdout;
@@ -166,7 +167,7 @@ void cli_exit(void) write_history(histfile); } -#else /* !HAVE_LIBREADLINE */ +#else /* !HAVE_LIBEDIT */ int cli_init (struct nft_ctx *nft) {
@@ -195,4 +196,4 @@ void cli_exit(void) linenoiseHistorySave(histfile); } -#endif /* HAVE_LIBREADLINE */ +#endif /* HAVE_LIBEDIT */
src/main.c +2 -2
@@ -227,8 +227,8 @@ static void show_version(void) {const char *cli, *minigmp, *json, *xt; -#if defined(HAVE_LIBREADLINE ) - cli ="readline" ; +#if defined(HAVE_LIBEDIT ) + cli ="edit" ;#elif defined(HAVE_LIBLINENOISE ) cli ="linenoise" ;#else