mirror of
https://github.com/WireGuard/wireguard-tools.git
synced 2026-08-24 10:14:46 -05:00
wg-quick: pass on # comments to {Pre,Post}{Up,Down}
Currently commands in {Pre,Post}{Up,Down} are stripped of everything
starting with the first #, even if the # is escaped or in a string. This
patch leaves comment interpretation to the shell, as it can presumably
already handle the difference between comments and escaped #.
Signed-off-by: Robyn Kosching <robyn@kosching.me>
[Jason: massage commit message, port to other platforms]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
780182e37d
commit
90deacd33d
@@ -62,6 +62,7 @@ parse_options() {
|
||||
stripped="${line%%\#*}"
|
||||
key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
|
||||
value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
|
||||
unstripped_value="${line#*=}"; unstripped_value="${unstripped_value##*([[:space:]])}"; unstripped_value="${unstripped_value%%*([[:space:]])}"
|
||||
[[ $key == "["* ]] && interface_section=0
|
||||
[[ $key == "[Interface]" ]] && interface_section=1
|
||||
if [[ $interface_section -eq 1 ]]; then
|
||||
@@ -72,10 +73,10 @@ parse_options() {
|
||||
[[ $v =~ (^[0-9.]+$)|(^.*:.*$) ]] && DNS+=( $v ) || DNS_SEARCH+=( $v )
|
||||
done; continue ;;
|
||||
Table) TABLE="$value"; continue ;;
|
||||
PreUp) PRE_UP+=( "$value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
PreUp) PRE_UP+=( "$unstripped_value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$unstripped_value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -80,6 +80,7 @@ parse_options() {
|
||||
stripped="${line%%\#*}"
|
||||
key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
|
||||
value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
|
||||
unstripped_value="${line#*=}"; unstripped_value="${unstripped_value##*([[:space:]])}"; unstripped_value="${unstripped_value%%*([[:space:]])}"
|
||||
[[ $key == "["* ]] && interface_section=0
|
||||
[[ $key == "[Interface]" ]] && interface_section=1
|
||||
if [[ $interface_section -eq 1 ]]; then
|
||||
@@ -90,10 +91,10 @@ parse_options() {
|
||||
[[ $v =~ (^[0-9.]+$)|(^.*:.*$) ]] && DNS+=( $v ) || DNS_SEARCH+=( $v )
|
||||
done; continue ;;
|
||||
Table) TABLE="$value"; continue ;;
|
||||
PreUp) PRE_UP+=( "$value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
PreUp) PRE_UP+=( "$unstripped_value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$unstripped_value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -51,6 +51,7 @@ parse_options() {
|
||||
stripped="${line%%\#*}"
|
||||
key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
|
||||
value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
|
||||
unstripped_value="${line#*=}"; unstripped_value="${unstripped_value##*([[:space:]])}"; unstripped_value="${unstripped_value%%*([[:space:]])}"
|
||||
[[ $key == "["* ]] && interface_section=0
|
||||
[[ $key == "[Interface]" ]] && interface_section=1
|
||||
if [[ $interface_section -eq 1 ]]; then
|
||||
@@ -61,10 +62,10 @@ parse_options() {
|
||||
[[ $v =~ (^[0-9.]+$)|(^.*:.*$) ]] && DNS+=( $v ) || DNS_SEARCH+=( $v )
|
||||
done; continue ;;
|
||||
Table) TABLE="$value"; continue ;;
|
||||
PreUp) PRE_UP+=( "$value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
PreUp) PRE_UP+=( "$unstripped_value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$unstripped_value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -52,6 +52,7 @@ parse_options() {
|
||||
stripped="${line%%\#*}"
|
||||
key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
|
||||
value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
|
||||
unstripped_value="${line#*=}"; unstripped_value="${unstripped_value##*([[:space:]])}"; unstripped_value="${unstripped_value%%*([[:space:]])}"
|
||||
[[ $key == "["* ]] && interface_section=0
|
||||
[[ $key == "[Interface]" ]] && interface_section=1
|
||||
if [[ $interface_section -eq 1 ]]; then
|
||||
@@ -62,10 +63,10 @@ parse_options() {
|
||||
[[ $v =~ (^[0-9.]+$)|(^.*:.*$) ]] && DNS+=( $v ) || DNS_SEARCH+=( $v )
|
||||
done; continue ;;
|
||||
Table) TABLE="$value"; continue ;;
|
||||
PreUp) PRE_UP+=( "$value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
PreUp) PRE_UP+=( "$unstripped_value" ); continue ;;
|
||||
PreDown) PRE_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
PostUp) POST_UP+=( "$unstripped_value" ); continue ;;
|
||||
PostDown) POST_DOWN+=( "$unstripped_value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user