Skip to content

Commit 8323fb7

Browse files
committed
Firewall ipset: abort adding/updating when preprcessing script fails, replace iplist file content with the script output
1 parent 26f629d commit 8323fb7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bin/v-add-firewall-ipset

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ if [ ! -f "${IPSET_PATH}/${IPSET_FILE}.iplist" ] || [ "$force" = "yes" ]; then
8989
# Advanced: execute script with the same basename for aditional pre-processing
9090
# ex:
9191
if [ -x "${IPSET_PATH}/${IPSET_FILE}.sh" ]; then
92-
setpriv --clear-groups --reuid nobody --regid nogroup -- ${IPSET_PATH}/${IPSET_FILE}.sh "$ip_name" "$iplist_tempfile"
92+
preprocess_output="$(cat "$iplist_tempfile" | setpriv --clear-groups --reuid nobody --regid nogroup -- ${IPSET_PATH}/${IPSET_FILE}.sh "$ip_name" "$iplist_tempfile")"
93+
check_result $? "Preprocessing script failed (${IPSET_FILE}.sh)"
94+
[[ "$preprocess_output" ]] && echo "$preprocess_output" > "$iplist_tempfile"
9395
fi
9496

9597
elif [[ "$data_source" =~ ^script:/ ]]; then

0 commit comments

Comments
 (0)