]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg-quick: check permissions of parent directory
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 1 Oct 2017 20:05:19 +0000 (22:05 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 2 Oct 2017 00:45:53 +0000 (02:45 +0200)
Also prefix octal 0, in case these files are actually of modes that
don't start with 0 by accident (such as SUID or sticky bit).

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/wg-quick.bash

index 5295c8bfff65ca0a886d40e60dfc1bc4bbfa8889..015df85967e2b73390f50268f2b2302dbf011eb8 100755 (executable)
@@ -30,7 +30,7 @@ parse_options() {
        [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,16}$ ]] && 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"
-       ((($(stat -c '%#a' "$CONFIG_FILE") & 0007) == 0)) || echo "Warning: \`$CONFIG_FILE' is world accessible" >&2
+       ((($(stat -c '0%#a' "$CONFIG_FILE") & $(stat -c '0%#a' "/etc/wireguard") & 0007) == 0)) || echo "Warning: \`$CONFIG_FILE' is world accessible" >&2
        INTERFACE="${BASH_REMATCH[1]}"
        shopt -s nocasematch
        while read -r line || [[ -n $line ]]; do