From fd0e64fcf14d078605b0adc6bbb7cb3651708b2d Mon Sep 17 00:00:00 2001
From: Stefan Knoblich <stkn@gentoo.org>
Date: Fri, 29 Jul 2005 19:51:57 +0000
Subject: Added patch from uberlord to fix asterisk on hardened setups with ssp
 enabled, see Changelog and #100697 for more information Package-Manager:
 portage-2.0.51.19

---
 net-misc/asterisk/ChangeLog                        |  10 +-
 net-misc/asterisk/Manifest                         |   7 +-
 net-misc/asterisk/asterisk-1.0.8.ebuild            |   6 +-
 net-misc/asterisk/asterisk-1.0.9.ebuild            |   6 +-
 .../1.0.0/asterisk-1.0.9-weak-references.diff      | 229 +++++++++++++++++++++
 5 files changed, 252 insertions(+), 6 deletions(-)
 create mode 100644 net-misc/asterisk/files/1.0.0/asterisk-1.0.9-weak-references.diff

(limited to 'net-misc/asterisk')

diff --git a/net-misc/asterisk/ChangeLog b/net-misc/asterisk/ChangeLog
index 858119ff4eea..41bb988007b6 100644
--- a/net-misc/asterisk/ChangeLog
+++ b/net-misc/asterisk/ChangeLog
@@ -1,6 +1,14 @@
 # ChangeLog for net-misc/asterisk
 # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.71 2005/07/29 01:19:13 stkn Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.72 2005/07/29 19:51:57 stkn Exp $
+
+  29 Jul 2005; <stkn@gentoo.org>
+  +files/1.0.0/asterisk-1.0.9-weak-references.diff, asterisk-1.0.9.ebuild,
+  asterisk-1.0.8.ebuild:
+  Added patch to mark adsi_* functions as weak references, this fixes loading
+  of res_features.so (= asterisk startup) on ssp enabled systems. Many thanks
+  to Uberlord (Roy Marples <uberlord@gentoo.org>) for examining the problem
+  and providing a patch. Closing #100697 and #85655.
 
 *asterisk-1.0.9 (29 Jul 2005)
 
diff --git a/net-misc/asterisk/Manifest b/net-misc/asterisk/Manifest
index f0ba4fc8796d..414af0c988f8 100644
--- a/net-misc/asterisk/Manifest
+++ b/net-misc/asterisk/Manifest
@@ -1,9 +1,9 @@
 MD5 dd6c6b7f4015bd3469119952d5126a7a asterisk-1.0.6-r1.ebuild 13746
 MD5 8a58b364b0ad9e0a2f2a88365da7afd5 asterisk-1.0.5-r2.ebuild 11975
-MD5 6f63b6cbc18290f4058c77ff2da3ea28 asterisk-1.0.8.ebuild 13301
-MD5 f665860e9ed034106c9aead27811a899 asterisk-1.0.9.ebuild 13201
+MD5 0ce8670e8257054257c61b1245852df3 asterisk-1.0.8.ebuild 13481
+MD5 3a02d714a0cea48cce4aa6a1f237df63 asterisk-1.0.9.ebuild 13371
 MD5 44cf247f04cc83413fcb40ed59d0847a metadata.xml 248
-MD5 de77b5e2e5df15b70d89a5fec610aac0 ChangeLog 13582
+MD5 3896ac07e557fc2eedd2ad806ab09ca5 ChangeLog 14001
 MD5 13dc6ccd1a6df943f810c51e949c4728 asterisk-1.0.7-r1.ebuild 13360
 MD5 97ed00bdccf7c70d5fcbf37580da91c4 files/digest-asterisk-1.0.5-r2 139
 MD5 b3bbedde09faea609a0357b21eafa596 files/digest-asterisk-1.0.8 210
