Skip to content
Snippets Groups Projects
Verified Commit f2ebda10 authored by Roosemberth Palacios's avatar Roosemberth Palacios
Browse files

epfl-vpn: fix word splitting issue when passing complex command


Signed-off-by: default avatarRoosembert Palacios <roosemberth@posteo.ch>
parent 80947626
Branches master
1 merge request!20Small fixes on epfl-vpn script
Pipeline #2051 passed with stages
in 13 minutes and 21 seconds
......@@ -252,12 +252,19 @@ if [ -n "$VPNGATEWAY" ]; then
"$VPNC_SCRIPT" "$@"
# Deserialize command
OLDIFS="$IFS"
IFS="\x1E"
# shellcheck disable=SC2206 # splitting with custom IFS
CMD=($COMMAND)
IFS="$OLDIFS"
# shellcheck disable=SC2154 # $reason is set by openconnect
if [ -n "$NETNS_NAME" ] && [ -n "$RUNAS_USER" ] && [ "$reason" = "connect" ] ; then
echo "Running requested command"
cat <<- EOF | sudo -u "$RUNAS_USER" bash -s &
#!/usr/bin/env bash
$COMMAND
${CMD[@]}
echo
echo "Command finished, press Ctrl-C to exit the network jail"
EOF
......@@ -283,7 +290,8 @@ while [ $# -gt 0 ]; do
if [ $# -lt 1 ]; then
die $E_USER "A command to execute inside the jail must be specified."
fi
COMMAND="$@"
# Serialize the rest of the arguments, to be executed in bash inside the jail
OLDIFS="$IFS"; IFS="\x1E"; COMMAND="$*"; IFS="$OLDIFS"
break ;;
(-*) die $E_USER 'Unknown option: %s' "$opt" ;;
(*) die $E_USER 'Trailing argument: %s' "$opt" ;;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment