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