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

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