From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RrMRU-0003WD-GL for garchives@archives.gentoo.org; Sun, 29 Jan 2012 04:32:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8BF80E090B; Sun, 29 Jan 2012 04:32:32 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3ABCFE0907 for ; Sun, 29 Jan 2012 04:32:32 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9E4F81B403E for ; Sun, 29 Jan 2012 04:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 1A4148004F for ; Sun, 29 Jan 2012 04:32:31 +0000 (UTC) From: "Jeremy Olexa" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jeremy Olexa" Message-ID: <54ce210f763c641c0bda088dc38e0025fb45d814.darkside@gentoo> Subject: [gentoo-commits] dev/darkside:master commit in: net-misc/openvpn/, net-misc/openvpn/files/ X-VCS-Repository: dev/darkside X-VCS-Files: net-misc/openvpn/Manifest net-misc/openvpn/files/65openvpn net-misc/openvpn/files/down.sh net-misc/openvpn/files/openvpn-2.1.conf net-misc/openvpn/files/openvpn-2.1.init net-misc/openvpn/files/openvpn-2.1_rc13-peercred.patch net-misc/openvpn/files/openvpn-2.2.2-pkcs11.patch net-misc/openvpn/files/openvpn.init net-misc/openvpn/files/up.sh net-misc/openvpn/openvpn-2.2.2.ebuild X-VCS-Directories: net-misc/openvpn/ net-misc/openvpn/files/ X-VCS-Committer: darkside X-VCS-Committer-Name: Jeremy Olexa X-VCS-Revision: 54ce210f763c641c0bda088dc38e0025fb45d814 Date: Sun, 29 Jan 2012 04:32:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b31eca13-003f-450f-8e75-9bd844490b90 X-Archives-Hash: 0edf5053376737a34ded9dcf3b1390cf commit: 54ce210f763c641c0bda088dc38e0025fb45d814 Author: Jeremy Olexa gentoo org> AuthorDate: Sun Jan 29 04:32:25 2012 +0000 Commit: Jeremy Olexa gentoo org> CommitDate: Sun Jan 29 04:32:25 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Ddev/darkside.git;a= =3Dcommit;h=3D54ce210f [net-misc/openvpn] version bump to 2.2.2, bug 383537 --- net-misc/openvpn/Manifest | 2 + net-misc/openvpn/files/65openvpn | 1 + net-misc/openvpn/files/down.sh | 33 ++++ net-misc/openvpn/files/openvpn-2.1.conf | 18 ++ net-misc/openvpn/files/openvpn-2.1.init | 133 ++++++++++++++= + .../openvpn/files/openvpn-2.1_rc13-peercred.patch | 10 ++ net-misc/openvpn/files/openvpn-2.2.2-pkcs11.patch | 36 ++++ net-misc/openvpn/files/openvpn.init | 63 +++++++ net-misc/openvpn/files/up.sh | 82 ++++++++++ net-misc/openvpn/openvpn-2.2.2.ebuild | 171 ++++++++++++++= ++++++ 10 files changed, 549 insertions(+), 0 deletions(-) diff --git a/net-misc/openvpn/Manifest b/net-misc/openvpn/Manifest new file mode 100644 index 0000000..1833126 --- /dev/null +++ b/net-misc/openvpn/Manifest @@ -0,0 +1,2 @@ +DIST openvpn-2.2.0-ipv6-20110522-1.patch.gz 36029 RMD160 a476ba5581f0920= dd5f42b2b22beeccb7ef2cbe8 SHA1 04dbcd44d825949e895d714a97e4e57617037536 S= HA256 e3b415b1dd61f7fb823231c32b40516a93efc99c2b6b52e3b9fce03d4ae45053 +DIST openvpn-2.2.2.tar.gz 911158 RMD160 60990f183bdd46933724b3bf39ba5861= ed0258a6 SHA1 992373cdf12e1b50655b13765a6d36a87cfd3ca3 SHA256 54ca8b260e2= ea3b26e84c2282ccb5f8cb149edcfd424b686d5fb22b8dbbeac00 diff --git a/net-misc/openvpn/files/65openvpn b/net-misc/openvpn/files/65= openvpn new file mode 100644 index 0000000..4ddb034 --- /dev/null +++ b/net-misc/openvpn/files/65openvpn @@ -0,0 +1 @@ +CONFIG_PROTECT=3D"/usr/share/openvpn/easy-rsa" diff --git a/net-misc/openvpn/files/down.sh b/net-misc/openvpn/files/down= .sh new file mode 100755 index 0000000..1c70db0 --- /dev/null +++ b/net-misc/openvpn/files/down.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Copyright (c) 2006-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Contributed by Roy Marples (uberlord@gentoo.org) + +# If we have a service specific script, run this now +if [ -x /etc/openvpn/"${SVCNAME}"-down.sh ] ; then + /etc/openvpn/"${SVCNAME}"-down.sh "$@" +fi + +# Restore resolv.conf to how it was +if [ "${PEER_DNS}" !=3D "no" ]; then + if [ -x /sbin/resolvconf ] ; then + /sbin/resolvconf -d "${dev}" + elif [ -e /etc/resolv.conf-"${dev}".sv ] ; then + # Important that we copy instead of move incase resolv.conf is + # a symlink and not an actual file + cp /etc/resolv.conf-"${dev}".sv /etc/resolv.conf + rm -f /etc/resolv.conf-"${dev}".sv + fi +fi + +if [ -n "${SVCNAME}" ]; then + # Re-enter the init script to start any dependant services + if /etc/init.d/"${SVCNAME}" --quiet status ; then + export IN_BACKGROUND=3Dtrue + /etc/init.d/"${SVCNAME}" --quiet stop + fi +fi + +exit 0 + +# vim: ts=3D4 : diff --git a/net-misc/openvpn/files/openvpn-2.1.conf b/net-misc/openvpn/f= iles/openvpn-2.1.conf new file mode 100644 index 0000000..72510c3 --- /dev/null +++ b/net-misc/openvpn/files/openvpn-2.1.conf @@ -0,0 +1,18 @@ +# OpenVPN automatically creates an /etc/resolv.conf (or sends it to +# resolvconf) if given DNS information by the OpenVPN server. +# Set PEER_DNS=3D"no" to stop this. +PEER_DNS=3D"yes" + +# OpenVPN can run in many modes. Most people will want the init script +# to automatically detect the mode and try and apply a good default +# configuration and setup scripts. However, there are cases where the +# OpenVPN configuration looks like a client, but it's really a peer or +# something else. DETECT_CLIENT controls this behaviour. +DETECT_CLIENT=3D"yes" + +# If DETECT_CLIENT is no and you have your own scripts to re-enter the o= penvpn +# init script (ie, it first becomes "inactive" and the script then start= s the +# script again to make it "started") then you can state this below. +# In other words, unless you understand service dependencies and are a +# competent shell scripter, don't set this. +RE_ENTER=3D"no" diff --git a/net-misc/openvpn/files/openvpn-2.1.init b/net-misc/openvpn/f= iles/openvpn-2.1.init new file mode 100755 index 0000000..d65e6f8 --- /dev/null +++ b/net-misc/openvpn/files/openvpn-2.1.init @@ -0,0 +1,133 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +VPNDIR=3D${VPNDIR:-/etc/openvpn} +VPN=3D${SVCNAME#*.} +if [ -n "${VPN}" ] && [ ${SVCNAME} !=3D "openvpn" ]; then + VPNPID=3D"/var/run/openvpn.${VPN}.pid" +else + VPNPID=3D"/var/run/openvpn.pid" +fi +VPNCONF=3D"${VPNDIR}/${VPN}.conf" + +depend() { + need localmount net + use dns + after bootmisc +} + +checkconfig() { + # Linux has good dynamic tun/tap creation + if [ $(uname -s) =3D "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available" \ + "in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + return 0 + fi + + # Other OS's don't, so we rely on a pre-configured interface + # per vpn instance + local ifname=3D$(sed -n -e 's/[[:space:]]*dev[[:space:]][[:space:]]*\([= ^[:space:]]*\).*/\1/p' "${VPNCONF}") + if [ -z ${ifname} ] ; then + eerror "You need to specify the interface that this openvpn" \ + "instance should use" \ + "by using the dev option in ${VPNCONF}" + return 1 + fi + + if ! ifconfig "${ifname}" >/dev/null 2>/dev/null ; then + # Try and create it + echo > /dev/"${ifname}" >/dev/null + fi + if ! ifconfig "${ifname}" >/dev/null 2>/dev/null ; then + eerror "${VPNCONF} requires interface ${ifname}" \ + "but that does not exist" + return 1 + fi +} + +start() { + # If we are re-called by the openvpn gentoo-up.sh script + # then we don't actually want to start openvpn + [ "${IN_BACKGROUND}" =3D "true" ] && return 0 +=09 + ebegin "Starting ${SVCNAME}" + + checkconfig || return 1 + + local args=3D"" reenter=3D${RE_ENTER:-no} + # If the config file does not specify the cd option, we do + # But if we specify it, we override the config option which we do not w= ant + if ! grep -q "^[ ]*cd[ ].*" "${VPNCONF}" ; then + args=3D"${args} --cd ${VPNDIR}" + fi +=09 + # We mark the service as inactive and then start it. + # When we get an authenticated packet from the peer then we run our scr= ipt + # which configures our DNS if any and marks us as up. + if [ "${DETECT_CLIENT:-yes}" =3D "yes" ] && \ + grep -q "^[ ]*remote[ ].*" "${VPNCONF}" ; then + reenter=3D"yes" + args=3D"${args} --up-delay --up-restart" + args=3D"${args} --script-security 2" + args=3D"${args} --up /etc/openvpn/up.sh" + args=3D"${args} --down-pre --down /etc/openvpn/down.sh" + + # Warn about setting scripts as we override them + if grep -Eq "^[ ]*(up|down)[ ].*" "${VPNCONF}" ; then + ewarn "WARNING: You have defined your own up/down scripts" + ewarn "As you're running as a client, we now force Gentoo specific" + ewarn "scripts to be run for up and down events." + ewarn "These scripts will call /etc/openvpn/${SVCNAME}-{up,down}.sh" + ewarn "where you can put your own code." + fi + + # Warn about the inability to change ip/route/dns information when + # dropping privs + if grep -q "^[ ]*user[ ].*" "${VPNCONF}" ; then + ewarn "WARNING: You are dropping root privileges!" + ewarn "As such openvpn may not be able to change ip, routing" + ewarn "or DNS configuration." + fi + else + # So we're a server. Run as openvpn unless otherwise specified + grep -q "^[ ]*user[ ].*" "${VPNCONF}" || args=3D"${args} --user open= vpn" + grep -q "^[ ]*group[ ].*" "${VPNCONF}" || args=3D"${args} --group op= envpn" + fi + + # Ensure that our scripts get the PEER_DNS variable + [ -n "${PEER_DNS}" ] && args=3D"${args} --setenv PEER_DNS ${PEER_DNS}" + + [ "${reenter}" =3D "yes" ] && mark_service_inactive "${SVCNAME}" + start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}= " \ + -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon \ + --setenv SVCNAME "${SVCNAME}" ${args} + eend $? "Check your logs to see why startup failed" +} + +stop() { + # If we are re-called by the openvpn gentoo-down.sh script + # then we don't actually want to stop openvpn + if [ "${IN_BACKGROUND}" =3D "true" ] ; then + mark_service_inactive "${SVCNAME}" + return 0 + fi + + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --quiet \ + --exec /usr/sbin/openvpn --pidfile "${VPNPID}" + eend $? +} + +# vim: set ts=3D4 : diff --git a/net-misc/openvpn/files/openvpn-2.1_rc13-peercred.patch b/net= -misc/openvpn/files/openvpn-2.1_rc13-peercred.patch new file mode 100644 index 0000000..6592cf1 --- /dev/null +++ b/net-misc/openvpn/files/openvpn-2.1_rc13-peercred.patch @@ -0,0 +1,10 @@ +--- socket.c~ 2008-11-02 01:39:00.406009999 +0100 ++++ socket.c 2008-11-02 01:39:00.406009999 +0100 +@@ -22,6 +22,7 @@ + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +=20 ++#define _GNU_SOURCE + #include "syshead.h" +=20 + #include "socket.h" diff --git a/net-misc/openvpn/files/openvpn-2.2.2-pkcs11.patch b/net-misc= /openvpn/files/openvpn-2.2.2-pkcs11.patch new file mode 100644 index 0000000..c7115cc --- /dev/null +++ b/net-misc/openvpn/files/openvpn-2.2.2-pkcs11.patch @@ -0,0 +1,36 @@ +diff --git a/easy-rsa/2.0/openssl-0.9.8.cnf b/easy-rsa/2.0/openssl-0.9.8= .cnf +index 340b8af..89602a2 100755 +--- a/easy-rsa/2.0/openssl-0.9.8.cnf ++++ b/easy-rsa/2.0/openssl-0.9.8.cnf +@@ -283,8 +283,8 @@ authorityKeyIdentifier=3Dkeyid:always,issuer:always + #pkcs11 =3D pkcs11_section +=20 + [ pkcs11_section ] +-engine_id =3D pkcs11 +-dynamic_path =3D /usr/lib/engines/engine_pkcs11.so +-MODULE_PATH =3D $ENV::PKCS11_MODULE_PATH +-PIN =3D $ENV::PKCS11_PIN +-init =3D 0 ++#engine_id =3D pkcs11 ++#dynamic_path =3D /usr/lib/engines/engine_pkcs11.so ++#MODULE_PATH =3D $ENV::PKCS11_MODULE_PATH ++#PIN =3D $ENV::PKCS11_PIN ++#init =3D 0 +diff --git a/easy-rsa/2.0/openssl-1.0.0.cnf b/easy-rsa/2.0/openssl-1.0.0= .cnf +index fa258a5..527919d 100755 +--- a/easy-rsa/2.0/openssl-1.0.0.cnf ++++ b/easy-rsa/2.0/openssl-1.0.0.cnf +@@ -278,8 +278,8 @@ authorityKeyIdentifier=3Dkeyid:always,issuer:always + #pkcs11 =3D pkcs11_section +=20 + [ pkcs11_section ] +-engine_id =3D pkcs11 +-dynamic_path =3D /usr/lib/engines/engine_pkcs11.so +-MODULE_PATH =3D $ENV::PKCS11_MODULE_PATH +-PIN =3D $ENV::PKCS11_PIN +-init =3D 0 ++#engine_id =3D pkcs11 ++#dynamic_path =3D /usr/lib/engines/engine_pkcs11.so ++#MODULE_PATH =3D $ENV::PKCS11_MODULE_PATH ++#PIN =3D $ENV::PKCS11_PIN ++#init =3D 0 diff --git a/net-misc/openvpn/files/openvpn.init b/net-misc/openvpn/files= /openvpn.init new file mode 100644 index 0000000..489ab49 --- /dev/null +++ b/net-misc/openvpn/files/openvpn.init @@ -0,0 +1,63 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +VPNDIR=3D"/etc/openvpn" +VPN=3D"${SVCNAME#*.}" +if [ -n "${VPN}" ] && [ "${SVCNAME}" !=3D "openvpn" ]; then + VPNPID=3D"/var/run/openvpn.${VPN}.pid" +else + VPNPID=3D"/var/run/openvpn.pid" +fi +VPNCONF=3D"${VPNDIR}/${VPN}.conf" + +depend() { + need localmount net + before netmount + after bootmisc +} + +checktundevice() { + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi +} + +start() { + ebegin "Starting ${SVCNAME}" + + checktundevice || return 1 + + if [ ! -e "${VPNCONF}" ]; then + eend 1 "${VPNCONF} does not exist" + return 1 + fi + + local args=3D"" + # If the config file does not specify the cd option, we do + # But if we specify it, we override the config option which we do not w= ant + if ! grep -q "^[ ]*cd[ ].*" "${VPNCONF}" ; then + args=3D"${args} --cd ${VPNDIR}" + fi + + start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}= " \ + -- --config "${VPNCONF}" --writepid "${VPNPID}" --daemon ${args} + eend $? "Check your logs to see why startup failed" +} + +stop() { + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${VPNPID}" + eend $? +} + +# vim: ts=3D4 diff --git a/net-misc/openvpn/files/up.sh b/net-misc/openvpn/files/up.sh new file mode 100755 index 0000000..4a88687 --- /dev/null +++ b/net-misc/openvpn/files/up.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# Copyright (c) 2006-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Contributed by Roy Marples (uberlord@gentoo.org) + +# Setup our resolv.conf +# Vitally important that we use the domain entry in resolv.conf so we +# can setup the nameservers are for the domain ONLY in resolvconf if +# we're using a decent dns cache/forwarder like dnsmasq and NOT nscd/lib= c. +# nscd/libc users will get the VPN nameservers before their other ones +# and will use the first one that responds - maybe the LAN ones? +# non resolvconf users just the the VPN resolv.conf + +# FIXME:- if we have >1 domain, then we have to use search :/ +# We need to add a flag to resolvconf to say +# "these nameservers should only be used for the listed search domains +# if other global nameservers are present on other interfaces" +# This however, will break compatibility with Debians resolvconf +# A possible workaround would be to just list multiple domain lines +# and try and let resolvconf handle it + +if [ "${PEER_DNS}" !=3D "no" ]; then + NS=3D + DOMAIN=3D + SEARCH=3D + i=3D1 + while true ; do + eval opt=3D\$foreign_option_${i} + [ -z "${opt}" ] && break + if [ "${opt}" !=3D "${opt#dhcp-option DOMAIN *}" ] ; then + if [ -z "${DOMAIN}" ] ; then + DOMAIN=3D"${opt#dhcp-option DOMAIN *}" + else + SEARCH=3D"${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}" + fi + elif [ "${opt}" !=3D "${opt#dhcp-option DNS *}" ] ; then + NS=3D"${NS}nameserver ${opt#dhcp-option DNS *}\n" + fi + i=3D$((${i} + 1)) + done + + if [ -n "${NS}" ] ; then + DNS=3D"# Generated by openvpn for interface ${dev}\n" + if [ -n "${SEARCH}" ] ; then + DNS=3D"${DNS}search ${DOMAIN} ${SEARCH}\n" + elif [ -n "${DOMAIN}" ]; then + DNS=3D"${DNS}domain ${DOMAIN}\n" + fi + DNS=3D"${DNS}${NS}" + if [ -x /sbin/resolvconf ] ; then + printf "${DNS}" | /sbin/resolvconf -a "${dev}" + else + # Preserve the existing resolv.conf + if [ -e /etc/resolv.conf ] ; then + cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv + fi + printf "${DNS}" > /etc/resolv.conf + chmod 644 /etc/resolv.conf + fi + fi +fi + +# Below section is Gentoo specific +# Quick summary - our init scripts are re-entrant and set the SVCNAME en= v var +# as we could have >1 openvpn service + +if [ -n "${SVCNAME}" ]; then + # If we have a service specific script, run this now + if [ -x /etc/openvpn/"${SVCNAME}"-up.sh ] ; then + /etc/openvpn/"${SVCNAME}"-up.sh "$@" + fi + + # Re-enter the init script to start any dependant services + if ! /etc/init.d/"${SVCNAME}" --quiet status ; then + export IN_BACKGROUND=3Dtrue + /etc/init.d/${SVCNAME} --quiet start + fi +fi + +exit 0 + +# vim: ts=3D4 : diff --git a/net-misc/openvpn/openvpn-2.2.2.ebuild b/net-misc/openvpn/ope= nvpn-2.2.2.ebuild new file mode 100644 index 0000000..af4c8b9 --- /dev/null +++ b/net-misc/openvpn/openvpn-2.2.2.ebuild @@ -0,0 +1,171 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/openvpn/openvpn-2.2.0-r1.ebu= ild,v 1.3 2011/07/29 08:45:05 zmedico Exp $ + +EAPI=3D4 + +inherit eutils multilib toolchain-funcs autotools flag-o-matic + +IPV6_VERSION=3D"2.2.0-ipv6-20110522-1" +DESCRIPTION=3D"OpenVPN is a robust and highly flexible tunneling applica= tion compatible with many OSes." +SRC_URI=3D"http://swupdate.openvpn.net/community/releases/${P}.tar.gz + ipv6? ( + http://www.greenie.net/ipv6/openvpn-${IPV6_VERSION}.patch.gz + )" +HOMEPAGE=3D"http://openvpn.net/" + +LICENSE=3D"GPL-2" +SLOT=3D"0" +KEYWORDS=3D"~alpha ~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc = ~x86 ~sparc-fbsd ~x86-fbsd ~x86-linux" +# ipv6 patch seems broken, ipv6 is planned for the 2.3 release +#IUSE=3D"examples iproute2 ipv6 minimal pam passwordsave selinux ssl sta= tic pkcs11 userland_BSD" +IUSE=3D"examples iproute2 minimal pam passwordsave selinux ssl static pk= cs11 userland_BSD" + +DEPEND=3D">=3Ddev-libs/lzo-1.07 + kernel_linux? ( + iproute2? ( sys-apps/iproute2[-minimal] ) !iproute2? ( sys-apps/net-to= ols ) + ) + !minimal? ( pam? ( virtual/pam ) ) + selinux? ( sec-policy/selinux-openvpn ) + ssl? ( >=3Ddev-libs/openssl-0.9.6 ) + pkcs11? ( >=3Ddev-libs/pkcs11-helper-1.05 )" +RDEPEND=3D"${DEPEND}" + +src_prepare() { + epatch "${FILESDIR}/${PN}-2.2.2-pkcs11.patch" + use ipv6 && epatch "${WORKDIR}/${PN}-${IPV6_VERSION}.patch" + sed -i \ + -e "s/gcc \${CC_FLAGS}/\${CC} \${CFLAGS} -Wall/" \ + -e "s/-shared/-shared \${LDFLAGS}/" \ + plugin/*/Makefile || die "sed failed" + if use ipv6; then + eautoreconf + fi +} + +src_configure() { + # basic.h defines a type 'bool' that conflicts with the altivec + # keyword bool which has to be fixed upstream, see bugs #293840 + # and #297854. + # For now, filter out -maltivec on ppc and append -mno-altivec, as + # -maltivec is enabled implicitly by -mcpu and similar flags. + (use ppc || use ppc64) && filter-flags -maltivec && append-flags -mno-a= ltivec + + local myconf=3D"" + + if use minimal ; then + myconf=3D"${myconf} --disable-plugins" + myconf=3D"${myconf} --disable-pkcs11" + else + myconf=3D"$(use_enable pkcs11)" + fi + + econf ${myconf} \ + $(use_enable passwordsave password-save) \ + $(use_enable ssl) \ + $(use_enable ssl crypto) \ + $(use_enable iproute2) \ + --docdir=3D"${EPREFIX}/usr/share/doc/${PF}" +} + +src_compile() { + + if use static ; then + sed -i -e '/^LIBS/s/LIBS =3D /LIBS =3D -static /' Makefile || die "sed= failed" + fi + + emake || die "make failed" + + if ! use minimal ; then + cd plugin + for i in *; do + [[ ${i} =3D=3D "README" || ${i} =3D=3D "examples" || ${i} =3D=3D "def= er" ]] && continue + [[ ${i} =3D=3D "auth-pam" ]] && ! use pam && continue + einfo "Building ${i} plugin" + emake -C "${i}" CC=3D$(tc-getCC) || die "make failed" + done + cd .. + fi +} + +src_install() { + emake DESTDIR=3D"${D}" install || die "make install failed" + + # install documentation + dodoc AUTHORS ChangeLog PORTS README + + # Install some helper scripts + keepdir /etc/openvpn + exeinto /etc/openvpn + doexe "${FILESDIR}/up.sh" || die "doexe failed" + doexe "${FILESDIR}/down.sh" || die "doexe failed" + + # Install the init script and config file + newinitd "${FILESDIR}/${PN}-2.1.init" openvpn || die "newinitd failed" + newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn || die "newconfd failed" + + # install examples, controlled by the respective useflag + if use examples ; then + # dodoc does not supportly support directory traversal, #15193 + insinto /usr/share/doc/${PF}/examples + doins -r sample-{config-files,keys,scripts} contrib + fi + + # Install plugins and easy-rsa + doenvd "${FILESDIR}/65openvpn" # config-protect easy-rsa + if ! use minimal ; then + cd easy-rsa/2.0 + make install "DESTDIR=3D${D}" "PREFIX=3D${EPREFIX}/usr/share/${PN}/eas= y-rsa" + cd ../.. + + exeinto "/usr/$(get_libdir)/${PN}" + doexe plugin/*/*.so + fi +} + +pkg_postinst() { + # Add openvpn user so openvpn servers can drop privs + # Clients should run as root so they can change ip addresses, + # dns information and other such things. + enewgroup openvpn + enewuser openvpn "" "" "" openvpn + + if [ path_exists -o "${ROOT}/etc/openvpn/*/local.conf" ] ; then + ewarn "WARNING: The openvpn init script has changed" + ewarn "" + fi + + elog "The openvpn init script expects to find the configuration file" + elog "openvpn.conf in /etc/openvpn along with any extra files it may ne= ed." + elog "" + elog "To create more VPNs, simply create a new .conf file for it and" + elog "then create a symlink to the openvpn init script from a link call= ed" + elog "openvpn.newconfname - like so" + elog " cd /etc/openvpn" + elog " ${EDITOR##*/} foo.conf" + elog " cd /etc/init.d" + elog " ln -s openvpn openvpn.foo" + elog "" + elog "You can then treat openvpn.foo as any other service, so you can" + elog "stop one vpn and start another if you need to." + + if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/d= ev/null ; then + ewarn "" + ewarn "WARNING: If you use the remote keyword then you are deemed to b= e" + ewarn "a client by our init script and as such we force up,down script= s." + ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where yo= u" + ewarn "can move your scripts to." + fi + + if ! use minimal ; then + einfo "" + einfo "plugins have been installed into /usr/$(get_libdir)/${PN}" + fi + +# if use ipv6 ; then +# einfo "" +# einfo "This build contains a community-maintained IPv6 patch." +# einfo "For more information please visit:" +# einfo "http://www.greenie.net/ipv6/openvpn.html" +# fi +}