Compare commits

...
8 Commits
8 changed files with 141 additions and 35 deletions

No files matched your search

+15 -1
View File
@@ -19,9 +19,12 @@ version 2.64
Flag DHCP or DHCPv6 in starup logging. Thanks to Flag DHCP or DHCPv6 in starup logging. Thanks to
Vladislav Grishenko for the patch. Vladislav Grishenko for the patch.
Add SetServersEX method in DBus interface. Thanks to Dan Add SetServersEx method in DBus interface. Thanks to Dan
Williams for the patch. Williams for the patch.
Add SetDomainServers method in DBus interface. Thanks to
Roy Marples for the patch.
Fix build with later Lua libraries. Thansk to Cristian Fix build with later Lua libraries. Thansk to Cristian
Rodriguez for the patch. Rodriguez for the patch.
@@ -45,6 +48,17 @@ version 2.64
subnet, --dhcp-range=::,static Useful for Stateless subnet, --dhcp-range=::,static Useful for Stateless
DHCPv6. Thanks to Vladislav Grishenko for the patch. DHCPv6. Thanks to Vladislav Grishenko for the patch.
Don't include lease-time in DHCPACK replies to DHCPINFORM
queries, since RFC-2131 says we shouldn't. Thanks to
Wouter Ibens for pointing this out.
Makefile tweak to do dependency checking on header files.
Thanks to Johan Peeters for the patch.
Check interface for outgoing unsolicited router
advertisements, rather than relying on interface address
configuration. Thanks to Gene Czarinski for the patch.
version 2.63 version 2.63
Do duplicate dhcp-host address check in --test mode. Do duplicate dhcp-host address check in --test mode.
+8 -3
View File
@@ -79,7 +79,8 @@ all : $(BUILDDIR)
clean : clean :
rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot rm -f *~ $(BUILDDIR)/*.mo contrib/*/*~ */*~ $(BUILDDIR)/*.pot
rm -f $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq core */core rm -f $(BUILDDIR)/.configured $(BUILDDIR)/*.o $(BUILDDIR)/dnsmasq.a $(BUILDDIR)/dnsmasq
rm -rf core */core
install : all install-common install : all install-common
@@ -113,7 +114,11 @@ $(BUILDDIR):
mkdir -p $(BUILDDIR) mkdir -p $(BUILDDIR)
# rules below are targets in recusive makes with cwd=$(SRC) # rules below are targets in recusive makes with cwd=$(BUILDDIR)
.configured: $(hdrs)
@rm -f *.o
@touch $@
$(objs:.o=.c) $(hdrs): $(objs:.o=.c) $(hdrs):
ln -s $(top)/$(SRC)/$@ . ln -s $(top)/$(SRC)/$@ .
@@ -121,7 +126,7 @@ $(objs:.o=.c) $(hdrs):
.c.o: .c.o:
$(CC) $(CFLAGS) $(COPTS) $(i18n) $(build_cflags) $(RPM_OPT_FLAGS) -c $< $(CC) $(CFLAGS) $(COPTS) $(i18n) $(build_cflags) $(RPM_OPT_FLAGS) -c $<
dnsmasq : $(hdrs) $(objs) dnsmasq : .configured $(hdrs) $(objs)
$(CC) $(LDFLAGS) -o $@ $(objs) $(build_libs) $(LIBS) $(CC) $(LDFLAGS) -o $@ $(objs) $(build_libs) $(LIBS)
dnsmasq.pot : $(objs:.o=.c) $(hdrs) dnsmasq.pot : $(objs:.o=.c) $(hdrs)
+17
View File
@@ -137,6 +137,23 @@ Each call to SetServersEx completely replaces the set of servers
specified by via the DBus, but it leaves any servers specified via the specified by via the DBus, but it leaves any servers specified via the
command line or /etc/dnsmasq.conf or /etc/resolv.conf alone. command line or /etc/dnsmasq.conf or /etc/resolv.conf alone.
SetDomainServers
----------------
Yes another variation for setting DNS servers, with the capability of
SetServersEx, but without using arrays of arrays, which are not
sendable with dbus-send. The arguments are an array of strings which
are identical to the equivalent arguments --server, so the example
for SetServersEx is represented as
[
"/foobar.com/1.2.3.4"
"/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
]
2. SIGNALS 2. SIGNALS
---------- ----------
+8 -2
View File
@@ -83,7 +83,9 @@ or launchd.
Debug mode: don't fork to the background, don't write a pid file, Debug mode: don't fork to the background, don't write a pid file,
don't change user id, generate a complete cache dump on receipt on don't change user id, generate a complete cache dump on receipt on
SIGUSR1, log to stderr as well as syslog, don't fork new processes SIGUSR1, log to stderr as well as syslog, don't fork new processes
to handle TCP queries. to handle TCP queries. Note that this option is for use in debugging
only, to stop dnsmasq daemonising in production, use
.B -k.
.TP .TP
.B \-q, --log-queries .B \-q, --log-queries
Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1.
@@ -584,7 +586,11 @@ which tells dnsmasq to enable DHCP for the network specified, but not
to dynamically allocate IP addresses: only hosts which have static to dynamically allocate IP addresses: only hosts which have static
addresses given via addresses given via
.B dhcp-host .B dhcp-host
or from /etc/ethers will be served. or from /etc/ethers will be served. A static-only subnet with address
all zeros may be used as a "catch-all" address to enable replies to all
Information-request packets on a subnet which is provided with
stateless DHCPv6, ie
.B --dhcp=range=::,static
For IPv4, the <mode> may be For IPv4, the <mode> may be
.B proxy .B proxy
+88 -16
View File
@@ -38,6 +38,9 @@ const char* introspection_xml_template =
" <method name=\"SetServers\">\n" " <method name=\"SetServers\">\n"
" <arg name=\"servers\" direction=\"in\" type=\"av\"/>\n" " <arg name=\"servers\" direction=\"in\" type=\"av\"/>\n"
" </method>\n" " </method>\n"
" <method name=\"SetDomainServers\">\n"
" <arg name=\"servers\" direction=\"in\" type=\"as\"/>\n"
" </method>\n"
" <method name=\"SetServersEx\">\n" " <method name=\"SetServersEx\">\n"
" <arg name=\"servers\" direction=\"in\" type=\"aas\"/>\n" " <arg name=\"servers\" direction=\"in\" type=\"aas\"/>\n"
" </method>\n" " </method>\n"
@@ -292,11 +295,14 @@ static void dbus_read_servers(DBusMessage *message)
cleanup_dbus(); cleanup_dbus();
} }
static DBusMessage* dbus_read_servers_ex(DBusMessage *message) static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
{ {
DBusMessageIter iter, array_iter, string_iter; DBusMessageIter iter, array_iter, string_iter;
DBusMessage *error = NULL; DBusMessage *error = NULL;
const char *addr_err; const char *addr_err;
char *dup = NULL;
my_syslog(LOG_INFO, _("setting upstream servers from DBus"));
if (!dbus_message_iter_init(message, &iter)) if (!dbus_message_iter_init(message, &iter))
{ {
@@ -306,10 +312,10 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
/* check that the message contains an array of arrays */ /* check that the message contains an array of arrays */
if ((dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) || if ((dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) ||
(dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_ARRAY)) (dbus_message_iter_get_element_type(&iter) != (strings ? DBUS_TYPE_STRING : DBUS_TYPE_ARRAY)))
{ {
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Expected array of string arrays"); strings ? "Expected array of string" : "Expected array of string arrays");
} }
mark_dbus(); mark_dbus();
@@ -321,8 +327,51 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
const char *str = NULL; const char *str = NULL;
union mysockaddr addr, source_addr; union mysockaddr addr, source_addr;
char interface[IF_NAMESIZE]; char interface[IF_NAMESIZE];
char *str_addr; char *str_addr, *str_domain = NULL;
if (strings)
{
dbus_message_iter_get_basic(&array_iter, &str);
if (!str || !strlen (str))
{
error = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Empty string");
break;
}
/* dup the string because it gets modified during parsing */
if (!(dup = str_domain = whine_malloc(strlen(str)+1)))
break;
strcpy(str_domain, str);
/* point to address part of old string for error message */
if ((str_addr = strrchr(str, '/')))
str = str_addr+1;
if ((str_addr = strrchr(str_domain, '/')))
{
if (*str_domain != '/' || str_addr == str_domain)
{
error = dbus_message_new_error_printf(message,
DBUS_ERROR_INVALID_ARGS,
"No domain terminator '%s'",
str);
break;
}
*str_addr++ = 0;
str_domain++;
}
else
{
str_addr = str_domain;
str_domain = NULL;
}
}
else
{
/* check the types of the struct and its elements */ /* check the types of the struct and its elements */
if ((dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY) || if ((dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY) ||
(dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_STRING)) (dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_STRING))
@@ -350,22 +399,19 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
break; break;
} }
/* dup the string because it gets modified during parsing */
if (!(dup = str_addr = whine_malloc(strlen(str)+1)))
break;
strcpy(str_addr, str);
}
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
memset(&source_addr, 0, sizeof(source_addr)); memset(&source_addr, 0, sizeof(source_addr));
memset(&interface, 0, sizeof(interface)); memset(&interface, 0, sizeof(interface));
/* dup the string because it gets modified during parsing */
str_addr = strdup(str);
if (!str_addr)
{
error = dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Out of memory parsing IP address");
break;
}
/* parse the IP address */ /* parse the IP address */
addr_err = parse_server(str_addr, &addr, &source_addr, (char *) &interface, NULL); addr_err = parse_server(str_addr, &addr, &source_addr, (char *) &interface, NULL);
free(str_addr);
if (addr_err) if (addr_err)
{ {
@@ -375,6 +421,24 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
break; break;
} }
if (strings)
{
char *p;
do {
if (str_domain)
{
if ((p = strchr(str_domain, '/')))
*p++ = 0;
}
else
p = NULL;
add_update_server(&addr, &source_addr, interface, str_domain);
} while ((str_domain = p));
}
else
{
/* jump past the address to the domain list (if any) */ /* jump past the address to the domain list (if any) */
dbus_message_iter_next (&string_iter); dbus_message_iter_next (&string_iter);
@@ -387,6 +451,7 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
add_update_server(&addr, &source_addr, interface, str); add_update_server(&addr, &source_addr, interface, str);
} while (dbus_message_iter_get_arg_type(&string_iter) == DBUS_TYPE_STRING); } while (dbus_message_iter_get_arg_type(&string_iter) == DBUS_TYPE_STRING);
}
/* jump to next element in outer array */ /* jump to next element in outer array */
dbus_message_iter_next(&array_iter); dbus_message_iter_next(&array_iter);
@@ -394,6 +459,9 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message)
cleanup_dbus(); cleanup_dbus();
if (dup)
free(dup);
return error; return error;
} }
@@ -432,8 +500,12 @@ DBusHandlerResult message_handler(DBusConnection *connection,
} }
else if (strcmp(method, "SetServersEx") == 0) else if (strcmp(method, "SetServersEx") == 0)
{ {
my_syslog(LOG_INFO, _("setting upstream servers from DBus")); reply = dbus_read_servers_ex(message, 0);
reply = dbus_read_servers_ex(message); check_servers();
}
else if (strcmp(method, "SetDomainServers") == 0)
{
reply = dbus_read_servers_ex(message, 1);
check_servers(); check_servers();
} }
else if (strcmp(method, "ClearCache") == 0) else if (strcmp(method, "ClearCache") == 0)
+2 -2
View File
@@ -371,9 +371,9 @@ static int nl_async(struct nlmsghdr *h)
} }
return 0; return 0;
} }
#ifdef HAVE_DHCP6
else if (h->nlmsg_type == RTM_NEWADDR) else if (h->nlmsg_type == RTM_NEWADDR)
{ {
#ifdef HAVE_DHCP6
/* force RAs to sync new network and pick up new interfaces. */ /* force RAs to sync new network and pick up new interfaces. */
if (daemon->ra_contexts) if (daemon->ra_contexts)
{ {
@@ -383,9 +383,9 @@ static int nl_async(struct nlmsghdr *h)
iface_enumerate and can't re-enter it now */ iface_enumerate and can't re-enter it now */
send_alarm(0, 0); send_alarm(0, 0);
} }
#endif
return 1; /* clever bind mode - rescan */ return 1; /* clever bind mode - rescan */
} }
#endif
return 0; return 0;
} }
+2 -1
View File
@@ -482,7 +482,8 @@ time_t periodic_ra(time_t now)
ever be able to send ra's and satistfy it. */ ever be able to send ra's and satistfy it. */
if (iface_enumerate(AF_INET6, &param, iface_search)) if (iface_enumerate(AF_INET6, &param, iface_search))
context->ra_time = 0; context->ra_time = 0;
else if (indextoname(daemon->icmp6fd, param.iface, interface)) else if (indextoname(daemon->icmp6fd, param.iface, interface) &&
iface_check(AF_LOCAL, NULL, interface))
send_ra(param.iface, interface, NULL); send_ra(param.iface, interface, NULL);
} }
+1 -10
View File
@@ -1387,6 +1387,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if (lease) if (lease)
{ {
lease_set_interface(lease, int_index, now);
if (override.s_addr != 0) if (override.s_addr != 0)
lease->override = override; lease->override = override;
else else
@@ -1397,16 +1398,6 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr));
if (lease)
{
if (lease->expires == 0)
time = 0xffffffff;
else
time = (unsigned int)difftime(lease->expires, now);
option_put(mess, end, OPTION_LEASE_TIME, 4, time);
lease_set_interface(lease, int_index, now);
}
do_options(context, mess, end, req_options, hostname, get_domain(mess->ciaddr), do_options(context, mess, end, req_options, hostname, get_domain(mess->ciaddr),
netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now); netid, subnet_addr, fqdn_flags, borken_opt, pxearch, uuid, vendor_class_len, now);