diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-06 12:52:09 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-06 12:52:09 +0100 |
commit | dd85f27b6ec98de1527a935a7f0930c2111d7930 (patch) | |
tree | fdfa8c958cebc27efbdbce4cc73522f161660c97 | |
parent | tools: endian.h is not portable (diff) | |
download | wireguard-monolithic-historical-dd85f27b6ec98de1527a935a7f0930c2111d7930.tar.xz wireguard-monolithic-historical-dd85f27b6ec98de1527a935a7f0930c2111d7930.zip |
wg-quick: match from beginning rather than shift right
Before, this meant that it simply took the last 15 characters, instead
of erroring out when there's more than 15 chars.
-rwxr-xr-x | src/tools/wg-quick.bash | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash index a028b98..80921bf 100755 --- a/src/tools/wg-quick.bash +++ b/src/tools/wg-quick.bash @@ -31,10 +31,10 @@ parse_options() { CONFIG_FILE="$1" [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" [[ -e $CONFIG_FILE ]] || die "\`$CONFIG_FILE' does not exist" - [[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] || die "The config file must be a valid interface name, followed by .conf" + [[ $CONFIG_FILE =~ (^|/)([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] || die "The config file must be a valid interface name, followed by .conf" CONFIG_FILE="$(readlink -f "$CONFIG_FILE")" ((($(stat -c '0%#a' "$CONFIG_FILE") & $(stat -c '0%#a' "${CONFIG_FILE%/*}") & 0007) == 0)) || echo "Warning: \`$CONFIG_FILE' is world accessible" >&2 - INTERFACE="${BASH_REMATCH[1]}" + INTERFACE="${BASH_REMATCH[2]}" shopt -s nocasematch while read -r line || [[ -n $line ]]; do key="${line%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}" |