DM_LIST_KNOWN_ZONES="invalid"
DM_LIST_TRN_ZONES=""
DM_LIST_LOCAL_DATA=""
+DM_LIST_PRZ_DATA=""
DM_LIST_LOCAL_PTR=""
DM_LIST_FWD_PORTS=""
DM_LIST_FWD_ZONES=""
config_get target "$cfg" target
+ # For cnames with a local data target the A RR is not resolved and missing
+ # in the response. As most applications don't send another query and fail,
+ # these entries are placed in a rpz zone instead.
if [ -n "$cname" ] && [ -n "$target" ] ; then
- create_local_zone "$cname"
- record="$cname.@@300@@IN@@CNAME@@$target."
- DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $record"
+ record="${DM_LIST_LOCAL_DATA#*${target}.@@*@@IN@@A@@}"
+ if [ "$record" == "$DM_LIST_LOCAL_DATA" ]; then
+ # Target is not a local data record => local data can be used
+ create_local_zone "$cname"
+ record="$cname.@@300@@IN@@CNAME@@$target."
+ DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $record"
+
+ else
+ # Target is a local data record => use rpz zone
+
+ # Add A RR at the end if still not present
+ record="$target@@A@@${record%% *}"
+ if [ "${DM_LIST_PRZ_DATA}" == "${DM_LIST_PRZ_DATA#*${record}}" ]; then
+ DM_LIST_PRZ_DATA="$DM_LIST_PRZ_DATA $record"
+ fi
+
+ # Add CNAME at the beginning
+ record="$cname@@CNAME@@$target."
+ DM_LIST_PRZ_DATA="$record $DM_LIST_PRZ_DATA"
+ fi
fi
}
echo
fi
} > $UB_SRVMASQ_CONF
+
+ if [ -n "$DM_LIST_PRZ_DATA" ] ; then
+ {
+ echo '$ORIGIN cname.rpz.localhost; generated by UCI'
+ echo ""
+ for record in $DM_LIST_PRZ_DATA; do
+ echo "${record//@@/ }"
+ done
+ } > $UB_RPZCNAME_CONF
+
+ {
+ echo "# $UB_EXTMASQ_CONF generated by UCI"
+ echo "rpz:"
+ echo " name: cname.rpz.localhost"
+ echo " zonefile: $UB_RPZCNAME_CONF"
+ echo ""
+ } > $UB_EXTMASQ_CONF
+ fi
fi
}