[dnsmasq/f19] Include several fixies from upstream repo

Tomas Hozza thozza at fedoraproject.org
Fri May 17 13:32:59 UTC 2013


commit cf08454de6e8387f5308ea2c734255a2bd726742
Author: Tomas Hozza <thozza at redhat.com>
Date:   Fri May 17 15:01:06 2013 +0200

    Include several fixies from upstream repo
    
    - Tighten hostname checks in legal hostname() function
    - Replace inet_addr() with inet_pton() in src/option.c
    - Use dnsmasq as default DNS server for RA only if it's doing DNS
    - Handle IPv4 interface address labels (aliases) in Linux (#962246)
    - Fix failure to start with ENOTSOCK (#962874)
    
    Signed-off-by: Tomas Hozza <thozza at redhat.com>

 ...q-2.66-Fix_failure_to_start_with_ENOTSOCK.patch |   44 +++
 ...le_IPv4_interface_address_labels_in_Linux.patch |  283 ++++++++++++++++++++
 ...asq-2.66-Tighten_checks_in_legal_hostname.patch |   45 +++
 ...DNS-server-for-RA-only-if-it-is-doing-DNS.patch |   30 ++
 ...lace-inet_addr-with-inet_pton-in-option-c.patch |  164 +++++++++++
 dnsmasq.spec                                       |   25 ++-
 6 files changed, 590 insertions(+), 1 deletions(-)
---
diff --git a/dnsmasq-2.66-Fix_failure_to_start_with_ENOTSOCK.patch b/dnsmasq-2.66-Fix_failure_to_start_with_ENOTSOCK.patch
new file mode 100644
index 0000000..26b2795
--- /dev/null
+++ b/dnsmasq-2.66-Fix_failure_to_start_with_ENOTSOCK.patch
@@ -0,0 +1,44 @@
+From cfcad42ff1ddee8e64d120f18016a654152d0215 Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon at thekelleys.org.uk>
+Date: Fri, 17 May 2013 11:32:03 +0100
+Subject: [PATCH] Fix failure to start with ENOTSOCK
+
+---
+ CHANGELOG     | 6 ++++++
+ src/dnsmasq.c | 2 +-
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index 7aa0024..48b6070 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -31,7 +31,13 @@ version 2.67
+ 	    want to continue to bind the aliases too, you need to add
+ 	    eg. --interface=eth0:0 to the config. 
+ 	
++	    Fix "failed to set SO_BINDTODEVICE on DHCP socket: Socket 
++	    operation on non-socket" error on startup with
++	    configurations which have exactly one --interface option
++	    and do RA but _not_ DHCPv6. Thanks to Trever Adams for the
++	    bug report.
+ 
++		
+ version 2.66
+             Add the ability to act as an authoritative DNS
+             server. Dnsmasq can now answer queries from the wider 'net
+diff --git a/src/dnsmasq.c b/src/dnsmasq.c
+index 43b8cb1..b0f984d 100644
+--- a/src/dnsmasq.c
++++ b/src/dnsmasq.c
+@@ -248,7 +248,7 @@ int main (int argc, char **argv)
+ #endif
+ 
+ #if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP6)
+-      if (daemon->dhcp6)
++      if (daemon->doing_dhcp6)
+ 	bindtodevice(daemon->dhcp6fd);
+ #endif
+     }
+-- 
+1.8.1.4
+
diff --git a/dnsmasq-2.66-Handle_IPv4_interface_address_labels_in_Linux.patch b/dnsmasq-2.66-Handle_IPv4_interface_address_labels_in_Linux.patch
new file mode 100644
index 0000000..1434467
--- /dev/null
+++ b/dnsmasq-2.66-Handle_IPv4_interface_address_labels_in_Linux.patch
@@ -0,0 +1,283 @@
+From 3f2873d42c4d7e7dba32b6e64a3687d43928bc8e Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon at thekelleys.org.uk>
+Date: Tue, 14 May 2013 11:28:47 +0100
+Subject: [PATCH]  Handle IPv4 interface-address labels in Linux.
+
+---
+ CHANGELOG     |  9 +++++++++
+ src/bpf.c     |  2 +-
+ src/dhcp.c    | 14 +++++++++-----
+ src/dnsmasq.h |  1 +
+ src/forward.c |  3 ++-
+ src/lease.c   |  3 ++-
+ src/netlink.c |  7 +++++--
+ src/network.c | 39 +++++++++++++++++++++++++++++++--------
+ src/tftp.c    |  3 ++-
+ 9 files changed, 62 insertions(+), 19 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index f6ce80e..7aa0024 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -21,6 +21,15 @@ version 2.67
+	    Fix --dhcp-match, --dhcp-vendorclass and --dhcp-userclass
+	    to work with BOOTP and well as DHCP. Thanks to Peter
+	    Korsgaard for spotting the problem. 
++
++	    Handle IPv4 interface-address labels in Linux. These are
++	    often used to emulate the old IP-alias addresses. Before,
++	    using --interface=eth0 would service all the addresses of
++	    eth0, including ones configured as aliases, which appear
++	    in ifconfig as eth0:0. Now, only addresses with the label
++	    eth0 are active. This is not backwards compatible: if you
++	    want to continue to bind the aliases too, you need to add
++	    eg. --interface=eth0:0 to the config. 
+ 	
+ 
+ version 2.66
+diff --git a/src/bpf.c b/src/bpf.c
+index 02a3abb..e75b0c6 100644
+--- a/src/bpf.c
++++ b/src/bpf.c
+@@ -123,7 +123,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
+ 		broadcast = ((struct sockaddr_in *) addrs->ifa_broadaddr)->sin_addr; 
+ 	      else 
+ 		broadcast.s_addr = 0;	      
+-	      if (!((*callback)(addr, iface_index, netmask, broadcast, parm)))
++	      if (!((*callback)(addr, iface_index, NULL, netmask, broadcast, parm)))
+ 		goto err;
+ 	    }
+ #ifdef HAVE_IPV6
+diff --git a/src/dhcp.c b/src/dhcp.c
+index dd25632..333a327 100644
+--- a/src/dhcp.c
++++ b/src/dhcp.c
+@@ -28,9 +28,9 @@ struct match_param {
+   struct in_addr netmask, broadcast, addr;
+ };
+ 
+-static int complete_context(struct in_addr local, int if_index, 
++static int complete_context(struct in_addr local, int if_index, char *label,
+ 			    struct in_addr netmask, struct in_addr broadcast, void *vparam);
+-static int check_listen_addrs(struct in_addr local, int if_index, 
++static int check_listen_addrs(struct in_addr local, int if_index, char *label,
+ 			      struct in_addr netmask, struct in_addr broadcast, void *vparam);
+ 
+ static int make_fd(int port)
+@@ -287,7 +287,7 @@ void dhcp_packet(time_t now, int pxe_fd)
+       iface_addr = match.addr;
+       /* make sure secondary address gets priority in case
+ 	 there is more than one address on the interface in the same subnet */
+-      complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm);
++      complete_context(match.addr, iface_index, NULL, match.netmask, match.broadcast, &parm);
+     }    
+       
+   if (!iface_enumerate(AF_INET, &parm, complete_context))
+@@ -411,12 +411,14 @@ void dhcp_packet(time_t now, int pxe_fd)
+ }
+  
+ /* check against secondary interface addresses */
+-static int check_listen_addrs(struct in_addr local, int if_index, 
++static int check_listen_addrs(struct in_addr local, int if_index, char *label,
+ 			      struct in_addr netmask, struct in_addr broadcast, void *vparam)
+ {
+   struct match_param *param = vparam;
+   struct iname *tmp;
+ 
++  (void) label;
++
+   if (if_index == param->ind)
+     {
+       for (tmp = daemon->if_addrs; tmp; tmp = tmp->next)
+@@ -444,11 +446,13 @@ static int check_listen_addrs(struct in_addr local, int if_index,
+ 
+    Note that the current chain may be superceded later for configured hosts or those coming via gateways. */
+ 
+-static int complete_context(struct in_addr local, int if_index, 
++static int complete_context(struct in_addr local, int if_index, char *label,
+ 			    struct in_addr netmask, struct in_addr broadcast, void *vparam)
+ {
+   struct dhcp_context *context;
+   struct iface_param *param = vparam;
++
++  (void)label;
+   
+   for (context = daemon->dhcp; context; context = context->next)
+     {
+diff --git a/src/dnsmasq.h b/src/dnsmasq.h
+index e177cea..8866dd8 100644
+--- a/src/dnsmasq.h
++++ b/src/dnsmasq.h
+@@ -1030,6 +1030,7 @@ void create_bound_listeners(int die);
+ int is_dad_listeners(void);
+ int iface_check(int family, struct all_addr *addr, char *name, int *auth_dns);
+ int loopback_exception(int fd, int family, struct all_addr *addr, char *name);
++int label_exception(int index, int family, struct all_addr *addr);
+ int fix_fd(int fd);
+ int tcp_interface(int fd, int af);
+ struct in_addr get_ifaddr(char *intr);
+diff --git a/src/forward.c b/src/forward.c
+index 78495ca..28fe9eb 100644
+--- a/src/forward.c
++++ b/src/forward.c
+@@ -789,7 +789,8 @@ void receive_query(struct listener *listen, time_t now)
+ 	{
+ 	   if (!option_bool(OPT_CLEVERBIND))
+ 	     enumerate_interfaces(); 
+-	   if (!loopback_exception(listen->fd, listen->family, &dst_addr, ifr.ifr_name))
++	   if (!loopback_exception(listen->fd, listen->family, &dst_addr, ifr.ifr_name) &&
++	       !label_exception(if_index, listen->family, &dst_addr))
+ 	     return;
+ 	}
+ 
+diff --git a/src/lease.c b/src/lease.c
+index a4560ba..b85cf57 100644
+--- a/src/lease.c
++++ b/src/lease.c
+@@ -345,11 +345,12 @@ void lease_update_file(time_t now)
+ }
+ 
+ 
+-static int find_interface_v4(struct in_addr local, int if_index, 
++static int find_interface_v4(struct in_addr local, int if_index, char *label,
+ 			     struct in_addr netmask, struct in_addr broadcast, void *vparam)
+ {
+   struct dhcp_lease *lease;
+   
++  (void) label;
+   (void) broadcast;
+   (void) vparam;
+ 
+diff --git a/src/netlink.c b/src/netlink.c
+index 0881b71..78d0926 100644
+--- a/src/netlink.c
++++ b/src/netlink.c
+@@ -215,7 +215,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
+ 		if (ifa->ifa_family == AF_INET)
+ 		  {
+ 		    struct in_addr netmask, addr, broadcast;
+-		    
++		    char *label = NULL;
++
+ 		    netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));
+ 		    addr.s_addr = 0;
+ 		    broadcast.s_addr = 0;
+@@ -226,12 +227,14 @@ int iface_enumerate(int family, void *parm, int (*callback)())
+ 			  addr = *((struct in_addr *)(rta+1));
+ 			else if (rta->rta_type == IFA_BROADCAST)
+ 			  broadcast = *((struct in_addr *)(rta+1));
++			else if (rta->rta_type == IFA_LABEL)
++			  label = RTA_DATA(rta);
+ 			
+ 			rta = RTA_NEXT(rta, len1);
+ 		      }
+ 		    
+ 		    if (addr.s_addr && callback_ok)
+-		      if (!((*callback)(addr, ifa->ifa_index, netmask, broadcast, parm)))
++		      if (!((*callback)(addr, ifa->ifa_index, label,  netmask, broadcast, parm)))
+ 			callback_ok = 0;
+ 		  }
+ #ifdef HAVE_IPV6
+diff --git a/src/network.c b/src/network.c
+index 792914b..473e85f 100644
+--- a/src/network.c
++++ b/src/network.c
+@@ -204,7 +204,27 @@ int loopback_exception(int fd, int family, struct all_addr *addr, char *name)
+   return 0;
+ }
+ 
+-static int iface_allowed(struct irec **irecp, int if_index, 
++/* If we're configured with something like --interface=eth0:0 then we'll listen correctly
++   on the relevant address, but the name of the arrival interface, derived from the
++   index won't match the config. Check that we found an interface address for the arrival 
++   interface: daemon->interfaces must be up-to-date. */
++int label_exception(int index, int family, struct all_addr *addr)
++{
++  struct irec *iface;
++
++  /* labels only supported on IPv4 addresses. */
++  if (family != AF_INET)
++    return 0;
++
++  for (iface = daemon->interfaces; iface; iface = iface->next)
++    if (iface->index == index && iface->addr.sa.sa_family == AF_INET &&
++	iface->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
++      return 1;
++
++  return 0;
++}
++
++static int iface_allowed(struct irec **irecp, int if_index, char *label,
+ 			 union mysockaddr *addr, struct in_addr netmask, int dad) 
+ {
+   struct irec *iface;
+@@ -242,8 +262,8 @@ static int iface_allowed(struct irec **irecp, int if_index,
+   loopback = ifr.ifr_flags & IFF_LOOPBACK;
+   
+   if (loopback)
+-     dhcp_ok = 0;
+-
++    dhcp_ok = 0;
++  
+   if (ioctl(fd, SIOCGIFMTU, &ifr) != -1)
+     mtu = ifr.ifr_mtu;
+   
+@@ -272,13 +292,16 @@ static int iface_allowed(struct irec **irecp, int if_index,
+ 	}
+     }
+   
++  if (!label)
++    label = ifr.ifr_name;
++
+   if (addr->sa.sa_family == AF_INET &&
+-      !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, &auth_dns))
++      !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, label, &auth_dns))
+     return 1;
+ 
+ #ifdef HAVE_IPV6
+   if (addr->sa.sa_family == AF_INET6 &&
+-      !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, &auth_dns))
++      !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, label, &auth_dns))
+     return 1;
+ #endif
+     
+@@ -348,11 +371,11 @@ static int iface_allowed_v6(struct in6_addr *local, int prefix,
+   addr.in6.sin6_port = htons(daemon->port);
+   addr.in6.sin6_scope_id = if_index;
+   
+-  return iface_allowed((struct irec **)vparam, if_index, &addr, netmask, !!(flags & IFACE_TENTATIVE));
++  return iface_allowed((struct irec **)vparam, if_index, NULL, &addr, netmask, !!(flags & IFACE_TENTATIVE));
+ }
+ #endif
+ 
+-static int iface_allowed_v4(struct in_addr local, int if_index, 
++static int iface_allowed_v4(struct in_addr local, int if_index, char *label,
+ 			    struct in_addr netmask, struct in_addr broadcast, void *vparam)
+ {
+   union mysockaddr addr;
+@@ -366,7 +389,7 @@ static int iface_allowed_v4(struct in_addr local, int if_index,
+   addr.in.sin_addr = local;
+   addr.in.sin_port = htons(daemon->port);
+ 
+-  return iface_allowed((struct irec **)vparam, if_index, &addr, netmask, 0);
++  return iface_allowed((struct irec **)vparam, if_index, label, &addr, netmask, 0);
+ }
+    
+ int enumerate_interfaces(void)
+diff --git a/src/tftp.c b/src/tftp.c
+index 960b1ee..d7d050f 100644
+--- a/src/tftp.c
++++ b/src/tftp.c
+@@ -202,7 +202,8 @@ void tftp_request(struct listener *listen, time_t now)
+ 	{
+ 	  if (!option_bool(OPT_CLEVERBIND))
+ 	    enumerate_interfaces(); 
+-	  if (!loopback_exception(listen->tftpfd, listen->family, &addra, name))
++	  if (!loopback_exception(listen->tftpfd, listen->family, &addra, name) &&
++	      !label_exception(if_index, listen->family, &addra) )
+ 	    return;
+ 	}
+       
+-- 
+1.8.1.4
+
diff --git a/dnsmasq-2.66-Tighten_checks_in_legal_hostname.patch b/dnsmasq-2.66-Tighten_checks_in_legal_hostname.patch
new file mode 100644
index 0000000..cc6f603
--- /dev/null
+++ b/dnsmasq-2.66-Tighten_checks_in_legal_hostname.patch
@@ -0,0 +1,45 @@
+From 7abb69b5dc8dbe369be36bd7bf23c039b036acd1 Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon at thekelleys.org.uk>
+Date: Mon, 29 Apr 2013 10:52:16 +0100
+Subject: [PATCH] Tighten checks in legal_hostname().
+
+---
+ src/util.c | 14 +++++++++-----
+ 1 file changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/src/util.c b/src/util.c
+index 848e01b..af4031c 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -142,19 +142,23 @@ static int check_name(char *in)
+ int legal_hostname(char *name)
+ {
+   char c;
++  int first;
+ 
+   if (!check_name(name))
+     return 0;
+ 
+-  for (; (c = *name); name++)
++  for (first = 1; (c = *name); name++, first = 0)
+     /* check for legal char a-z A-Z 0-9 - _ . */
+     {
+       if ((c >= 'A' && c <= 'Z') ||
+-	  (c >= 'a' && c <= 'z') ||
+-	  (c >= '0' && c <= '9') ||
+-	  c == '-' || c == '_')
++	  (c >= 'a' && c <= 'z'))
+ 	continue;
+-      
++
++      if (!first && 
++	  ((c >= '0' && c <= '9') ||
++	   c == '-' || c == '_'))
++	continue;
++
+       /* end of hostname part */
+       if (c == '.')
+ 	return 1;
+-- 
+1.8.1.4
+
diff --git a/dnsmasq-2.66-Use-dnsmasq-as-default-DNS-server-for-RA-only-if-it-is-doing-DNS.patch b/dnsmasq-2.66-Use-dnsmasq-as-default-DNS-server-for-RA-only-if-it-is-doing-DNS.patch
new file mode 100644
index 0000000..22139ee
--- /dev/null
+++ b/dnsmasq-2.66-Use-dnsmasq-as-default-DNS-server-for-RA-only-if-it-is-doing-DNS.patch
@@ -0,0 +1,30 @@
+From ab915f837c1db9b8b095158b41028ea71246d68d Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon at thekelleys.org.uk>
+Date: Tue, 30 Apr 2013 10:41:28 +0100
+Subject: [PATCH] Only use ourselves as default DNS server for RA if we're
+ doing DNS.
+
+This makes RA the same as DHCP4/6
+---
+ src/radv.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/radv.c b/src/radv.c
+index a708758..72a93cb 100644
+--- a/src/radv.c
++++ b/src/radv.c
+@@ -300,9 +300,9 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
+ 	}
+     }
+ 	
+-  if (!done_dns)
++  if (daemon->port == NAMESERVER_PORT && !done_dns)
+     {
+-      /* default == us. */
++      /* default == us, as long as we are supplying DNS service. */
+       put_opt6_char(ICMP6_OPT_RDNSS);
+       put_opt6_char(3);
+       put_opt6_short(0);
+-- 
+1.8.1.4
+
diff --git a/dnsmasq-2.66-replace-inet_addr-with-inet_pton-in-option-c.patch b/dnsmasq-2.66-replace-inet_addr-with-inet_pton-in-option-c.patch
new file mode 100644
index 0000000..d21a776
--- /dev/null
+++ b/dnsmasq-2.66-replace-inet_addr-with-inet_pton-in-option-c.patch
@@ -0,0 +1,164 @@
+From ddd9a6b499ae601231070854c562611a79e004c0 Mon Sep 17 00:00:00 2001
+From: Simon Kelley <simon at thekelleys.org.uk>
+Date: Mon, 29 Apr 2013 17:00:21 +0100
+Subject: [PATCH] replace inet_addr with inet_pton() in src/option.c
+
+---
+ src/option.c | 52 ++++++++++++++++++++++++++--------------------------
+ 1 file changed, 26 insertions(+), 26 deletions(-)
+
+diff --git a/src/option.c b/src/option.c
+index 20a8668..d2ab689 100644
+--- a/src/option.c
++++ b/src/option.c
+@@ -660,7 +660,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
+   scope_id = split_chr(arg, '%');
+ #endif
+   
+-  if ((addr->in.sin_addr.s_addr = inet_addr(arg)) != (in_addr_t) -1)
++  if (inet_pton(AF_INET, arg, &addr->in.sin_addr) > 0)
+     {
+       addr->in.sin_port = htons(serv_port);	
+       addr->sa.sa_family = source_addr->sa.sa_family = AF_INET;
+@@ -675,7 +675,7 @@ char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_a
+ 	  if (flags)
+ 	    *flags |= SERV_HAS_SOURCE;
+ 	  source_addr->in.sin_port = htons(source_port);
+-	  if ((source_addr->in.sin_addr.s_addr = inet_addr(source)) == (in_addr_t) -1)
++	  if (!(inet_pton(AF_INET, source, &source_addr->in.sin_addr) > 0))
+ 	    {
+ #if defined(SO_BINDTODEVICE)
+ 	      source_addr->in.sin_addr.s_addr = INADDR_ANY;
+@@ -1031,7 +1031,7 @@ static int parse_dhcp_opt(char *errstr, char *arg, int flags)
+ 	      cp = comma;
+ 	      comma = split(cp);
+ 	      slash = split_chr(cp, '/');
+-	      in.s_addr = inet_addr(cp);
++	      inet_pton(AF_INET, cp, &in);
+ 	      if (!slash)
+ 		{
+ 		  memcpy(op, &in, INADDRSZ);
+@@ -1576,7 +1576,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	comma = split(arg);
+ 	new->name = NULL;
+ 	unhide_metas(arg);
+-	if ((new->addr.in.sin_addr.s_addr = inet_addr(arg)) != (in_addr_t)-1)
++	if (inet_pton(AF_INET, arg, &new->addr.in.sin_addr) > 0)
+ 	  new->addr.sa.sa_family = AF_INET;
+ #ifdef HAVE_IPV6
+ 	else if (inet_pton(AF_INET6, arg, &new->addr.in6.sin6_addr) > 0)
+@@ -1927,7 +1927,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+       {
+ 	struct in_addr addr;
+ 	unhide_metas(arg);
+-	if (arg && (addr.s_addr = inet_addr(arg)) != (in_addr_t)-1)
++	if (arg && (inet_pton(AF_INET, arg, &addr) > 0))
+ 	  {
+ 	    struct bogus_addr *baddr = opt_malloc(sizeof(struct bogus_addr));
+ 	    baddr->next = daemon->bogus_addr;
+@@ -1945,7 +1945,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	struct iname *new = opt_malloc(sizeof(struct iname));
+ 	comma = split(arg);
+ 	unhide_metas(arg);
+-	if (arg && (new->addr.in.sin_addr.s_addr = inet_addr(arg)) != (in_addr_t)-1)
++	if (arg && (inet_pton(AF_INET, arg, &new->addr.in.sin_addr) > 0))
+ 	  {
+ 	    new->addr.sa.sa_family = AF_INET;
+ 	    new->addr.in.sin_port = 0;
+@@ -2369,7 +2369,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	      }
+ 	    
+ 	    if (k >= 3 && strchr(a[2], '.') &&  
+-		((new->netmask.s_addr = inet_addr(a[2])) != (in_addr_t)-1))
++		(inet_pton(AF_INET, a[2], &new->netmask) > 0))
+ 	      {
+ 		new->flags |= CONTEXT_NETMASK;
+ 		leasepos = 3;
+@@ -2378,7 +2378,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	      }
+ 	    
+ 	    if (k >= 4 && strchr(a[3], '.') &&  
+-		((new->broadcast.s_addr = inet_addr(a[3])) != (in_addr_t)-1))
++		(inet_pton(AF_INET, a[3], &new->broadcast) > 0))
+ 	      {
+ 		new->flags |= CONTEXT_BRDCAST;
+ 		leasepos = 4;
+@@ -2608,7 +2608,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 		    }		    
+ 		}
+ 	    }
+-	  else if (strchr(a[j], '.') && (in.s_addr = inet_addr(a[j])) != (in_addr_t)-1)
++	  else if (strchr(a[j], '.') && (inet_pton(AF_INET, a[j], &in) > 0))
+ 	    {
+ 	      struct dhcp_config *configs;
+ 	      
+@@ -2805,17 +2805,17 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 		if (comma)
+ 		  {
+ 		    unhide_metas(comma);
+-		    if ((dhcp_next_server.s_addr = inet_addr(comma)) == (in_addr_t)-1) {
+-
+-		      /*
+-		       * The user may have specified the tftp hostname here.
+-		       * save it so that it can be resolved/looked up during
+-		       * actual dhcp_reply().
+-		       */	
+-
+-		      tftp_sname = opt_string_alloc(comma);
+-		      dhcp_next_server.s_addr = 0;
+-		    }
++		    if (!(inet_pton(AF_INET, comma, &dhcp_next_server) > 0))
++		      {
++			/*
++			 * The user may have specified the tftp hostname here.
++			 * save it so that it can be resolved/looked up during
++			 * actual dhcp_reply().
++			 */	
++			
++			tftp_sname = opt_string_alloc(comma);
++			dhcp_next_server.s_addr = 0;
++		      }
+ 		  }
+ 	      }
+ 	    
+@@ -2828,7 +2828,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	    new->next = daemon->boot_config;
+ 	    daemon->boot_config = new;
+ 	  }
+-	
++      
+ 	break;
+       }
+ 
+@@ -3144,7 +3144,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+       while (arg) {
+ 	struct addr_list *new = opt_malloc(sizeof(struct addr_list));
+ 	comma = split(arg);
+-	if ((new->addr.s_addr = inet_addr(arg)) == (in_addr_t)-1)
++	if (!(inet_pton(AF_INET, arg, &new->addr) > 0))
+ 	  ret_err(_("bad dhcp-proxy address"));
+ 	new->next = daemon->override_relays;
+ 	daemon->override_relays = new;
+@@ -3187,15 +3187,15 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
+ 	dash = split_chr(a[0], '-');
+ 
+ 	if ((k < 2) || 
+-	    ((new->in.s_addr = inet_addr(a[0])) == (in_addr_t)-1) ||
+-	    ((new->out.s_addr = inet_addr(a[1])) == (in_addr_t)-1))
++	    (!(inet_pton(AF_INET, a[0], &new->in) > 0)) ||
++	    (!(inet_pton(AF_INET, a[1], &new->out) > 0)))
+ 	  option = '?';
+ 	
+ 	if (k == 3)
+-	  new->mask.s_addr = inet_addr(a[2]);
++	  inet_pton(AF_INET, a[2], &new->mask);
+ 	
+ 	if (dash && 
+-	    ((new->end.s_addr = inet_addr(dash)) == (in_addr_t)-1 ||
++	    (!(inet_pton(AF_INET, dash, &new->end) > 0) ||
+ 	     !is_same_net(new->in, new->end, new->mask) ||
+ 	     ntohl(new->in.s_addr) > ntohl(new->end.s_addr)))
+ 	  ret_err(_("invalid alias range"));
+-- 
+1.8.1.4
+
diff --git a/dnsmasq.spec b/dnsmasq.spec
index f5f41cc..91af9a6 100644
--- a/dnsmasq.spec
+++ b/dnsmasq.spec
@@ -11,7 +11,7 @@
 
 Name:           dnsmasq
 Version:        2.66
-Release:        5%{?extraversion}%{?dist}
+Release:        6%{?extraversion}%{?dist}
 Summary:        A lightweight DHCP/caching DNS server
 
 Group:          System Environment/Daemons
@@ -37,6 +37,16 @@ Patch5:         %{name}-2.66-Manpage-typos.patch
 Patch6:         %{name}-2.66-Note-that-dhcp_lease_time-and-dhcp_release-work-for-IPv4.patch
 # commit 86e92f998379d219e10517dfa2c42f544ba164ce
 Patch7:         %{name}-2.66-dhcp-match-now-work-with-BOOTP.patch
+# commit 7abb69b5dc8dbe369be36bd7bf23c039b036acd1
+Patch8:         %{name}-2.66-Tighten_checks_in_legal_hostname.patch
+# commit ddd9a6b499ae601231070854c562611a79e004c0
+Patch9:         %{name}-2.66-replace-inet_addr-with-inet_pton-in-option-c.patch
+# commit b915f837c1db9b8b095158b41028ea71246d68d
+Patch10:        %{name}-2.66-Use-dnsmasq-as-default-DNS-server-for-RA-only-if-it-is-doing-DNS.patch
+# commit 3f2873d42c4d7e7dba32b6e64a3687d43928bc8e - Bug #962246
+Patch11:        %{name}-2.66-Handle_IPv4_interface_address_labels_in_Linux.patch
+# commit cfcad42ff1ddee8e64d120f18016a654152d0215 - Bug #962874
+Patch12:        %{name}-2.66-Fix_failure_to_start_with_ENOTSOCK.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -80,6 +90,11 @@ query/remove a DHCP server's leases.
 %patch5 -p1
 %patch6 -p1 -b .utils_work_only_ipv4
 %patch7 -p1 -b .dhcp-match_bootp
+%patch8 -p1 -b .hosname_checks
+%patch9 -p1 -b .inet_pton
+%patch10 -p1 -b .default_dns_server
+%patch11 -p1 -b .interface_aliases
+%patch12 -p1 -b .enotsock_failure
 
 # use /var/lib/dnsmasq instead of /var/lib/misc
 for file in dnsmasq.conf.example man/dnsmasq.8 man/es/dnsmasq.8 src/config.h; do
@@ -164,6 +179,14 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/dhcp_*
 
 %changelog
+* Fri May 17 2013 Tomas Hozza <thozza at redhat.com> - 2.66-6
+- include several fixies from upstream repo:
+  - Tighten hostname checks in legal hostname() function
+  - Replace inet_addr() with inet_pton() in src/option.c
+  - Use dnsmasq as default DNS server for RA only if it's doing DNS
+  - Handle IPv4 interface address labels (aliases) in Linux (#962246)
+  - Fix failure to start with ENOTSOCK (#962874)
+
 * Tue Apr 30 2013 Tomas Hozza <thozza at redhat.com> - 2.66-5
 - dnsmasq unit file cleanup
   - drop forking Type and PIDfile and rather start dnsmasq with "-k" option


More information about the scm-commits mailing list