diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2013-03-22 12:03:52 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2013-03-22 12:03:52 +0100 |
commit | c8e96611f141dd14ba0a6e8924e2951852401d8e (patch) | |
tree | 1375f30e58bc9e99c0e074f4c2ca8ad0b85059f9 /src | |
parent | e108b3b497a8553db8af0003a17266183bd6fe15 (diff) | |
download | netctl-c8e96611f141dd14ba0a6e8924e2951852401d8e.tar.gz netctl-c8e96611f141dd14ba0a6e8924e2951852401d8e.tar.xz |
Fix escaping unfortunate strings
Strings that look like arguments, as well as no string at all, were
causing trouble.
Reported by: Thomas Bächler
Diffstat (limited to 'src')
-rwxr-xr-x | src/netctl | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -29,9 +29,9 @@ END sd_escape() { local IFS='' # Prevent a recursion loop on backspaces - set "${@//\\/\\x5c}" + set -- "${@//\\/\\x5c}" while [[ "$*" =~ [^[:alnum:].:_/\\] ]]; do - set "${@//$BASH_REMATCH/$(printf '\\x%x' "'$BASH_REMATCH")}" + set -- "${@//$BASH_REMATCH/$(printf '\\x%x' "'$BASH_REMATCH")}" done printf '%s\n' "${@//\//-}" } @@ -40,7 +40,7 @@ sd_escape() { sd_call() { local command=$1 shift - set $(sd_escape "$@") + set -- $(sd_escape "$@") systemctl $command $(printf 'netctl@%s.service\n' "$@") } @@ -109,11 +109,12 @@ unit_enable() { echo ".include /usr/lib/systemd/system/netctl@.service" > "$unit" echo -e "\n[Unit]" >> "$unit" [[ -n $Description ]] && echo "Description=$Description" >> "$unit" - : ${BindsToInterfaces=$Interface} - printf 'BindsTo=sys-subsystem-net-devices-%s.device\n' \ - $(sd_escape "${BindsToInterfaces[@]}") >> "$unit" - printf 'After=sys-subsystem-net-devices-%s.device\n' \ - $(sd_escape "${BindsToInterfaces[@]}") >> "$unit" + if [[ -n ${BindsToInterfaces=$Interface} ]]; then + printf 'BindsTo=sys-subsystem-net-devices-%s.device\n' \ + $(sd_escape "${BindsToInterfaces[@]}") >> "$unit" + printf 'After=sys-subsystem-net-devices-%s.device\n' \ + $(sd_escape "${BindsToInterfaces[@]}") >> "$unit" + fi if [[ -n $After ]]; then printf 'After="netctl@%s.service"\n' \ $(sd_escape "${After[@]}") >> "$unit" |