commit: 296b6c10efa3a16e29b6d895dcda15f06776bbe2 Author: orbea <orbea <AT> riseup <DOT> net> AuthorDate: Sun Sep 3 17:10:30 2023 +0000 Commit: orbea <orbea <AT> riseup <DOT> net> CommitDate: Sun Sep 3 17:10:30 2023 +0000 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=296b6c10
net-vpn/openvpn: new package Signed-off-by: orbea <orbea <AT> riseup.net> net-vpn/openvpn/Manifest | 4 + net-vpn/openvpn/files/down.sh | 33 ++++ net-vpn/openvpn/files/openvpn-2.1.conf | 18 ++ net-vpn/openvpn/files/openvpn-2.1.init | 134 ++++++++++++++ .../openvpn-2.5.0-auth-pam-missing-header.patch | 12 ++ .../openvpn-2.5.2-detect-python-rst2man.patch | 14 ++ net-vpn/openvpn/files/openvpn-2.5.2-libressl.patch | 147 +++++++++++++++ net-vpn/openvpn/files/openvpn-2.5.7-libressl.patch | 37 ++++ net-vpn/openvpn/files/up.sh | 100 +++++++++++ net-vpn/openvpn/metadata.xml | 28 +++ net-vpn/openvpn/openvpn-2.5.2-r3.ebuild | 199 +++++++++++++++++++++ net-vpn/openvpn/openvpn-2.5.6-r1.ebuild | 198 ++++++++++++++++++++ net-vpn/openvpn/openvpn-2.5.7-r1.ebuild | 195 ++++++++++++++++++++ net-vpn/openvpn/openvpn-2.6.4.ebuild | 197 ++++++++++++++++++++ 14 files changed, 1316 insertions(+) diff --git a/net-vpn/openvpn/Manifest b/net-vpn/openvpn/Manifest new file mode 100644 index 0000000..00d1421 --- /dev/null +++ b/net-vpn/openvpn/Manifest @@ -0,0 +1,4 @@ +DIST openvpn-2.5.2.tar.xz 1134644 BLAKE2B 59aa0c540894de4cfb37ad4c3139eb69a35d317e3de490f71b185a979989c1253221091a30bfb2ee5243fcfae190605e9787051de079eee79e57bd63392c42d5 SHA512 ae2cac00ae4b9e06e7e70b268ed47d36bbb45409650175e507d5bfa12b0a4f24bccc64f2494d1563f9269c8076d0f753a492f01ea33ce376ba00b7cdcb5c7bd0 +DIST openvpn-2.5.6.tar.xz 1150352 BLAKE2B 509821eca9d40c5579700e05e560b906ddee5abb0c51a9a210e2e998cdd9606f734d43d3bec8c473cc4f0aaa1e265e7f05202aa606247ebde8844c0243165fac SHA512 f0f0600df013431af804ace70ea86ac064917acdeaad3759b5d5eaa4a8dc3738d6da6df4c16bbb23443e3493487541cb8b10b89f9f0b40a17caa6e6fc46e0adb +DIST openvpn-2.5.7.tar.xz 1150476 BLAKE2B e8d24a8be8ff97072ef3b76dbec15cd6e7097ebe99f680d759f213cb5643d7b4a29664d2a96e6efe1d6ee858a6d6b3f23c6d12cf74f202fbe8cc48642f18dba6 SHA512 9a3234b479f5bab12b8c3af7691f175f8cd32f2929dd27efc16e96e14dbb8e07421e623869ad5ffc2d7e65f2266817d1583723033f3646b9913b10ec6d014b44 +DIST openvpn-2.6.4.tar.gz 1861178 BLAKE2B 584fc3950732d6a1db417811f6e330a154537207f6c9543ab03b1c1a886a98a0aee7d1649055a9f7944555ae8865602be15fd8e23b67258917f1adebde050099 SHA512 903ac41691c26e8e4ad65c9b6fb5e75db2caf2e4079d3c4cb61a44e51be9991508f53a1dd8b4b863b4ac86088ad1a705d22131df1e25612560c9f4276d8190ec diff --git a/net-vpn/openvpn/files/down.sh b/net-vpn/openvpn/files/down.sh new file mode 100644 index 0000000..1c70db0 --- /dev/null +++ b/net-vpn/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 (uberl...@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}" != "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=true + /etc/init.d/"${SVCNAME}" --quiet stop + fi +fi + +exit 0 + +# vim: ts=4 : diff --git a/net-vpn/openvpn/files/openvpn-2.1.conf b/net-vpn/openvpn/files/openvpn-2.1.conf new file mode 100644 index 0000000..72510c3 --- /dev/null +++ b/net-vpn/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="no" to stop this. +PEER_DNS="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="yes" + +# If DETECT_CLIENT is no and you have your own scripts to re-enter the openvpn +# init script (ie, it first becomes "inactive" and the script then starts 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="no" diff --git a/net-vpn/openvpn/files/openvpn-2.1.init b/net-vpn/openvpn/files/openvpn-2.1.init new file mode 100644 index 0000000..3af33f5 --- /dev/null +++ b/net-vpn/openvpn/files/openvpn-2.1.init @@ -0,0 +1,134 @@ +#!/sbin/openrc-run +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +VPNDIR=${VPNDIR:-/etc/openvpn} +VPN=${SVCNAME#*.} +if [ -n "${VPN}" ] && [ ${SVCNAME} != "openvpn" ]; then + VPNPID="/run/openvpn.${VPN}.pid" +else + VPNPID="/run/openvpn.pid" +fi +VPNCONF="${VPNDIR}/${VPN}.conf" + +depend() { + need localmount net + use dns + after bootmisc +} + +checkconfig() { + # Linux has good dynamic tun/tap creation + if [ $(uname -s) = "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=$(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}" = "true" ] && return 0 + + ebegin "Starting ${SVCNAME}" + + checkconfig || return 1 + + local args="" reenter=${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 want + if ! grep -q "^[ ]*cd[ ].*" "${VPNCONF}" ; then + args="${args} --cd ${VPNDIR}" + fi + + # We mark the service as inactive and then start it. + # When we get an authenticated packet from the peer then we run our script + # which configures our DNS if any and marks us as up. + if [ "${DETECT_CLIENT:-yes}" = "yes" ] && \ + grep -q "^[ ]*remote[ ].*" "${VPNCONF}" ; then + reenter="yes" + args="${args} --up-delay --up-restart" + args="${args} --script-security 2" + args="${args} --up /etc/openvpn/up.sh" + args="${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="${args} --user openvpn" + grep -q "^[ ]*group[ ].*" "${VPNCONF}" || args="${args} --group openvpn" + fi + + # Ensure that our scripts get the PEER_DNS variable + [ -n "${PEER_DNS}" ] && args="${args} --setenv PEER_DNS ${PEER_DNS}" + + [ "${reenter}" = "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}" = "true" ] ; then + mark_service_inactive "${SVCNAME}" + return 0 + fi + + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --stop --quiet \ + --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \ + -- --config "${VPNCONF}" + eend $? +} + +# vim: set ts=4 : diff --git a/net-vpn/openvpn/files/openvpn-2.5.0-auth-pam-missing-header.patch b/net-vpn/openvpn/files/openvpn-2.5.0-auth-pam-missing-header.patch new file mode 100644 index 0000000..2e48bd6 --- /dev/null +++ b/net-vpn/openvpn/files/openvpn-2.5.0-auth-pam-missing-header.patch @@ -0,0 +1,12 @@ +diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pam.c +index f537652e..29306310 100644 +--- a/src/plugins/auth-pam/auth-pam.c ++++ b/src/plugins/auth-pam/auth-pam.c +@@ -47,6 +47,7 @@ + #include <fcntl.h> + #include <signal.h> + #include <syslog.h> ++#include <limits.h> + #include "utils.h" + + #include <openvpn-plugin.h> diff --git a/net-vpn/openvpn/files/openvpn-2.5.2-detect-python-rst2man.patch b/net-vpn/openvpn/files/openvpn-2.5.2-detect-python-rst2man.patch new file mode 100644 index 0000000..d2060bb --- /dev/null +++ b/net-vpn/openvpn/files/openvpn-2.5.2-detect-python-rst2man.patch @@ -0,0 +1,14 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -376,8 +376,8 @@ AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path + # + AC_ARG_VAR([RST2MAN], [path to rst2man utility]) + AC_ARG_VAR([RST2HTML], [path to rst2html utility]) +-AC_CHECK_PROGS([RST2MAN], [rst2man]) +-AC_CHECK_PROGS([RST2HTML], [rst2html]) ++AC_CHECK_PROGS([RST2MAN], [rst2man rst2man.py]) ++AC_CHECK_PROGS([RST2HTML], [rst2html rst2html.py]) + AM_CONDITIONAL([HAVE_PYDOCUTILS], [test "${RST2MAN}" -a "${RST2HTML}"]) + + # Set -std=c99 unless user already specified a -std= + diff --git a/net-vpn/openvpn/files/openvpn-2.5.2-libressl.patch b/net-vpn/openvpn/files/openvpn-2.5.2-libressl.patch new file mode 100644 index 0000000..6ac7382 --- /dev/null +++ b/net-vpn/openvpn/files/openvpn-2.5.2-libressl.patch @@ -0,0 +1,147 @@ +commit 0df2261da192eac74d1c53e99db0ed3f49278986 +Author: Arne Schwabe <a...@rfc2549.org> +Date: Tue Oct 19 20:31:08 2021 +0200 + + Add --with-openssl-engine autoconf option (auto|yes|no) + + This allows to select engine support at configure time. For OpenSSL 1.1 the + default is not changed and we detect if engine support is available. + + Engine support is deprecated in OpenSSL 3.0 and for OpenSSL 3.0 the default + is to disable engine support as engine support is deprecated and generates + compiler warnings which in turn also break -Werror. + + By using --with-openssl-engine=no or --with-openssl-engine=yes engine + support can be forced on or off. If it is enabled but not detected an + error will be thown. + + This commit cleans up the configure logic a bit and removes the + ENGINE_cleanup checks as we can just assume that it will be also + available as macro or function if the other engine functions are + available. Before the cleanup we would only check for the existance + of engine.h if ENGINE_cleanup was not found. + + Signed-off-by: Arne Schwabe <a...@rfc2549.org> + Acked-by: Max Fillinger <maximilian.fillin...@foxcrypto.com> + Message-Id: <20211019183127.614175-3-a...@rfc2549.org> + URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23000.html + Signed-off-by: Gert Doering <g...@greenie.muc.de> + +diff --git a/configure.ac b/configure.ac +index a37dc762..e0f9c332 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -267,6 +267,18 @@ AC_ARG_ENABLE( + [enable_wolfssl_options_h="yes"] + ) + ++AC_ARG_WITH( ++ [openssl-engine], ++ [AS_HELP_STRING([--with-openssl-engine], [enable engine support with OpenSSL. Default enabled for OpenSSL < 3.0, auto,yes,no @<:@default=auto@:>@])], ++ [ ++ case "${withval}" in ++ auto|yes|no) ;; ++ *) AC_MSG_ERROR([bad value ${withval} for --with-engine]) ;; ++ esac ++ ], ++ [with_openssl_engine="auto"] ++) ++ + AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@]) + if test -n "${PLUGINDIR}"; then + plugindir="${PLUGINDIR}" +@@ -800,22 +812,44 @@ if test "${with_crypto_library}" = "openssl"; then + [AC_MSG_ERROR([openssl check failed])] + ) + +- have_openssl_engine="yes" +- AC_CHECK_FUNCS( +- [ \ ++ if test "${with_openssl_engine}" = "auto"; then ++ AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [[ ++ #include <openssl/opensslv.h> ++ ]], ++ [[ ++ /* Version encoding: MNNFFPPS - see opensslv.h for details */ ++ #if OPENSSL_VERSION_NUMBER >= 0x30000000L ++ #error Engine supported disabled by default in OpenSSL 3.0+ ++ #endif ++ ]] ++ )], ++ [have_openssl_engine="yes"], ++ [have_openssl_engine="no"] ++ ) ++ if test "${have_openssl_engine}" = "yes"; then ++ AC_CHECK_FUNCS( ++ [ \ + ENGINE_load_builtin_engines \ + ENGINE_register_all_complete \ +- ENGINE_cleanup \ +- ], +- , +- [have_openssl_engine="no"; break] +- ) +- if test "${have_openssl_engine}" = "no"; then +- AC_CHECK_DECL( [ENGINE_cleanup], [have_openssl_engine="yes"],, +- [[ +- #include <openssl/engine.h> +- ]] ++ ], ++ , ++ [have_openssl_engine="no"; break] ++ ) ++ fi ++ else ++ have_openssl_engine="${with_openssl_engine}" ++ if test "${have_openssl_engine}" = "yes"; then ++ AC_CHECK_FUNCS( ++ [ \ ++ ENGINE_load_builtin_engines \ ++ ENGINE_register_all_complete \ ++ ], ++ , ++ [AC_MSG_ERROR([OpenSSL engine support not found])] + ) ++ fi + fi + if test "${have_openssl_engine}" = "yes"; then + AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [OpenSSL engine support available]) +https://sourceforge.net/p/openvpn/mailman/openvpn-devel/thread/20230903095545.0f6d9d03%40Akita/#msg37891128 + +From d6700ec0f5af2522bb4eb136d3760f5b1445c9d1 Mon Sep 17 00:00:00 2001 +From: orbea <or...@riseup.net> +Date: Sat, 2 Sep 2023 23:06:22 -0700 +Subject: [PATCH] configure: disable engines if OPENSSL_NO_ENGINE is defined + +Starting with LibreSSL 3.8.1 the engines have been removed which causes +the OpenVPN build to fail. This can be solved during configure by +checking if OPENSSL_NO_ENGINE is defined in opensslconf.h. +--- + configure.ac | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 2f65cbd5..1adfb9d4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -927,11 +927,17 @@ if test "${with_crypto_library}" = "openssl"; then + [AC_LANG_PROGRAM( + [[ + #include <openssl/opensslv.h> ++ #include <openssl/opensslconf.h> + ]], + [[ + /* Version encoding: MNNFFPPS - see opensslv.h for details */ + #if OPENSSL_VERSION_NUMBER >= 0x30000000L +- #error Engine supported disabled by default in OpenSSL 3.0+ ++ #error Engine support disabled by default in OpenSSL 3.0+ ++ #endif ++ ++ /* BoringSSL and LibreSSL >= 3.8.1 removed engine support */ ++ #ifdef OPENSSL_NO_ENGINE ++ #error Engine support disabled by default in openssl/opensslconf.h + #endif + ]] + )], diff --git a/net-vpn/openvpn/files/openvpn-2.5.7-libressl.patch b/net-vpn/openvpn/files/openvpn-2.5.7-libressl.patch new file mode 100644 index 0000000..5abe955 --- /dev/null +++ b/net-vpn/openvpn/files/openvpn-2.5.7-libressl.patch @@ -0,0 +1,37 @@ +https://sourceforge.net/p/openvpn/mailman/openvpn-devel/thread/20230903095545.0f6d9d03%40Akita/#msg37891128 + +From d6700ec0f5af2522bb4eb136d3760f5b1445c9d1 Mon Sep 17 00:00:00 2001 +From: orbea <or...@riseup.net> +Date: Sat, 2 Sep 2023 23:06:22 -0700 +Subject: [PATCH] configure: disable engines if OPENSSL_NO_ENGINE is defined + +Starting with LibreSSL 3.8.1 the engines have been removed which causes +the OpenVPN build to fail. This can be solved during configure by +checking if OPENSSL_NO_ENGINE is defined in opensslconf.h. +--- + configure.ac | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 2f65cbd5..1adfb9d4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -927,11 +927,17 @@ if test "${with_crypto_library}" = "openssl"; then + [AC_LANG_PROGRAM( + [[ + #include <openssl/opensslv.h> ++ #include <openssl/opensslconf.h> + ]], + [[ + /* Version encoding: MNNFFPPS - see opensslv.h for details */ + #if OPENSSL_VERSION_NUMBER >= 0x30000000L +- #error Engine supported disabled by default in OpenSSL 3.0+ ++ #error Engine support disabled by default in OpenSSL 3.0+ ++ #endif ++ ++ /* BoringSSL and LibreSSL >= 3.8.1 removed engine support */ ++ #ifdef OPENSSL_NO_ENGINE ++ #error Engine support disabled by default in openssl/opensslconf.h + #endif + ]] + )], diff --git a/net-vpn/openvpn/files/up.sh b/net-vpn/openvpn/files/up.sh new file mode 100644 index 0000000..6ce82d6 --- /dev/null +++ b/net-vpn/openvpn/files/up.sh @@ -0,0 +1,100 @@ +#!/bin/sh +# Copyright (c) 2006-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Contributed by Roy Marples (uberl...@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/libc. +# 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 + +min_route() { + local n=1 + local m + local r + + eval m="\$route_metric_$n" + while [ -n "${m}" ]; do + if [ -z "$r" ] || [ "$r" -gt "$m" ]; then + r="$m" + fi + n="$(($n+1))" + eval m="\$route_metric_$n" + done + + echo "$r" +} + +if [ "${PEER_DNS}" != "no" ]; then + NS= + DOMAIN= + SEARCH= + i=1 + while true ; do + eval opt=\$foreign_option_${i} + [ -z "${opt}" ] && break + if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then + if [ -z "${DOMAIN}" ] ; then + DOMAIN="${opt#dhcp-option DOMAIN *}" + else + SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}" + fi + elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then + NS="${NS}nameserver ${opt#dhcp-option DNS *}\n" + fi + i=$((${i} + 1)) + done + + if [ -n "${NS}" ] ; then + DNS="# Generated by openvpn for interface ${dev}\n" + if [ -n "${SEARCH}" ] ; then + DNS="${DNS}search ${DOMAIN} ${SEARCH}\n" + elif [ -n "${DOMAIN}" ]; then + DNS="${DNS}domain ${DOMAIN}\n" + fi + DNS="${DNS}${NS}" + if [ -x /sbin/resolvconf ] ; then + metric="$(min_route)" + printf "${DNS}" | /sbin/resolvconf -a "${dev}" ${metric:+-m ${metric}} + 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 env 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=true + /etc/init.d/${SVCNAME} --quiet start + fi +fi + +exit 0 + +# vim: ts=4 : diff --git a/net-vpn/openvpn/metadata.xml b/net-vpn/openvpn/metadata.xml new file mode 100644 index 0000000..f3e8394 --- /dev/null +++ b/net-vpn/openvpn/metadata.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>chutz...@gentoo.org</email> + <name>Patrick McLean</name> + </maintainer> + <maintainer type="person"> + <email>willi...@gentoo.org</email> + <name>William Hubbs</name> + </maintainer> + <longdescription>OpenVPN is an easy-to-use, robust and highly +configurable VPN daemon which can be used to securely link two or more +networks using an encrypted tunnel.</longdescription> + <use> + <flag name="dco">Enable support for kernel data channel offload</flag> + <flag name="down-root">Enable the down-root plugin</flag> + <flag name="iproute2">Enabled iproute2 support instead of net-tools</flag> + <flag name="mbedtls">Use mbed TLS as the backend crypto library</flag> + <flag name="openssl">Use OpenSSL as the backend crypto library</flag> + <flag name="pkcs11">Enable PKCS#11 smartcard support</flag> + <flag name="plugins">Enable the OpenVPN plugin system</flag> + </use> + <upstream> + <remote-id type="cpe">cpe:/a:openvpn:openvpn</remote-id> + <remote-id type="github">OpenVPN/openvpn</remote-id> + </upstream> +</pkgmetadata> diff --git a/net-vpn/openvpn/openvpn-2.5.2-r3.ebuild b/net-vpn/openvpn/openvpn-2.5.2-r3.ebuild new file mode 100644 index 0000000..02be010 --- /dev/null +++ b/net-vpn/openvpn/openvpn-2.5.2-r3.ebuild @@ -0,0 +1,199 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit autotools flag-o-matic systemd linux-info tmpfiles + +DESCRIPTION="Robust and highly flexible tunneling application compatible with many OSes" +HOMEPAGE="https://openvpn.net/" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://github.com/OpenVPN/${PN}.git" + EGIT_SUBMODULES=(-cmocka) + + inherit git-r3 +else + SRC_URI="https://build.openvpn.net/downloads/releases/${P}.tar.xz" + KEYWORDS="~alpha amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv ~sparc x86" +fi + +LICENSE="GPL-2" +SLOT="0" + +IUSE="down-root examples inotify iproute2 +lz4 +lzo mbedtls +openssl" +IUSE+=" pam pkcs11 +plugins selinux systemd test" + +RESTRICT="!test? ( test )" +REQUIRED_USE=" + ^^ ( openssl mbedtls ) + pkcs11? ( !mbedtls ) + !plugins? ( !pam !down-root ) + inotify? ( plugins ) +" + +CDEPEND=" + kernel_linux? ( + iproute2? ( sys-apps/iproute2[-minimal] ) + ) + lz4? ( app-arch/lz4 ) + lzo? ( >=dev-libs/lzo-1.07 ) + mbedtls? ( net-libs/mbedtls:= ) + openssl? ( >=dev-libs/openssl-0.9.8:0= ) + pam? ( sys-libs/pam ) + pkcs11? ( >=dev-libs/pkcs11-helper-1.11 ) + systemd? ( sys-apps/systemd ) +" + +BDEPEND="virtual/pkgconfig" + +DEPEND="${CDEPEND} + test? ( dev-util/cmocka ) +" +RDEPEND="${CDEPEND} + acct-group/openvpn + acct-user/openvpn + selinux? ( sec-policy/selinux-openvpn ) +" + +if [[ ${PV} = "9999" ]]; then + BDEPEND+=" dev-python/docutils" +fi + +PATCHES=( + "${FILESDIR}"/openvpn-2.5.0-auth-pam-missing-header.patch + "${FILESDIR}"/openvpn-2.5.2-detect-python-rst2man.patch + "${FILESDIR}"/openvpn-2.5.2-libressl.patch +) + +pkg_setup() { + local CONFIG_CHECK="~TUN" + linux-info_pkg_setup +} + +src_prepare() { + default + + eautoreconf +} + +src_configure() { + local -a myeconfargs + + if ! use mbedtls; then + myeconfargs+=( + $(use_enable pkcs11) + ) + fi + + myeconfargs+=( + $(use_enable inotify async-push) + --with-crypto-library=$(usex mbedtls mbedtls openssl) + $(use_enable lz4) + $(use_enable lzo) + $(use_enable plugins) + $(use_enable iproute2) + $(use_enable pam plugin-auth-pam) + $(use_enable down-root plugin-down-root) + $(use_enable systemd) + ) + + SYSTEMD_UNIT_DIR=$(systemd_get_systemunitdir) \ + TMPFILES_DIR="/usr/lib/tmpfiles.d" \ + IPROUTE=$(usex iproute2 '/bin/ip' '') \ + econf "${myeconfargs[@]}" +} + +src_test() { + local -x RUN_SUDO=false + + elog "Running top-level tests" + emake check + + pushd tests/unit_tests &>/dev/null || die + elog "Running unit tests" + emake check + popd &>/dev/null || die +} + +src_install() { + default + + find "${ED}/usr" -name '*.la' -delete || die + + # install documentation + dodoc AUTHORS ChangeLog PORTS README README.IPv6 + + # Install some helper scripts + keepdir /etc/openvpn + exeinto /etc/openvpn + doexe "${FILESDIR}/up.sh" + doexe "${FILESDIR}/down.sh" + + # Install the init script and config file + newinitd "${FILESDIR}/${PN}-2.1.init" openvpn + newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn + + # install examples, controlled by the respective useflag + if use examples ; then + # (is the below comment relevant anymore?) + ## dodoc does not supportly support directory traversal, #15193 + docinto examples + dodoc -r sample contrib + fi + + # https://bugs.gentoo.org/755680#c3 + doman doc/openvpn.8 +} + +pkg_postinst() { + tmpfiles_process openvpn.conf + + if use x64-macos ; then + elog "You might want to install tuntaposx for TAP interface support:" + elog "http://tuntaposx.sourceforge.net" + fi + + if systemd_is_booted || has_version sys-apps/systemd ; then + elog "In order to use OpenVPN with systemd please use the correct systemd service file." + elog "" + elog "server:" + elog "" + elog "- Place your server configuration file in /etc/openvpn/server" + elog "- Use the openvpn-server@.service like so" + elog "systemctl start openvpn-server@{Server-config}" + elog "" + elog "client:" + elog "" + elog "- Place your client configuration file in /etc/openvpn/client" + elog "- Use the openvpn-client@.service like so:" + elog "systemctl start openvpn-client@{Client-config}" + else + elog "The openvpn init script expects to find the configuration file" + elog "openvpn.conf in /etc/openvpn along with any extra files it may need." + 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 called" + 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." + fi + + if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/dev/null ; then + ewarn "" + ewarn "WARNING: If you use the remote keyword then you are deemed to be" + ewarn "a client by our init script and as such we force up,down scripts." + ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where you" + ewarn "can move your scripts to." + fi + + if use plugins ; then + einfo "" + einfo "plugins have been installed into /usr/$(get_libdir)/${PN}/plugins" + fi +} diff --git a/net-vpn/openvpn/openvpn-2.5.6-r1.ebuild b/net-vpn/openvpn/openvpn-2.5.6-r1.ebuild new file mode 100644 index 0000000..9bd9396 --- /dev/null +++ b/net-vpn/openvpn/openvpn-2.5.6-r1.ebuild @@ -0,0 +1,198 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit autotools flag-o-matic systemd linux-info tmpfiles + +DESCRIPTION="Robust and highly flexible tunneling application compatible with many OSes" +HOMEPAGE="https://openvpn.net/" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://github.com/OpenVPN/${PN}.git" + EGIT_SUBMODULES=(-cmocka) + + inherit git-r3 +else + SRC_URI="https://build.openvpn.net/downloads/releases/${P}.tar.xz" + KEYWORDS="~alpha amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv ~sparc x86" +fi + +LICENSE="GPL-2" +SLOT="0" + +IUSE="down-root examples inotify iproute2 +lz4 +lzo mbedtls +openssl" +IUSE+=" pam pkcs11 +plugins selinux systemd test" + +RESTRICT="!test? ( test )" +REQUIRED_USE=" + ^^ ( openssl mbedtls ) + pkcs11? ( !mbedtls ) + !plugins? ( !pam !down-root ) + inotify? ( plugins ) +" + +CDEPEND=" + kernel_linux? ( + iproute2? ( sys-apps/iproute2[-minimal] ) + ) + lz4? ( app-arch/lz4 ) + lzo? ( >=dev-libs/lzo-1.07 ) + mbedtls? ( net-libs/mbedtls:= ) + openssl? ( >=dev-libs/openssl-0.9.8:0= ) + pam? ( sys-libs/pam ) + pkcs11? ( >=dev-libs/pkcs11-helper-1.11 ) + systemd? ( sys-apps/systemd ) +" + +BDEPEND="virtual/pkgconfig" + +DEPEND="${CDEPEND} + test? ( dev-util/cmocka ) +" +RDEPEND="${CDEPEND} + acct-group/openvpn + acct-user/openvpn + selinux? ( sec-policy/selinux-openvpn ) +" + +if [[ ${PV} = "9999" ]]; then + BDEPEND+=" dev-python/docutils" +fi + +PATCHES=( + "${FILESDIR}"/openvpn-2.5.0-auth-pam-missing-header.patch + "${FILESDIR}"/openvpn-2.5.2-libressl.patch +) + +pkg_setup() { + local CONFIG_CHECK="~TUN" + linux-info_pkg_setup +} + +src_prepare() { + default + + eautoreconf +} + +src_configure() { + local -a myeconfargs + + if ! use mbedtls; then + myeconfargs+=( + $(use_enable pkcs11) + ) + fi + + myeconfargs+=( + $(use_enable inotify async-push) + --with-crypto-library=$(usex mbedtls mbedtls openssl) + $(use_enable lz4) + $(use_enable lzo) + $(use_enable plugins) + $(use_enable iproute2) + $(use_enable pam plugin-auth-pam) + $(use_enable down-root plugin-down-root) + $(use_enable systemd) + ) + + SYSTEMD_UNIT_DIR=$(systemd_get_systemunitdir) \ + TMPFILES_DIR="/usr/lib/tmpfiles.d" \ + IPROUTE=$(usex iproute2 '/bin/ip' '') \ + econf "${myeconfargs[@]}" +} + +src_test() { + local -x RUN_SUDO=false + + elog "Running top-level tests" + emake check + + pushd tests/unit_tests &>/dev/null || die + elog "Running unit tests" + emake check + popd &>/dev/null || die +} + +src_install() { + default + + find "${ED}/usr" -name '*.la' -delete || die + + # install documentation + dodoc AUTHORS ChangeLog PORTS README README.IPv6 + + # Install some helper scripts + keepdir /etc/openvpn + exeinto /etc/openvpn + doexe "${FILESDIR}/up.sh" + doexe "${FILESDIR}/down.sh" + + # Install the init script and config file + newinitd "${FILESDIR}/${PN}-2.1.init" openvpn + newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn + + # install examples, controlled by the respective useflag + if use examples ; then + # (is the below comment relevant anymore?) + ## dodoc does not supportly support directory traversal, #15193 + docinto examples + dodoc -r sample contrib + fi + + # https://bugs.gentoo.org/755680#c3 + doman doc/openvpn.8 +} + +pkg_postinst() { + tmpfiles_process openvpn.conf + + if use x64-macos ; then + elog "You might want to install tuntaposx for TAP interface support:" + elog "http://tuntaposx.sourceforge.net" + fi + + if systemd_is_booted || has_version sys-apps/systemd ; then + elog "In order to use OpenVPN with systemd please use the correct systemd service file." + elog "" + elog "server:" + elog "" + elog "- Place your server configuration file in /etc/openvpn/server" + elog "- Use the openvpn-server@.service like so" + elog "systemctl start openvpn-server@{Server-config}" + elog "" + elog "client:" + elog "" + elog "- Place your client configuration file in /etc/openvpn/client" + elog "- Use the openvpn-client@.service like so:" + elog "systemctl start openvpn-client@{Client-config}" + else + elog "The openvpn init script expects to find the configuration file" + elog "openvpn.conf in /etc/openvpn along with any extra files it may need." + 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 called" + 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." + fi + + if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/dev/null ; then + ewarn "" + ewarn "WARNING: If you use the remote keyword then you are deemed to be" + ewarn "a client by our init script and as such we force up,down scripts." + ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where you" + ewarn "can move your scripts to." + fi + + if use plugins ; then + einfo "" + einfo "plugins have been installed into /usr/$(get_libdir)/${PN}/plugins" + fi +} diff --git a/net-vpn/openvpn/openvpn-2.5.7-r1.ebuild b/net-vpn/openvpn/openvpn-2.5.7-r1.ebuild new file mode 100644 index 0000000..205f6ce --- /dev/null +++ b/net-vpn/openvpn/openvpn-2.5.7-r1.ebuild @@ -0,0 +1,195 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit autotools flag-o-matic systemd linux-info tmpfiles + +DESCRIPTION="Robust and highly flexible tunneling application compatible with many OSes" +HOMEPAGE="https://openvpn.net/" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://github.com/OpenVPN/${PN}.git" + EGIT_SUBMODULES=(-cmocka) + + inherit git-r3 +else + SRC_URI="https://build.openvpn.net/downloads/releases/${P}.tar.xz" + KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ppc ppc64 ~riscv ~sparc x86" +fi + +LICENSE="GPL-2" +SLOT="0" + +IUSE="down-root examples inotify iproute2 +lz4 +lzo mbedtls +openssl" +IUSE+=" pam pkcs11 +plugins selinux systemd test" + +RESTRICT="!test? ( test )" +REQUIRED_USE=" + ^^ ( openssl mbedtls ) + pkcs11? ( !mbedtls ) + !plugins? ( !pam !down-root ) + inotify? ( plugins ) +" + +CDEPEND=" + kernel_linux? ( + iproute2? ( sys-apps/iproute2[-minimal] ) + ) + lz4? ( app-arch/lz4 ) + lzo? ( >=dev-libs/lzo-1.07 ) + mbedtls? ( net-libs/mbedtls:= ) + openssl? ( >=dev-libs/openssl-0.9.8:0= ) + pam? ( sys-libs/pam ) + pkcs11? ( >=dev-libs/pkcs11-helper-1.11 ) + systemd? ( sys-apps/systemd ) +" + +BDEPEND="virtual/pkgconfig" + +DEPEND="${CDEPEND} + test? ( dev-util/cmocka ) +" +RDEPEND="${CDEPEND} + acct-group/openvpn + acct-user/openvpn + selinux? ( sec-policy/selinux-openvpn ) +" + +PATCHES=( "${FILESDIR}"/openvpn-2.5.7-libressl.patch ) + +if [[ ${PV} = "9999" ]]; then + BDEPEND+=" dev-python/docutils" +fi + +pkg_setup() { + local CONFIG_CHECK="~TUN" + linux-info_pkg_setup +} + +src_prepare() { + default + + eautoreconf +} + +src_configure() { + local -a myeconfargs + + if ! use mbedtls; then + myeconfargs+=( + $(use_enable pkcs11) + ) + fi + + myeconfargs+=( + $(use_enable inotify async-push) + --with-crypto-library=$(usex mbedtls mbedtls openssl) + $(use_enable lz4) + $(use_enable lzo) + $(use_enable plugins) + $(use_enable iproute2) + $(use_enable pam plugin-auth-pam) + $(use_enable down-root plugin-down-root) + $(use_enable systemd) + ) + + SYSTEMD_UNIT_DIR=$(systemd_get_systemunitdir) \ + TMPFILES_DIR="/usr/lib/tmpfiles.d" \ + IPROUTE=$(usex iproute2 '/bin/ip' '') \ + econf "${myeconfargs[@]}" +} + +src_test() { + local -x RUN_SUDO=false + + elog "Running top-level tests" + emake check + + pushd tests/unit_tests &>/dev/null || die + elog "Running unit tests" + emake check + popd &>/dev/null || die +} + +src_install() { + default + + find "${ED}/usr" -name '*.la' -delete || die + + # install documentation + dodoc AUTHORS ChangeLog PORTS README README.IPv6 + + # Install some helper scripts + keepdir /etc/openvpn + exeinto /etc/openvpn + doexe "${FILESDIR}/up.sh" + doexe "${FILESDIR}/down.sh" + + # Install the init script and config file + newinitd "${FILESDIR}/${PN}-2.1.init" openvpn + newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn + + # install examples, controlled by the respective useflag + if use examples ; then + # (is the below comment relevant anymore?) + ## dodoc does not supportly support directory traversal, #15193 + docinto examples + dodoc -r sample contrib + fi + + # https://bugs.gentoo.org/755680#c3 + doman doc/openvpn.8 +} + +pkg_postinst() { + tmpfiles_process openvpn.conf + + if use x64-macos ; then + elog "You might want to install tuntaposx for TAP interface support:" + elog "http://tuntaposx.sourceforge.net" + fi + + if systemd_is_booted || has_version sys-apps/systemd ; then + elog "In order to use OpenVPN with systemd please use the correct systemd service file." + elog "" + elog "server:" + elog "" + elog "- Place your server configuration file in /etc/openvpn/server" + elog "- Use the openvpn-server@.service like so" + elog "systemctl start openvpn-server@{Server-config}" + elog "" + elog "client:" + elog "" + elog "- Place your client configuration file in /etc/openvpn/client" + elog "- Use the openvpn-client@.service like so:" + elog "systemctl start openvpn-client@{Client-config}" + else + elog "The openvpn init script expects to find the configuration file" + elog "openvpn.conf in /etc/openvpn along with any extra files it may need." + 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 called" + 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." + fi + + if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/dev/null ; then + ewarn "" + ewarn "WARNING: If you use the remote keyword then you are deemed to be" + ewarn "a client by our init script and as such we force up,down scripts." + ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where you" + ewarn "can move your scripts to." + fi + + if use plugins ; then + einfo "" + einfo "plugins have been installed into /usr/$(get_libdir)/${PN}/plugins" + fi +} diff --git a/net-vpn/openvpn/openvpn-2.6.4.ebuild b/net-vpn/openvpn/openvpn-2.6.4.ebuild new file mode 100644 index 0000000..170b907 --- /dev/null +++ b/net-vpn/openvpn/openvpn-2.6.4.ebuild @@ -0,0 +1,197 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools systemd linux-info tmpfiles + +DESCRIPTION="Robust and highly flexible tunneling application compatible with many OSes" +HOMEPAGE="https://openvpn.net/" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://github.com/OpenVPN/${PN}.git" + inherit git-r3 +else + SRC_URI="https://build.openvpn.net/downloads/releases/${P}.tar.gz" + KEYWORDS="amd64 ~arm ~arm64 ~loong ~ppc ppc64 ~riscv x86" +fi + +LICENSE="GPL-2" +SLOT="0" + +IUSE="dco down-root examples inotify iproute2 +lz4 +lzo mbedtls +openssl" +IUSE+=" pam pkcs11 +plugins selinux systemd test" + +RESTRICT="!test? ( test )" +REQUIRED_USE=" + ^^ ( openssl mbedtls ) + pkcs11? ( !mbedtls ) + !plugins? ( !pam !down-root ) + inotify? ( plugins ) + dco? ( !iproute2 ) +" + +CDEPEND=" + kernel_linux? ( + iproute2? ( sys-apps/iproute2[-minimal] ) + ) + lz4? ( app-arch/lz4 ) + lzo? ( >=dev-libs/lzo-1.07 ) + mbedtls? ( net-libs/mbedtls:= ) + openssl? ( >=dev-libs/openssl-1.0.2:0= ) + pam? ( sys-libs/pam ) + pkcs11? ( >=dev-libs/pkcs11-helper-1.11 ) + systemd? ( sys-apps/systemd ) + dco? ( >=net-vpn/ovpn-dco-0.2 >=dev-libs/libnl-3.2.29:= ) + sys-libs/libcap-ng:= +" + +BDEPEND="virtual/pkgconfig" + +DEPEND="${CDEPEND} + test? ( dev-util/cmocka ) +" +RDEPEND="${CDEPEND} + acct-group/openvpn + acct-user/openvpn + selinux? ( sec-policy/selinux-openvpn ) +" + +if [[ ${PV} = "9999" ]]; then + BDEPEND+=" dev-python/docutils" +fi + +PATCHES=( "${FILESDIR}"/openvpn-2.5.7-libressl.patch ) + +pkg_setup() { + local CONFIG_CHECK="~TUN" + linux-info_pkg_setup +} + +src_prepare() { + default + + eautoreconf +} + +src_configure() { + local -a myeconfargs + + if ! use mbedtls; then + myeconfargs+=( + $(use_enable pkcs11) + ) + fi + + myeconfargs+=( + $(use_enable inotify async-push) + --with-crypto-library=$(usex mbedtls mbedtls openssl) + $(use_enable lz4) + $(use_enable lzo) + $(use_enable plugins) + $(use_enable iproute2) + $(use_enable pam plugin-auth-pam) + $(use_enable down-root plugin-down-root) + $(use_enable systemd) + $(use_enable dco) + ) + + SYSTEMD_UNIT_DIR=$(systemd_get_systemunitdir) \ + TMPFILES_DIR="/usr/lib/tmpfiles.d" \ + IPROUTE=$(usex iproute2 '/bin/ip' '') \ + econf "${myeconfargs[@]}" +} + +src_test() { + local -x RUN_SUDO=false + + elog "Running top-level tests" + emake check + + pushd tests/unit_tests &>/dev/null || die + elog "Running unit tests" + emake check + popd &>/dev/null || die +} + +src_install() { + default + + find "${ED}/usr" -name '*.la' -delete || die + + # install documentation + dodoc AUTHORS ChangeLog PORTS README + + # Install some helper scripts + keepdir /etc/openvpn + exeinto /etc/openvpn + doexe "${FILESDIR}/up.sh" + doexe "${FILESDIR}/down.sh" + + # Install the init script and config file + newinitd "${FILESDIR}/${PN}-2.1.init" openvpn + newconfd "${FILESDIR}/${PN}-2.1.conf" openvpn + + # install examples, controlled by the respective useflag + if use examples ; then + # (is the below comment relevant anymore?) + ## dodoc does not supportly support directory traversal, #15193 + docinto examples + dodoc -r sample contrib + fi + + # https://bugs.gentoo.org/755680#c3 + doman doc/openvpn.8 +} + +pkg_postinst() { + tmpfiles_process openvpn.conf + + if use x64-macos ; then + elog "You might want to install tuntaposx for TAP interface support:" + elog "http://tuntaposx.sourceforge.net" + fi + + if systemd_is_booted || has_version sys-apps/systemd ; then + elog "In order to use OpenVPN with systemd please use the correct systemd service file." + elog "" + elog "server:" + elog "" + elog "- Place your server configuration file in /etc/openvpn/server" + elog "- Use the openvpn-server@.service like so" + elog "systemctl start openvpn-server@{Server-config}" + elog "" + elog "client:" + elog "" + elog "- Place your client configuration file in /etc/openvpn/client" + elog "- Use the openvpn-client@.service like so:" + elog "systemctl start openvpn-client@{Client-config}" + else + elog "The openvpn init script expects to find the configuration file" + elog "openvpn.conf in /etc/openvpn along with any extra files it may need." + 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 called" + 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." + fi + + if grep -Eq "^[ \t]*(up|down)[ \t].*" "${ROOT}/etc/openvpn"/*.conf 2>/dev/null ; then + ewarn "" + ewarn "WARNING: If you use the remote keyword then you are deemed to be" + ewarn "a client by our init script and as such we force up,down scripts." + ewarn "These scripts call /etc/openvpn/\$SVCNAME-{up,down}.sh where you" + ewarn "can move your scripts to." + fi + + if use plugins ; then + einfo "" + einfo "plugins have been installed into /usr/$(get_libdir)/${PN}/plugins" + fi +}