wg-quick: escaped # in Pre/PostUp/Down recognised
PATCH 1/1 wg-quick: escaped # in Pre/PostUp/Down recognised
Hi there,
currently commands in pre/PostUp/Down options in wireguard configs are stripped of everything starting with the first # - even if the # is escaped or in a string.
This patch leaves command interpretation in Pre/PostUp/Down options to bash as it can already interpret comments and escaped #.
Signed-off-by Robyn Kosching <[email protected]>
--- src/wg-quick/linux.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
src/wg-quick/linux.bash +5 -4
@@ -51,6 +51,7 @@ parse_options() { stripped="${line%%\#*}" key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}" value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}" + commandvalue="${line#*=}"; commandvalue="${commandvalue##*([[:space:]])}"; commandvalue="${commandvalue%%*([[: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+=( "$commandvalue" ); continue ;; + PreDown) PRE_DOWN+=( "$commandvalue" ); continue ;; + PostUp) POST_UP+=( "$commandvalue" ); continue ;; + PostDown) POST_DOWN+=( "$commandvalue" ); continue ;; SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;; esac fi
base-commit: 13f4ac4cb74b5a833fa7f825ba785b1e5774e84f
Signature · 1 line
2.34.1
Thanks. Applied with some minor changes here:
https://git.zx2c4.com/wireguard-tools/commit/?id=90deacd33da06534ee98d41c6e76e108b35cf077