ipsec-tools-0.8.2-r5.ebuild 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="6"
  4. inherit flag-o-matic autotools linux-info pam systemd
  5. DESCRIPTION="A port of KAME's IPsec utilities to the Linux-2.6 IPsec implementation"
  6. HOMEPAGE="http://ipsec-tools.sourceforge.net/"
  7. SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
  8. LICENSE="BSD GPL-2"
  9. SLOT="0"
  10. KEYWORDS="amd64 arm ~ia64 ~mips ppc ppc64 x86"
  11. IUSE="hybrid idea ipv6 kerberos ldap libressl nat pam rc5 readline selinux stats"
  12. CDEPEND="
  13. !libressl? ( dev-libs/openssl:0 )
  14. libressl? ( dev-libs/libressl )
  15. kerberos? ( virtual/krb5 )
  16. ldap? ( net-nds/openldap )
  17. pam? ( sys-libs/pam )
  18. readline? ( sys-libs/readline:0= )
  19. selinux? ( sys-libs/libselinux )"
  20. DEPEND="${CDEPEND}
  21. >=sys-kernel/linux-headers-2.6.30"
  22. RDEPEND="${CDEPEND}
  23. selinux? ( sec-policy/selinux-ipsec )
  24. "
  25. pkg_preinst() {
  26. if has_version "<${CATEGORY}/${PN}-0.8.0-r5" ; then
  27. ewarn
  28. ewarn "\033[1;33m**************************************************\033[00m"
  29. ewarn
  30. if ! has_version "net-vpn/strongswan" &&
  31. ! has_version "net-misc/openswan" &&
  32. ! has_version "net-vpn/libreswan"; then
  33. ewarn "We found an earlier version of ${PN} installed."
  34. ewarn "As of ${PN}-0.8.0-r5, the old configuration file,"
  35. ewarn "ipsec.conf, has been changed to ipsec-tools.conf to avoid"
  36. ewarn "a conflict with net-vpn/strongswan; bug #436144. We will"
  37. ewarn "rename this file for you with this upgrade. However, if"
  38. ewarn "you later downgrade, you'll have to rename the file to"
  39. ewarn "its orignal manually or change /etc/conf.d/racoon to point"
  40. ewarn "to the new file."
  41. if [[ -f /etc/ipsec.conf && ! -f /etc/ipsec-tools.conf ]] ; then
  42. mv /etc/ipsec.conf /etc/ipsec-tools.conf
  43. else
  44. ewarn
  45. ewarn "Oops! I can't move ipsec.conf to ipsec-tools.conf!"
  46. ewarn "Either the former doesn't exist or the later does and"
  47. ewarn "I won't clobber it. Please fix this situation manually."
  48. fi
  49. else
  50. ewarn "You had both an earlier version of ${PN} and"
  51. ewarn "net-vpn/strongswan installed. I can't tell whether"
  52. ewarn "the configuration file, ipsec.conf, belongs to one"
  53. ewarn "package or the other due to a file conflict; bug #436144."
  54. ewarn "The current version of ${PN} uses ipsec-tools.conf"
  55. ewarn "as its configuration file, as will future versions."
  56. ewarn "Please fix this situation manually."
  57. fi
  58. ewarn
  59. ewarn "\033[1;33m**************************************************\033[00m"
  60. ewarn
  61. fi
  62. }
  63. pkg_setup() {
  64. linux-info_pkg_setup
  65. get_version
  66. if linux_config_exists && kernel_is -ge 2 6 19; then
  67. ewarn
  68. ewarn "\033[1;33m**************************************************\033[00m"
  69. ewarn
  70. ewarn "Checking kernel configuration in /usr/src/linux or"
  71. ewarn "or /proc/config.gz for compatibility with ${PN}."
  72. ewarn "Here are the potential problems:"
  73. ewarn
  74. local nothing="1"
  75. # Check options for all flavors of IPSec
  76. local msg=""
  77. for i in XFRM_USER NET_KEY; do
  78. if ! linux_chkconfig_present ${i}; then
  79. msg="${msg} ${i}"
  80. fi
  81. done
  82. if [[ ! -z "$msg" ]]; then
  83. nothing="0"
  84. ewarn
  85. ewarn "ALL IPSec may fail. CHECK:"
  86. ewarn "${msg}"
  87. fi
  88. # Check unencrypted IPSec
  89. if ! linux_chkconfig_present CRYPTO_NULL; then
  90. nothing="0"
  91. ewarn
  92. ewarn "Unencrypted IPSec may fail. CHECK:"
  93. ewarn " CRYPTO_NULL"
  94. fi
  95. # Check IPv4 IPSec
  96. msg=""
  97. for i in \
  98. INET_IPCOMP INET_AH INET_ESP \
  99. INET_XFRM_MODE_TRANSPORT \
  100. INET_XFRM_MODE_TUNNEL \
  101. INET_XFRM_MODE_BEET
  102. do
  103. if ! linux_chkconfig_present ${i}; then
  104. msg="${msg} ${i}"
  105. fi
  106. done
  107. if [[ ! -z "$msg" ]]; then
  108. nothing="0"
  109. ewarn
  110. ewarn "IPv4 IPSec may fail. CHECK:"
  111. ewarn "${msg}"
  112. fi
  113. # Check IPv6 IPSec
  114. if use ipv6; then
  115. msg=""
  116. for i in INET6_IPCOMP INET6_AH INET6_ESP \
  117. INET6_XFRM_MODE_TRANSPORT \
  118. INET6_XFRM_MODE_TUNNEL \
  119. INET6_XFRM_MODE_BEET
  120. do
  121. if ! linux_chkconfig_present ${i}; then
  122. msg="${msg} ${i}"
  123. fi
  124. done
  125. if [[ ! -z "$msg" ]]; then
  126. nothing="0"
  127. ewarn
  128. ewarn "IPv6 IPSec may fail. CHECK:"
  129. ewarn "${msg}"
  130. fi
  131. fi
  132. # Check IPSec behind NAT
  133. if use nat; then
  134. if ! linux_chkconfig_present NETFILTER_XT_MATCH_POLICY; then
  135. nothing="0"
  136. ewarn
  137. ewarn "IPSec behind NAT may fail. CHECK:"
  138. ewarn " NETFILTER_XT_MATCH_POLICY"
  139. fi
  140. fi
  141. if [[ $nothing == "1" ]]; then
  142. ewarn "NO PROBLEMS FOUND"
  143. fi
  144. ewarn
  145. ewarn "WARNING: If your *configured* and *running* kernel"
  146. ewarn "differ either now or in the future, then these checks"
  147. ewarn "may lead to misleading results."
  148. ewarn
  149. ewarn "\033[1;33m**************************************************\033[00m"
  150. ewarn
  151. else
  152. eerror
  153. eerror "\033[1;31m**************************************************\033[00m"
  154. eerror "Make sure that your *running* kernel is/will be >=2.6.19."
  155. eerror "Building ${PN} now, assuming that you know what you're doing."
  156. eerror "\033[1;31m**************************************************\033[00m"
  157. eerror
  158. fi
  159. }
  160. src_prepare() {
  161. # fix for bug #124813
  162. sed -i 's:-Werror::g' "${S}"/configure.ac || die
  163. # fix for building with gcc-4.6
  164. sed -i 's: -R: -Wl,-R:' "${S}"/configure.ac || die
  165. eapply "${FILESDIR}/${PN}-def-psk.patch"
  166. eapply "${FILESDIR}/${PN}-include-vendoridh.patch"
  167. eapply "${FILESDIR}"/${PN}-0.8.0-sysctl.patch #425770
  168. eapply "${FILESDIR}"/${PN}-CVE-2015-4047.patch
  169. AT_M4DIR="${S}" eautoreconf
  170. eapply_user
  171. }
  172. src_configure() {
  173. #--with-{libiconv,libradius} lead to "Broken getaddrinfo()"
  174. #--enable-samode-unspec is not supported in linux
  175. local myconf
  176. myconf="--with-kernel-headers=/usr/include \
  177. --enable-adminport \
  178. --enable-dependency-tracking \
  179. --enable-dpd \
  180. --enable-frag \
  181. --without-libiconv \
  182. --without-libradius \
  183. --disable-samode-unspec \
  184. $(use_enable idea) \
  185. $(use_enable ipv6) \
  186. $(use_enable kerberos gssapi) \
  187. $(use_with ldap libldap) \
  188. $(use_enable nat natt) \
  189. $(use_with pam libpam) \
  190. $(use_enable rc5) \
  191. $(use_with readline) \
  192. $(use_enable selinux security-context) \
  193. $(use_enable stats)"
  194. use nat && myconf="${myconf} --enable-natt-versions=yes"
  195. # enable mode-cfg and xauth support
  196. if use pam; then
  197. myconf="${myconf} --enable-hybrid"
  198. else
  199. myconf="${myconf} $(use_enable hybrid)"
  200. fi
  201. econf ${myconf}
  202. }
  203. src_install() {
  204. emake DESTDIR="${D}" install
  205. keepdir /var/lib/racoon
  206. newconfd "${FILESDIR}"/racoon.conf.d-r2 racoon
  207. newinitd "${FILESDIR}"/racoon.init.d-r3 racoon
  208. systemd_dounit "${FILESDIR}/ipsec-tools.service"
  209. systemd_dounit "${FILESDIR}/racoon.service"
  210. use pam && newpamd "${FILESDIR}"/racoon.pam.d racoon
  211. insinto /etc
  212. doins "${FILESDIR}"/ipsec-tools.conf
  213. insinto /etc/racoon
  214. doins "${FILESDIR}"/racoon.conf
  215. doins "${FILESDIR}"/psk.txt
  216. chmod 400 "${D}"/etc/racoon/psk.txt
  217. dodoc ChangeLog README NEWS
  218. dodoc -r src/racoon/samples
  219. dodoc -r src/racoon/doc
  220. docinto samples
  221. newdoc src/setkey/sample.cf ipsec-tools.conf
  222. }
  223. pkg_postinst() {
  224. if use nat; then
  225. elog
  226. elog "You have enabled the nat traversal functionnality."
  227. elog "Nat versions wich are enabled by default are 00,02,rfc"
  228. elog "you can find those drafts in the CVS repository:"
  229. elog "cvs -d anoncvs@anoncvs.netbsd.org:/cvsroot co ipsec-tools"
  230. elog
  231. elog "If you feel brave enough and you know what you are"
  232. elog "doing, you can consider emerging this ebuild with"
  233. elog "EXTRA_ECONF=\"--enable-natt-versions=08,07,06\""
  234. elog
  235. fi
  236. if use ldap; then
  237. elog
  238. elog "You have enabled ldap support with {$PN}."
  239. elog "The man page does NOT contain any information on it yet."
  240. elog "Consider using a more recent version or CVS."
  241. elog
  242. fi
  243. elog
  244. elog "Please have a look in /usr/share/doc/${P} and visit"
  245. elog "http://www.netbsd.org/Documentation/network/ipsec/"
  246. elog "to find more information on how to configure this tool."
  247. elog
  248. }