commit 7839b4ddbda6662741487fe65138a5e89ff10506
parent 69f20153d0ad3eebc5a4c730eb39309dba2823d1
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Mon, 1 Aug 2022 05:30:49 +0200
Fix quoting. Function to escape regex in common.aat
Diffstat:
4 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/common.aat b/common.aat
@@ -13,3 +13,8 @@
| exit 3
| # return content ? "\nC\t"nl_esc(content) : "\tr"
|}
+|
+|function escape_regex(re) {
+| gsub(/[][)(\\\/*+?.]/, "\\\\&", re)
+| return re
+|}
diff --git a/postinstall.aat b/postinstall.aat
@@ -1,3 +1,4 @@
+@include common.aat
|### Functions ###
|function passwd_user(line, grep1) {
/etc/passwd f +
@@ -49,10 +50,8 @@
}'
|}
|function line_append_file(pre, match_str, post, pre_re, post_re, regex, grep1) {
-| regex = match_str
-| grep1 = pre match_str post
-| gsub(/[][)(\\\/*+?]/, "\\\\&", regex)
-| gsub(/[][)(\\\/*+?]/, "\\\\&", grep1)
+| regex = escape_regex(match_str)
+| grep1 = escape_regex(pre match_str post)
? grep -qEe '^{{grep1}}$' "$fname"
! if grep -qEe '{{pre_re regex post_re}}' "$fname"; then
sed -ire 's|{{pre_re regex post_re}}|{{pre match_str post}}|' "$fname"
diff --git a/s6-rc.aat b/s6-rc.aat
@@ -87,7 +87,7 @@ m755
/{{svc}}/up
CN if { ip link set {<i.iface>} up }
if -nt { ip addr add {<i.ip>}/{<i.cidr>} dev {<i.iface>} }
- pipeline { ip addr show dev {<i.iface>} } grep -qF 'inet {<i.ip>}/{<i.cidr>}'
+ pipeline { ip addr show dev {<i.iface>} } grep -F -q -e "inet {<i.ip>}/{<i.cidr>} "
/{{svc}}/down
CN ip addr del {<i.ip>} dev {<i.iface>}
m755
@@ -99,7 +99,7 @@ m755
/{{svc}}/up
CN if { ip link set {<i.iface>} up }
if -nt { ip route add dev {<i.iface>} {<i.spec>} }
- pipeline { ip route show dev {<i.iface>} {<i.spec>} } grep -q .'
+ pipeline { ip route show dev {<i.iface>} {<i.spec>} } grep -q .
/{{svc}}/down
CN ip route del dev {<i.iface>} {<i.spec>}
m755
diff --git a/s6-rc.fileset b/s6-rc.fileset
@@ -160,7 +160,7 @@ m755
/net-eth0-ip/up
CN if { ip link set eth0 up }
if -nt { ip addr add 192.168.16.23/24 dev eth0 }
- pipeline { ip addr show dev eth0 } grep -qF 'inet 192.168.16.23/24'
+ pipeline { ip addr show dev eth0 } grep -F -q -e "inet 192.168.16.23/24 "
/net-eth0-ip/down
CN ip addr del 192.168.16.23 dev eth0
m755
@@ -174,7 +174,7 @@ m644
/net-eth0-route/up
CN if { ip link set eth0 up }
if -nt { ip route add dev eth0 0.0.0.0/0 via 192.168.16.1 }
- pipeline { ip route show dev eth0 0.0.0.0/0 via 192.168.16.1 } grep -q .'
+ pipeline { ip route show dev eth0 0.0.0.0/0 via 192.168.16.1 } grep -q .
/net-eth0-route/down
CN ip route del dev eth0 0.0.0.0/0 via 192.168.16.1
m755