[2/3] Unbound: do not generate PTR if the user requested notto, do so

Message ID 9d755e0c-eb20-9ad9-9cb5-9ee38f5cc1ec@ipfire.org
State Accepted
Headers
Series [1/3] add option for selective PTR generation on hosts.cgi |

Commit Message

Peter Müller April 9, 2019, 4:04 a.m. UTC
  Partially fixes #12030

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
---
 src/initscripts/system/unbound | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Michael Tremer April 15, 2019, 7:50 p.m. UTC | #1
Hi,

> On 8 Apr 2019, at 19:04, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Partially fixes #12030
> 
> Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
> ---
> src/initscripts/system/unbound | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/initscripts/system/unbound b/src/initscripts/system/unbound
> index af9bcef73..107f80477 100644
> --- a/src/initscripts/system/unbound
> +++ b/src/initscripts/system/unbound
> @@ -172,9 +172,9 @@ own_hostname() {
> }
> 
> update_hosts() {
> -	local enabled address hostname domainname
> +	local enabled address hostname domainname generateptr
> 
> -	while IFS="," read -r enabled address hostname domainname; do
> +	while IFS="," read -r enabled address hostname domainname generateptr; do
> 		[ "${enabled}" = "on" ] || continue
> 
> 		# Build FQDN
> @@ -185,6 +185,9 @@ update_hosts() {
> 		# Skip reverse resolution if the address equals the GREEN address
> 		[ "${address}" = "${GREEN_ADDRESS}" ] && continue
> 
> +                # Skip reverse resolution if user requested not to do so
> +                [ "${generateptr}" = "off" ] && continue

You indented with spaces here when the whole file uses tabs. I changed that when I merged the patch.

-Michael

> +
> 		# Add RDNS
> 		address=$(ip_address_revptr ${address})
> 		unbound-control -q local_data "${address} ${LOCAL_TTL} IN PTR ${fqdn}"
> -- 
> 2.16.4
  

Patch

diff --git a/src/initscripts/system/unbound b/src/initscripts/system/unbound
index af9bcef73..107f80477 100644
--- a/src/initscripts/system/unbound
+++ b/src/initscripts/system/unbound
@@ -172,9 +172,9 @@  own_hostname() {
 }
 
 update_hosts() {
-	local enabled address hostname domainname
+	local enabled address hostname domainname generateptr
 
-	while IFS="," read -r enabled address hostname domainname; do
+	while IFS="," read -r enabled address hostname domainname generateptr; do
 		[ "${enabled}" = "on" ] || continue
 
 		# Build FQDN
@@ -185,6 +185,9 @@  update_hosts() {
 		# Skip reverse resolution if the address equals the GREEN address
 		[ "${address}" = "${GREEN_ADDRESS}" ] && continue
 
+                # Skip reverse resolution if user requested not to do so
+                [ "${generateptr}" = "off" ] && continue
+
 		# Add RDNS
 		address=$(ip_address_revptr ${address})
 		unbound-control -q local_data "${address} ${LOCAL_TTL} IN PTR ${fqdn}"