[PATCH wireguard-tools] wg-quick: escaped # in Pre/PostUp/Down recognised
Robyn Kosching
robyn at kosching.me
Wed Jan 15 11:36:42 UTC 2025
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 <robyn at kosching.me>
---
src/wg-quick/linux.bash | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
index 4193ce5..50bb794 100755
--- a/src/wg-quick/linux.bash
+++ b/src/wg-quick/linux.bash
@@ -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
--
2.34.1
More information about the WireGuard
mailing list