From e675b2e00579618c54064c4ac80e221c7531f280 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 30 Jan 2008 10:26:52 +0000 Subject: [PATCH] Allow openvpn options to be specified. If options exist then for tunctl then we prefer that to openvpn, unless openvpn options exist. --- doc.Linux/net.example | 4 +++- net.Linux/tuntap.sh | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/doc.Linux/net.example b/doc.Linux/net.example index 9cdea36d..49e608e0 100644 --- a/doc.Linux/net.example +++ b/doc.Linux/net.example @@ -768,7 +768,9 @@ # For passing custom options to tunctl use something like the following. This # example sets the owner to adm #tunctl_tun1="-u adm" -# When using openvpn, there are no options +# OpenVPN-2.1_rc6 and newer allow --user and --group to set owner and group +# of the node as well +#openvpn_tun1="--user foo --group bar" #----------------------------------------------------------------------------- # Bridging (802.1d) diff --git a/net.Linux/tuntap.sh b/net.Linux/tuntap.sh index 7c789620..62008135 100644 --- a/net.Linux/tuntap.sh +++ b/net.Linux/tuntap.sh @@ -32,12 +32,25 @@ tuntap_pre_start() # Set the base metric to 1000 metric=1000 - if type tunctl >/dev/null 2>&1; then - local opts= - eval opts=\$tunctl_${IFVAR} - tunctl ${opts} -t "${IFACE}" >/dev/null + local o_opts= t_opts= do_open=false do_tunctl=false + eval o_opts=\$openvpn_${IFVAR} + eval t_opts=\$tunctl_${IFVAR} + + if [ -n "${o_opts}" ] && type openvpn >/dev/null 2>&1; then + do_open=true + elif [ -n "${t_opts}" ] && type tunctl >/dev/null 2>&1; then + do_tunctl=true + elif type openvpn >/dev/null 2>&1; then + do_openvpn=true else - openvpn --mktun --dev-type "${tuntap}" --dev "${IFACE}" >/dev/null + do_tunctl=true + fi + + if ${do_openvpn}; then + openvpn --mktun --dev-type "${tuntap}" --dev "${IFACE}" \ + ${o_opts} >/dev/null + else + tunctl ${t_opts} -t "${IFACE}" >/dev/null fi eend $? && _up && service_set_value tuntap "${tuntap}" }