Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > 0485dac50d728597b235eced591783b3 > files > 3

asterisk-1.6.2.18-1.fc13.src.rpm

From b7448140ce8a86ec812e28b99d62ba59371d8c5c Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff@ocjtech.us>
Date: Fri, 5 Mar 2010 14:10:52 -0600
Subject: [PATCH 3/7] Allow linking/building against an external libedit.

The Asterisk tarball includes a very old copy of the editline library
that manages command line history and editing.  Fedora (and several
other distributions) highly discourage this practice because if there
are security problems (or even just severe bugs) in the library it can
be very difficult to track down all instances of the library.  This
patch adds the option of building/linking against an external copy of
the libedit library.
---
 build_tools/menuselect-deps.in |    1 +
 configure.ac                   |   22 ++++++++++++++++++++++
 main/Makefile                  |    8 +++++---
 main/cli.c                     |    3 ++-
 makeopts.in                    |    4 ++++
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index dba1b8f..2c2466f 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -23,6 +23,7 @@ ISDNNET=@PBX_ISDNNET@
 IXJUSER=@PBX_IXJUSER@
 JACK=@PBX_JACK@
 LDAP=@PBX_LDAP@
+LIBEDIT=@PBX_LIBEDIT@
 LTDL=@PBX_LTDL@
 LUA=@PBX_LUA@
 MISDN=@PBX_MISDN@
diff --git a/configure.ac b/configure.ac
index 0dbc3f5..072d670 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,6 +320,7 @@ AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux], [isdnnet])
 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
 AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
 AST_LIBCURL_CHECK_CONFIG([], [7.10.1])
+AST_EXT_LIB_SETUP([LIBEDIT], [NetBSD Editline library], [libedit])
 AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2])
 AST_EXT_LIB_SETUP([LTDL], [libtool], [ltdl])
 AST_EXT_LIB_SETUP([LUA], [Lua], [lua])
@@ -1895,6 +1896,27 @@ AC_SUBST(PBX_GTK2)
 AC_SUBST(GTK2_INCLUDE)
 AC_SUBST(GTK2_LIB)
 
+PBX_LIBEDIT=0
+LIBEDIT_INCLUDE=-Ieditline/readline
+LIBEDIT_LIB=
+LIBEDIT_OBJ=editline/libedit.a
+if test  "${USE_LIBEDIT}" != "no"; then
+   AC_CHECK_TOOL(PKGCONFIG, pkg-config, no)
+   if test "${PKGCONFIG}" != "no"; then
+      if ${PKGCONFIG} --exists libedit; then
+         LIBEDIT_INCLUDE=$(${PKGCONFIG} libedit --cflags)
+         LIBEDIT_LIB=$(${PKGCONFIG} libedit --libs)
+         LIBEDIT_OBJ=
+         PBX_LIBEDIT=1
+         AC_DEFINE([HAVE_LIBEDIT], 1, [Define if your system has the NetBSD Editline libraries.])
+      fi
+   fi
+fi
+AC_SUBST(PBX_LIBEDIT)
+AC_SUBST(LIBEDIT_INCLUDE)
+AC_SUBST(LIBEDIT_LIB)
+AC_SUBST(LIBEDIT_OBJ)
+
 # build a GENERIC_ODBC result based on the presence of either UnixODBC (preferred)
 # or iODBC
 
diff --git a/main/Makefile b/main/Makefile
index 9ba16fe..f898799 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -149,6 +149,8 @@ testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
 	$(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm
 	rm ast_expr2.o ast_expr2f.o 
 
+cli.o: ASTCFLAGS+=$(LIBEDIT_INCLUDE)
+
 ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
 http.o: _ASTCFLAGS+=$(GMIME_INCLUDE)
 endif
@@ -181,13 +183,13 @@ ifneq ($(findstring ENABLE_UPLOADS,$(MENUSELECT_CFLAGS)),)
 GMIMELDFLAGS+=$(GMIME_LIB)
 endif
 
-$(MAIN_TGT): $(OBJS) editline/libedit.a db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
+$(MAIN_TGT): $(OBJS) $(LIBEDIT_OBJ) db1-ast/libdb1.a $(AST_EMBED_LDSCRIPTS)
 	@$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS)
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
 ifneq ($(findstring chan_h323,$(MENUSELECT_CHANNELS)),)
-	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS)
+	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
 else
-	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS)
+	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(H323LDFLAGS) $^ buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(H323LDLIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB)
 endif
 	$(CMD_PREFIX) $(ASTTOPDIR)/build_tools/strip_nonapi $@ || rm $@
 
diff --git a/main/cli.c b/main/cli.c
index b2638cc..096178c 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -36,6 +36,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <pwd.h>
 #include <grp.h>
 
+#include <readline.h>
+
 #include "asterisk/cli.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/module.h"
@@ -44,7 +46,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 #include "asterisk/lock.h"
-#include "editline/readline/readline.h"
 #include "asterisk/threadstorage.h"
 
 /*!
diff --git a/makeopts.in b/makeopts.in
index 83ae26b..143a12e 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -265,3 +265,7 @@ TINFO_DIR=@TINFO_DIR@
 # if poll is not present, let the makefile know.
 POLL_AVAILABLE=@HAS_POLL@
 TIMERFD_INCLUDE=@TIMERFD_INCLUDE@
+
+LIBEDIT_INCLUDE=@LIBEDIT_INCLUDE@
+LIBEDIT_LIB=@LIBEDIT_LIB@
+LIBEDIT_OBJ=@LIBEDIT_OBJ@
-- 
1.7.4.4