Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openvpn: fix hotplug parameters #15124

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions net/openvpn/files/etc/hotplug.d/openvpn/01-user
Expand Up @@ -3,7 +3,8 @@
. /lib/functions/openvpn.sh

[ -e "/etc/openvpn.user" ] && {
env -i ACTION="$ACTION" INSTANCE="$INSTANCE" \
env -i ACTION="$ACTION" INSTANCE="$INSTANCE" INTERFACE=$INTERFACE MTU=$MTU LINK_MTU=$LINK_MTU \
IP_ADDRESS=$IP_ADDRESS NETMASK=$NETMASK COMMAND=$COMMAND \
/bin/sh \
/etc/openvpn.user \
$*
Expand All @@ -12,9 +13,8 @@
# Wrap user defined scripts on up/down events
case "$ACTION" in
up|down)
if get_openvpn_option "$config" command "$ACTION"; then
shift
exec /bin/sh -c "$command $*"
if command=$(uci get "openvpn.${INSTANCE}.${ACTION}"); then
exec /bin/sh -c "$command $INTERFACE $MTU $LINK_MTU $IP_ADDRESS $NETMASK $COMMAND"
fi
;;
esac
Expand Down
7 changes: 6 additions & 1 deletion net/openvpn/files/etc/openvpn.user
Expand Up @@ -8,4 +8,9 @@
# <down> down action is generated after the TUN/TAP device is closed
# <up> up action is generated after the TUN/TAP device is opened
# $INSTANCE Name of the openvpn instance which went up or down

# $INTERFACE VPN interface name
# $MTU VPN tunnel MTU
# $LINK_MTU VPN tunnel link MTU
# $IP_ADDRESS VPN interface IP Address
# $NETMASK VPN interface netmask
# $COMMAND Command to execute (in general this is "init")
18 changes: 18 additions & 0 deletions net/openvpn/files/usr/libexec/openvpn-hotplug
Expand Up @@ -4,7 +4,25 @@ ACTION=$1
shift
INSTANCE=$1
shift
INTERFACE=$1
shift
MTU=$1
shift
LINK_MTU=$1
shift
IP_ADDRESS=$1
shift
NETMASK=$1
shift
COMMAND=$1
shift

export ACTION=$ACTION
export INSTANCE=$INSTANCE
export INTERFACE=$INTERFACE
export MTU=$MTU
export LINK_MTU=$LINK_MTU
export IP_ADDRESS=$IP_ADDRESS
export NETMASK=$NETMASK
export COMMAND=$COMMAND
exec /sbin/hotplug-call openvpn "$@"