From b4d5801a16f8619bc3a6111a2a6bd049abd149a3 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 10 Jan 2018 02:37:03 +0100 Subject: wg-quick: ifnames have max len of 15 --- contrib/examples/reresolve-dns/reresolve-dns.sh | 4 ++-- src/tools/wg-quick.8 | 2 +- src/tools/wg-quick.bash | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/examples/reresolve-dns/reresolve-dns.sh b/contrib/examples/reresolve-dns/reresolve-dns.sh index 274aed8..7f913ab 100755 --- a/contrib/examples/reresolve-dns/reresolve-dns.sh +++ b/contrib/examples/reresolve-dns/reresolve-dns.sh @@ -9,8 +9,8 @@ shopt -s extglob export LC_ALL=C CONFIG_FILE="$1" -[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,16}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" -[[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,16})\.conf$ ]] +[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" +[[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] INTERFACE="${BASH_REMATCH[1]}" process_peer() { diff --git a/src/tools/wg-quick.8 b/src/tools/wg-quick.8 index 2039094..ceffb0d 100644 --- a/src/tools/wg-quick.8 +++ b/src/tools/wg-quick.8 @@ -97,7 +97,7 @@ interface upon shutdown. .P Recommended \fIINTERFACE\fP names include `wg0' or `wgvpn0' or even `wgmgmtlan0'. However, the number at the end is in fact optional, and really -any free-form string [a-zA-Z0-9_=+.-]{1,16} will work. So even interface names corresponding +any free-form string [a-zA-Z0-9_=+.-]{1,15} will work. So even interface names corresponding to geographic locations would suffice, such as `cincinnati', `nyc', or `paris', if that's somehow desirable. diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash index aceeebc..a028b98 100755 --- a/src/tools/wg-quick.bash +++ b/src/tools/wg-quick.bash @@ -29,9 +29,9 @@ ARGS=( "$@" ) parse_options() { local interface_section=0 line key value CONFIG_FILE="$1" - [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,16}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" + [[ $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,16})\.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]}" -- cgit v1.2.3-59-g8ed1b