fi
-# Generate ModSecurity configuration file and activate RBL lookup
+# Generate ModSecurity configuration files and activate RBL lookup
# for ModSecurity if needed.
#
chk_conf_tag "$MODSECCONF"
out=$(mktemp $MODSECCONF.XXXXXX)
temp_files="${temp_files} ${out}"
- cp "$MODSECTPL/$(basename $MODSECCONF)" "$out"
db_get mod-security-cn/rbl || true
if [ "$RET" = "true" ]; then
if [ $RET -eq 0 ] || [ $RET -eq 1 ]; then
if [ $RET -eq 1 ]; then
- cp_echo "CN: Creating new configuration file $MODSECRBL"
+ cp_echo "CN: Creating configuration file $MODSECRBL"
cp "$MODSECTPL/$(basename $MODSECRBL)" "$MODSECRBL"
need_restart=1
else
fi
fi
- cp_check_and_sed '#RBLLOOKUP#' \
- "s,#RBLLOOKUP#,Include $MODSECRBL,g" \
- "$out" || true
+ sed "s,#RBLLOOKUP#,Include $MODSECRBL,g" \
+ "$MODSECTPL/$(basename $MODSECCONF)" > "$out"
if [ -e "$MODSECCONF" ]; then
if ! cmp -s "$MODSECCONF" "$out"; then
need_restart=1
fi
else
- cp_echo "CN: Creating new configuration file $MODSECCONF"
+ cp_echo "CN: Creating configuration file $MODSECCONF"
mv "$out" "$MODSECCONF"
cp_echo "CN: Enabled ModSecurity RBL lookup."
need_restart=1
else
# Remove RBL configuration.
- cp_check_and_sed '#RBLLOOKUP#' \
- "s,#RBLLOOKUP#,# DISABLED,g" \
- "$out" || true
+ sed "s,#RBLLOOKUP#,# DISABLED,g" \
+ "$MODSECTPL/$(basename $MODSECCONF)" > "$out"
if [ -e "$MODSECCONF" ]; then
if ! cmp -s "$MODSECCONF" "$out"; then
need_restart=1
fi
else
- cp_echo "CN: Creating new configuration file $MODSECCONF"
+ cp_echo "CN: Creating configuration file $MODSECCONF"
mv "$out" "$MODSECCONF"
cp_echo "CN: Disabled ModSecurity RBL lookup."
need_restart=1