Blame SOURCES/dnsmasq-2.76-label-warning.patch

e20e41
From c3d10a1132ada7baa80914f61abb720f94400465 Mon Sep 17 00:00:00 2001
e20e41
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
e20e41
Date: Tue, 14 Mar 2017 15:23:22 +0100
e20e41
Subject: [PATCH 1/2] Warn when using label in default mode
e20e41
e20e41
---
e20e41
 src/dnsmasq.c |  2 ++
e20e41
 src/dnsmasq.h |  3 ++-
e20e41
 src/network.c | 13 +++++++++++++
e20e41
 3 files changed, 17 insertions(+), 1 deletion(-)
e20e41
e20e41
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
e20e41
index 456b0e8..d2cc7cc 100644
e20e41
--- a/src/dnsmasq.c
e20e41
+++ b/src/dnsmasq.c
e20e41
@@ -771,6 +771,8 @@ int main (int argc, char **argv)
e20e41
 
e20e41
   if (option_bool(OPT_NOWILD))
e20e41
     warn_bound_listeners();
e20e41
+  else if (!option_bool(OPT_CLEVERBIND))
e20e41
+    warn_wild_labels();
e20e41
 
e20e41
   warn_int_names();
e20e41
   
e20e41
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
e20e41
index a27fbc1..6b44e53 100644
e20e41
--- a/src/dnsmasq.h
e20e41
+++ b/src/dnsmasq.h
e20e41
@@ -522,7 +522,7 @@ struct ipsets {
e20e41
 struct irec {
e20e41
   union mysockaddr addr;
e20e41
   struct in_addr netmask; /* only valid for IPv4 */
e20e41
-  int tftp_ok, dhcp_ok, mtu, done, warned, dad, dns_auth, index, multicast_done, found;
e20e41
+  int tftp_ok, dhcp_ok, mtu, done, warned, dad, dns_auth, index, multicast_done, found, label;
e20e41
   char *name; 
e20e41
   struct irec *next;
e20e41
 };
e20e41
@@ -1252,6 +1252,7 @@ int enumerate_interfaces(int reset);
e20e41
 void create_wildcard_listeners(void);
e20e41
 void create_bound_listeners(int die);
e20e41
 void warn_bound_listeners(void);
e20e41
+void warn_wild_labels(void);
e20e41
 void warn_int_names(void);
e20e41
 int is_dad_listeners(void);
e20e41
 int iface_check(int family, struct all_addr *addr, char *name, int *auth_dns);
e20e41
diff --git a/src/network.c b/src/network.c
e20e41
index eb41624..e5ceb76 100644
e20e41
--- a/src/network.c
e20e41
+++ b/src/network.c
e20e41
@@ -244,6 +244,7 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
e20e41
   int tftp_ok = !!option_bool(OPT_TFTP);
e20e41
   int dhcp_ok = 1;
e20e41
   int auth_dns = 0;
e20e41
+  int is_label = 0;
e20e41
 #if defined(HAVE_DHCP) || defined(HAVE_TFTP)
e20e41
   struct iname *tmp;
e20e41
 #endif
e20e41
@@ -264,6 +265,8 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
e20e41
   
e20e41
   if (!label)
e20e41
     label = ifr.ifr_name;
e20e41
+  else
e20e41
+    is_label = strcmp(label, ifr.ifr_name);
e20e41
  
e20e41
   /* maintain a list of all addresses on all interfaces for --local-service option */
e20e41
   if (option_bool(OPT_LOCAL_SERVICE))
e20e41
@@ -482,6 +485,7 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
e20e41
       iface->found = 1;
e20e41
       iface->done = iface->multicast_done = iface->warned = 0;
e20e41
       iface->index = if_index;
e20e41
+      iface->label = is_label;
e20e41
       if ((iface->name = whine_malloc(strlen(ifr.ifr_name)+1)))
e20e41
 	{
e20e41
 	  strcpy(iface->name, ifr.ifr_name);
e20e41
@@ -1034,6 +1038,15 @@ void warn_bound_listeners(void)
e20e41
     my_syslog(LOG_WARNING, _("LOUD WARNING: use --bind-dynamic rather than --bind-interfaces to avoid DNS amplification attacks via these interface(s)")); 
e20e41
 }
e20e41
 
e20e41
+void warn_wild_labels(void)
e20e41
+{
e20e41
+  struct irec *iface;
e20e41
+
e20e41
+  for (iface = daemon->interfaces; iface; iface = iface->next)
e20e41
+    if (iface->found && iface->name && iface->label)
e20e41
+      my_syslog(LOG_WARNING, _("warning: using interface %s instead"), iface->name);
e20e41
+}
e20e41
+
e20e41
 void warn_int_names(void)
e20e41
 {
e20e41
   struct interface_name *intname;
e20e41
-- 
e20e41
2.9.3
e20e41