netifd-proto.sh: execute proto_add_host_dependency() actions in subshell to retain...
[project/netifd.git] / dummy / netifd-proto.sh
index 99ad11e..297e904 100755 (executable)
@@ -105,8 +105,9 @@ proto_add_ipv4_address() {
        local address="$1"
        local mask="$2"
        local broadcast="$3"
+       local ptp="$4"
 
-       jshn_append PROTO_IPADDR "$address/$mask/$broadcast"
+       jshn_append PROTO_IPADDR "$address/$mask/$broadcast/$ptp"
 }
 
 proto_add_ipv6_address() {
@@ -134,18 +135,21 @@ proto_add_ipv6_route() {
 
 _proto_push_ipv4_addr() {
        local str="$1"
-       local address mask broadcast
+       local address mask broadcast ptp
 
        address="${str%%/*}"
        str="${str#*/}"
        mask="${str%%/*}"
        str="${str#*/}"
-       broadcast="$str"
+       broadcast="${str%%/*}"
+       str="${str#*/}"
+       ptp="$str"
 
        json_add_object ""
        json_add_string ipaddr "$address"
        [ -n "$mask" ] && json_add_string mask "$mask"
        [ -n "$broadcast" ] && json_add_string broadcast "$broadcast"
+       [ -n "$ptp" ] && json_add_string ptp "$ptp"
        json_close_object
 }
 
@@ -286,10 +290,21 @@ proto_add_host_dependency() {
        local interface="$1"
        local host="$2"
 
+       # execute in subshell to not taint callers env
+       # see tickets #11046, #11545, #11570
+       (
+               json_init
+               json_add_int action 6
+               json_add_string host "$host"
+               _proto_notify "$interface" -S
+       )
+}
+
+proto_setup_failed() {
+       local interface="$1"
        json_init
-       json_add_int action 6
-       json_add_string host "$host"
-       _proto_notify "$interface" -S
+       json_add_int action 7
+       _proto_notify "$interface"
 }
 
 init_proto() {