@@ -24,6 +24,7 @@ MD5 5e1e00b71a830e487787ce48be04ccdc files/1.0.0/asterisk-1.0.8-initgroups.diff
 MD5 1d5c7f8847a95005af3ffb0699bba20f files/1.0.0/asterisk.confd.sec 528
 MD5 f0fe0308b464c71f83cf2483388c8058 files/1.0.0/asterisk-1.0.1-linux26.diff 474
 MD5 08d718c04e911f465f867577d649d204 files/1.0.0/asterisk-1.0.5-uclibc-dns.diff 304
+MD5 8929203070b56a9d9204423cc5b3349a files/1.0.0/asterisk-1.0.9-weak-references.diff 8406
 MD5 18fb1b2e1fbf2f19e8a9a600eab4c5c8 files/1.0.0/asterisk-1.0.8-callerid.patch 631
 MD5 6a50db2ee46d4139128d0c4225ac071f files/1.0.0/asterisk-uclibc-dns.diff 433
 MD5 38064faca1838d7c57bb26293741f31b files/1.0.0/asterisk-1.0.8-hppa.patch 1274
diff --git a/net-misc/asterisk/asterisk-1.0.8.ebuild b/net-misc/asterisk/asterisk-1.0.8.ebuild
index b60bcd9fc26c..fadc49b4a127 100644
--- a/net-misc/asterisk/asterisk-1.0.8.ebuild
+++ b/net-misc/asterisk/asterisk-1.0.8.ebuild
@@ -1,6 +1,6 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.0.8.ebuild,v 1.9 2005/07/25 22:45:03 stkn Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.0.8.ebuild,v 1.10 2005/07/29 19:51:57 stkn Exp $
 
 inherit eutils perl-module
 
