mirror of
https://git.zx2c4.com/wireguard-tools
synced 2026-06-11 09:52:20 -04: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:
parent
780182e37d
commit
90deacd33d
4 changed files with 20 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue