* [PATCH wireguard-tools] wg-quick: escaped # in Pre/PostUp/Down recognised
@ 2025-01-15 11:33 Robyn Kosching
2025-05-23 18:46 ` Jason A. Donenfeld
0 siblings, 1 reply; 2+ messages in thread
From: Robyn Kosching @ 2025-01-15 11:33 UTC (permalink / raw)
To: wireguard; +Cc: Robyn Kosching
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@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH wireguard-tools] wg-quick: escaped # in Pre/PostUp/Down recognised
2025-01-15 11:33 [PATCH wireguard-tools] wg-quick: escaped # in Pre/PostUp/Down recognised Robyn Kosching
@ 2025-05-23 18:46 ` Jason A. Donenfeld
0 siblings, 0 replies; 2+ messages in thread
From: Jason A. Donenfeld @ 2025-05-23 18:46 UTC (permalink / raw)
To: robyn; +Cc: wireguard
Thanks. Applied with some minor changes here:
https://git.zx2c4.com/wireguard-tools/commit/?id=90deacd33da06534ee98d41c6e76e108b35cf077
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-23 18:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-15 11:33 [PATCH wireguard-tools] wg-quick: escaped # in Pre/PostUp/Down recognised Robyn Kosching
2025-05-23 18:46 ` Jason A. Donenfeld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).