@@ -122,6 +122,10 @@ src_unpack() {
 	# hppa patch for gsm codec
 	epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-hppa.patch
 
+	# mark adsi functions as weak references, things will blow
+	# on hardened otherwise (bug #100697 and possibly #85655)
+	epatch ${FILESDIR}/1.0.0/${PN}-1.0.9-weak-references.diff
+
 	# gsm codec still uses -fomit-frame-pointer, and other codecs have their
 	# own flags. We only change the arch.
 	sed -i  -e "s:^OPTIMIZE+=.*:OPTIMIZE=${CFLAGS}:" \
diff --git a/net-misc/asterisk/asterisk-1.0.9.ebuild b/net-misc/asterisk/asterisk-1.0.9.ebuild
index bbf56e6f9488..ef7314fe1d4d 100644
--- a/net-misc/asterisk/asterisk-1.0.9.ebuild
+++ b/net-misc/asterisk/asterisk-1.0.9.ebuild
@@ -1,6 +1,6 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.0.9.ebuild,v 1.1 2005/07/29 01:19:13 stkn Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.0.9.ebuild,v 1.2 2005/07/29 19:51:57 stkn Exp $
 
 inherit eutils perl-module
 
@@ -122,6 +122,10 @@ src_unpack() {
 	# hppa patch for gsm codec
 	epatch ${FILESDIR}/1.0.0/${PN}-1.0.8-hppa.patch
 
+	# mark adsi functions as weak references, things will blow
+	# on hardened otherwise (bug #100697 and #85655)
+	epatch ${FILESDIR}/1.0.0/${PN}-1.0.9-weak-references.diff
+
 	# gsm codec still uses -fomit-frame-pointer, and other codecs have their
 	# own flags. We only change the arch.
 	sed -i  -e "s:^OPTIMIZE+=.*:OPTIMIZE=${CFLAGS}:" \
diff --git a/net-misc/asterisk/files/1.0.0/asterisk-1.0.9-weak-references.diff b/net-misc/asterisk/files/1.0.0/asterisk-1.0.9-weak-references.diff
new file mode 100644
index 000000000000..dfb46cc73908
--- /dev/null
+++ b/net-misc/asterisk/files/1.0.0/asterisk-1.0.9-weak-references.diff
@@ -0,0 +1,229 @@
+diff -ru ../asterisk-1.0.9/include/asterisk/adsi.h ./include/asterisk/adsi.h
+--- ../asterisk-1.0.9/include/asterisk/adsi.h	2005-07-29 13:22:39.003302450 +0100
++++ ./include/asterisk/adsi.h	2005-07-29 13:41:41.000000000 +0100
+@@ -118,11 +118,14 @@
+  * Returns 0 on success (or adsi unavailable) and -1 on hangup
+  * 
+  */
+-extern int adsi_channel_init(struct ast_channel *chan);
++extern int adsi_channel_init(struct ast_channel *chan)
++	__attribute__ ((weak));
+ 
+-extern int adsi_begin_download(struct ast_channel *chan, char *service, char *fdn, char *sec, int version);
++extern int adsi_begin_download(struct ast_channel *chan, char *service, char *fdn, char *sec, int version)
++	__attribute__ ((weak));
+ 
+-extern int adsi_end_download(struct ast_channel *chan);
++extern int adsi_end_download(struct ast_channel *chan)
++	__attribute__ ((weak));
+ 
+ //! Restore ADSI initialization (for applications that play with ADSI
+ //  and want to restore it to normal.  If you touch "INFO" then you
+@@ -133,7 +136,8 @@
+  * Returns 0 on success (or adsi unavailable) and -1 on hangup
+  *
+  */
+-extern int adsi_channel_restore(struct ast_channel *chan);
++extern int adsi_channel_restore(struct ast_channel *chan)
++	__attribute__ ((weak));
+ 
+ //! Display some stuff on the screen
+ /*!
+@@ -145,7 +149,8 @@
+  * Return 0 on success (or adsi unavailable) and -1 on hangup
+  *
+  */
+-extern int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice);
++extern int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
++	__attribute__ ((weak));
+ 
+ //! Check if scripts for a given app are already loaded.  Version may be -1
+ //  if any version is okay, or 0-255 for a specific version.
+@@ -158,18 +163,23 @@
+  * Returns 0 if scripts is not loaded or not an ADSI CPE.  Returns -1
+  * on hangup.  Returns 1 if script already loaded.
+  */
+-extern int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data);
+-extern int adsi_unload_session(struct ast_channel *chan);
++extern int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
++	__attribute__ ((weak));
++extern int adsi_unload_session(struct ast_channel *chan)
++	__attribute__ ((weak));
+ 
+ /* ADSI Layer 2 transmission functions */
+-extern int adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype);
+-extern int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
++extern int adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
++	__attribute__ ((weak));
++extern int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
++	__attribute__ ((weak));
+ 
+ //! Read some encoded DTMF data.  
+ /*!
+  * Returns number of bytes received
+  */
+-extern int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen);
++extern int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
++	__attribute__ ((weak));
+ 
+ /* ADSI Layer 3 creation functions */
+ 
+@@ -183,14 +193,17 @@
+  *
+  */
+ 
+-extern int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver);
++extern int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
++	__attribute__ ((weak));
+ 
+ //! Build Query CPE ID of equipment */
+ /*!
+  *  Returns number of bytes added to message
+  */
+-extern int adsi_query_cpeid(unsigned char *buf);
+-extern int adsi_query_cpeinfo(unsigned char *buf);
++extern int adsi_query_cpeid(unsigned char *buf)
++	__attribute__ ((weak));
++extern int adsi_query_cpeinfo(unsigned char *buf)
++	__attribute__ ((weak));
+ 
+ //! Get CPE ID from an attached ADSI compatible CPE.
+ /*!
+@@ -198,9 +211,11 @@
+  * or -1 on hangup, or 0 if there was no hangup but it failed to find the
+  * device ID.  Returns to voice mode if "voice" is non-zero.
+  */
+-extern int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
++extern int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
++	__attribute__ ((weak));
+ 
+-extern int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
++extern int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
++	__attribute__ ((weak));
+ 
+ //! Begin an ADSI script download */
+ /*!
+@@ -214,7 +229,8 @@
+  *
+  */
+ 
+-extern int adsi_download_connect(unsigned char *buf, unsigned char *service, unsigned char *fdn, unsigned char *sec, int ver);
++extern int adsi_download_connect(unsigned char *buf, unsigned char *service, unsigned char *fdn, unsigned char *sec, int ver)
++	__attribute__ ((weak));
+ 
+ //! Disconnects a running session
+ /*!
+@@ -223,7 +239,8 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_disconnect_session(unsigned char *buf);
++extern int adsi_disconnect_session(unsigned char *buf)
++	__attribute__ ((weak));
+ 
+ //! Disconnects (and hopefully saves) a downloaded script
+ /*!
+@@ -232,7 +249,8 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_download_disconnect(unsigned char *buf);
++extern int adsi_download_disconnect(unsigned char *buf)
++	__attribute__ ((weak));
+ 
+ //! Puts CPE in data mode...
+ /*!
+@@ -241,9 +259,12 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_data_mode(unsigned char *buf);
+-extern int adsi_clear_soft_keys(unsigned char *buf);
+-extern int adsi_clear_screen(unsigned char *buf);
++extern int adsi_data_mode(unsigned char *buf)
++	__attribute__ ((weak));
++extern int adsi_clear_soft_keys(unsigned char *buf)
++	__attribute__ ((weak));
++extern int adsi_clear_screen(unsigned char *buf)
++	__attribute__ ((weak));
+ 
+ //! Puts CPE in voice mode...
+ /*!
+@@ -253,14 +274,16 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_voice_mode(unsigned char *buf, int when);
++extern int adsi_voice_mode(unsigned char *buf, int when)
++	__attribute__ ((weak));
+ 
+ //! Returns non-zero if Channel does or might support ADSI
+ /*!
+  * \param chan Channel to check
+  *
+  */
+-extern int adsi_available(struct ast_channel *chan);
++extern int adsi_available(struct ast_channel *chan)
++	__attribute__ ((weak));
+ 
+ //! Loads a line of info into the display */
+ /*!
+@@ -276,7 +299,8 @@
+  *
+  */
+ 
+-extern int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, unsigned char *col1, unsigned char *col2);
++extern int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, unsigned char *col1, unsigned char *col2)
++	__attribute__ ((weak));
+ 
+ //! Sets the current line and page */
+ /*!
+@@ -288,7 +312,8 @@
+  *
+  */
+ 
+-extern int adsi_set_line(unsigned char *buf, int page, int line);
++extern int adsi_set_line(unsigned char *buf, int page, int line)
++	__attribute__ ((weak));
+ 
+ //! Creates "load soft key" parameters
+ /*! 
+@@ -302,7 +327,8 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_load_soft_key(unsigned char *buf, int key, unsigned char *llabel, unsigned char *slabel, unsigned char *ret, int data);
++extern int adsi_load_soft_key(unsigned char *buf, int key, unsigned char *llabel, unsigned char *slabel, unsigned char *ret, int data)
++	__attribute__ ((weak));
+ 
+ //! Set which soft keys should be displayed
+ /*!
+@@ -313,7 +339,8 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_set_keys(unsigned char *buf, unsigned char *keys);
++extern int adsi_set_keys(unsigned char *buf, unsigned char *keys)
++	__attribute__ ((weak));
+ 
+ //! Set input information
+ /*!
+@@ -327,7 +354,8 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just);
++extern int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
++	__attribute__ ((weak));
+ 
+ //! Set input format
+ /*!
+@@ -341,5 +369,6 @@
+  * Returns number of bytes added to buffer or -1 on error.
+  *
+  */
+-extern int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, unsigned char *format1, unsigned char *format2);
++extern int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, unsigned char *format1, unsigned char *format2)
++	__attribute__ ((weak));
+ #endif
+Only in ../asterisk-1.0.9: .version
-- 
cgit v1.2.3-65-gdbad