Blame SOURCES/0109-multipathd-replace-libreadline-with-libedit.patch

988ed2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
988ed2
From: Martin Wilck <mwilck@suse.com>
988ed2
Date: Fri, 12 Aug 2022 18:58:15 +0200
988ed2
Subject: [PATCH] multipathd: replace libreadline with libedit
988ed2
988ed2
Linking multipathd with libreadline may cause a license conflict,
988ed2
because libreadline is licensed under GPL-3.0-or-later, and
988ed2
libmultipath contains several files under GPL-2.0.
988ed2
988ed2
See:
988ed2
   https://github.com/opensvc/multipath-tools/issues/36
988ed2
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=979095
988ed2
   https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility
988ed2
988ed2
Replace the readline functionality with libedit, which comes under
988ed2
a BSD license. The readline library can still be enabled (e.g. for
988ed2
binaries not intended to be distributed) by running
988ed2
"make READLINE=libreadline".
988ed2
988ed2
Signed-off-by: Martin Wilck <mwilck@suse.com>
988ed2
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
988ed2
---
988ed2
 Makefile.inc        |  5 +++++
988ed2
 multipathd/Makefile | 11 ++++++++++-
988ed2
 multipathd/cli.c    |  5 +++++
988ed2
 multipathd/uxclnt.c |  6 ++++++
988ed2
 4 files changed, 26 insertions(+), 1 deletion(-)
988ed2
988ed2
diff --git a/Makefile.inc b/Makefile.inc
988ed2
index 25c16f4e..d471f045 100644
988ed2
--- a/Makefile.inc
988ed2
+++ b/Makefile.inc
988ed2
@@ -14,6 +14,11 @@
988ed2
 #
988ed2
 # Uncomment to disable dmevents polling support
988ed2
 # ENABLE_DMEVENTS_POLL = 0
988ed2
+#
988ed2
+# Readline library to use, libedit or libreadline
988ed2
+# Caution: Using libreadline may make the multipathd binary undistributable,
988ed2
+# see https://github.com/opensvc/multipath-tools/issues/36
988ed2
+READLINE = libedit
988ed2
 
988ed2
 ifeq ($(TOPDIR),)
988ed2
 	TOPDIR	= ..
988ed2
diff --git a/multipathd/Makefile b/multipathd/Makefile
988ed2
index 835edd93..4874ec3a 100644
988ed2
--- a/multipathd/Makefile
988ed2
+++ b/multipathd/Makefile
988ed2
@@ -15,7 +15,16 @@ CFLAGS += $(BIN_CFLAGS) -I$(multipathdir) -I$(mpathpersistdir) \
988ed2
 LDFLAGS += $(BIN_LDFLAGS)
988ed2
 LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \
988ed2
 	   -L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \
988ed2
-	   -ldevmapper -lreadline
988ed2
+	   -ldevmapper
988ed2
+
988ed2
+ifeq ($(READLINE),libedit)
988ed2
+CFLAGS += -DUSE_LIBEDIT
988ed2
+LIBDEPS += -ledit
988ed2
+endif
988ed2
+ifeq ($(READLINE),libreadline)
988ed2
+CFLAGS += -DUSE_LIBREADLINE
988ed2
+LIBDEPS += -lreadline
988ed2
+endif
988ed2
 
988ed2
 ifdef SYSTEMD
988ed2
 	CFLAGS += -DUSE_SYSTEMD=$(SYSTEMD)
988ed2
diff --git a/multipathd/cli.c b/multipathd/cli.c
988ed2
index bdc9fb10..85d73dfb 100644
988ed2
--- a/multipathd/cli.c
988ed2
+++ b/multipathd/cli.c
988ed2
@@ -11,7 +11,12 @@
988ed2
 #include "parser.h"
988ed2
 #include "util.h"
988ed2
 #include "version.h"
988ed2
+#ifdef USE_LIBEDIT
988ed2
+#include <editline/readline.h>
988ed2
+#endif
988ed2
+#ifdef USE_LIBREADLINE
988ed2
 #include <readline/readline.h>
988ed2
+#endif
988ed2
 
988ed2
 #include "mpath_cmd.h"
988ed2
 #include "cli.h"
988ed2
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
988ed2
index f16a7309..2c17d8fc 100644
988ed2
--- a/multipathd/uxclnt.c
988ed2
+++ b/multipathd/uxclnt.c
988ed2
@@ -16,8 +16,14 @@
988ed2
 #include <sys/socket.h>
988ed2
 #include <sys/un.h>
988ed2
 #include <poll.h>
988ed2
+
988ed2
+#ifdef USE_LIBEDIT
988ed2
+#include <editline/readline.h>
988ed2
+#endif
988ed2
+#ifdef USE_LIBREADLINE
988ed2
 #include <readline/readline.h>
988ed2
 #include <readline/history.h>
988ed2
+#endif
988ed2
 
988ed2
 #include "mpath_cmd.h"
988ed2
 #include "uxsock.h"