mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Alternate DBus service name via --enable-dbus
This commit is contained in:
@@ -40,6 +40,11 @@ version 2.63
|
|||||||
|
|
||||||
Update French translation. Thanks to Gildas Le Nadan.
|
Update French translation. Thanks to Gildas Le Nadan.
|
||||||
|
|
||||||
|
Allow a DBus service name to be given with --enable-dbus
|
||||||
|
which overrides the default,
|
||||||
|
uk.org.thekelleys.dnsmasq. Thanks to Mathieu
|
||||||
|
Trudel-Lapierre for the patch.
|
||||||
|
|
||||||
|
|
||||||
version 2.62
|
version 2.62
|
||||||
Update German translation. Thanks to Conrad Kostecki.
|
Update German translation. Thanks to Conrad Kostecki.
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ and avoids startup races with the provider of nameserver information.
|
|||||||
|
|
||||||
|
|
||||||
Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
|
Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
|
||||||
and a single object: /uk/org/thekelleys/dnsmasq
|
and a single object: /uk/org/thekelleys/dnsmasq
|
||||||
|
The name of the service may be changed by giving an argument to --enable-dbus.
|
||||||
|
|
||||||
1. METHODS
|
1. METHODS
|
||||||
----------
|
----------
|
||||||
|
|||||||
@@ -271,11 +271,13 @@ time is the one used.
|
|||||||
Don't read /etc/resolv.conf. Get upstream servers only from the command
|
Don't read /etc/resolv.conf. Get upstream servers only from the command
|
||||||
line or the dnsmasq configuration file.
|
line or the dnsmasq configuration file.
|
||||||
.TP
|
.TP
|
||||||
.B \-1, --enable-dbus
|
.B \-1, --enable-dbus[=<service-name>]
|
||||||
Allow dnsmasq configuration to be updated via DBus method calls. The
|
Allow dnsmasq configuration to be updated via DBus method calls. The
|
||||||
configuration which can be changed is upstream DNS servers (and
|
configuration which can be changed is upstream DNS servers (and
|
||||||
corresponding domains) and cache clear. Requires that dnsmasq has
|
corresponding domains) and cache clear. Requires that dnsmasq has
|
||||||
been built with DBus support.
|
been built with DBus support. If the service name is given, dnsmasq
|
||||||
|
provides service at that name, rather than the default which is
|
||||||
|
.B uk.org.thekelleys.dnsmasq
|
||||||
.TP
|
.TP
|
||||||
.B \-o, --strict-order
|
.B \-o, --strict-order
|
||||||
By default, dnsmasq will send queries to any of the upstream servers
|
By default, dnsmasq will send queries to any of the upstream servers
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#define LOG_MAX 5 /* log-queue length */
|
#define LOG_MAX 5 /* log-queue length */
|
||||||
#define RANDFILE "/dev/urandom"
|
#define RANDFILE "/dev/urandom"
|
||||||
#define EDNS0_OPTION_MAC 5 /* dyndns.org temporary assignment */
|
#define EDNS0_OPTION_MAC 5 /* dyndns.org temporary assignment */
|
||||||
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* DBUS interface specifics */
|
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
|
||||||
#define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
|
#define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
|
||||||
|
|
||||||
/* compile-time options: uncomment below to enable or do eg.
|
/* compile-time options: uncomment below to enable or do eg.
|
||||||
|
|||||||
30
src/dbus.c
30
src/dbus.c
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
const char* introspection_xml =
|
const char* introspection_xml_template =
|
||||||
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
|
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
|
||||||
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
|
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
|
||||||
"<node name=\"" DNSMASQ_PATH "\">\n"
|
"<node name=\"" DNSMASQ_PATH "\">\n"
|
||||||
@@ -29,7 +29,7 @@ const char* introspection_xml =
|
|||||||
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
|
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
" <interface name=\"" DNSMASQ_SERVICE "\">\n"
|
" <interface name=\"%s\">\n"
|
||||||
" <method name=\"ClearCache\">\n"
|
" <method name=\"ClearCache\">\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"GetVersion\">\n"
|
" <method name=\"GetVersion\">\n"
|
||||||
@@ -56,6 +56,8 @@ const char* introspection_xml =
|
|||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
"</node>\n";
|
"</node>\n";
|
||||||
|
|
||||||
|
static char *introspection_xml = NULL;
|
||||||
|
|
||||||
struct watch {
|
struct watch {
|
||||||
DBusWatch *watch;
|
DBusWatch *watch;
|
||||||
struct watch *next;
|
struct watch *next;
|
||||||
@@ -266,11 +268,21 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
|
|
||||||
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
||||||
{
|
{
|
||||||
DBusMessage *reply = dbus_message_new_method_return(message);
|
DBusMessage *reply;
|
||||||
|
|
||||||
dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection_xml, DBUS_TYPE_INVALID);
|
/* string length: "%s" provides space for termination zero */
|
||||||
dbus_connection_send (connection, reply, NULL);
|
if (!introspection_xml &&
|
||||||
dbus_message_unref (reply);
|
(introspection_xml = whine_malloc(strlen(introspection_xml_template) + strlen(daemon->dbus_name))))
|
||||||
|
sprintf(introspection_xml, introspection_xml_template, daemon->dbus_name);
|
||||||
|
|
||||||
|
if (introspection_xml)
|
||||||
|
{
|
||||||
|
reply = dbus_message_new_method_return(message);
|
||||||
|
|
||||||
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection_xml, DBUS_TYPE_INVALID);
|
||||||
|
dbus_connection_send (connection, reply, NULL);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "GetVersion") == 0)
|
else if (strcmp(method, "GetVersion") == 0)
|
||||||
{
|
{
|
||||||
@@ -315,7 +327,7 @@ char *dbus_init(void)
|
|||||||
dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
|
dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
dbus_error_init (&dbus_error);
|
dbus_error_init (&dbus_error);
|
||||||
dbus_bus_request_name (connection, DNSMASQ_SERVICE, 0, &dbus_error);
|
dbus_bus_request_name (connection, daemon->dbus_name, 0, &dbus_error);
|
||||||
if (dbus_error_is_set (&dbus_error))
|
if (dbus_error_is_set (&dbus_error))
|
||||||
return (char *)dbus_error.message;
|
return (char *)dbus_error.message;
|
||||||
|
|
||||||
@@ -325,7 +337,7 @@ char *dbus_init(void)
|
|||||||
|
|
||||||
daemon->dbus = connection;
|
daemon->dbus = connection;
|
||||||
|
|
||||||
if ((message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, "Up")))
|
if ((message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, "Up")))
|
||||||
{
|
{
|
||||||
dbus_connection_send(connection, message, NULL);
|
dbus_connection_send(connection, message, NULL);
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
@@ -430,7 +442,7 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, action_str)))
|
if (!(message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, action_str)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbus_message_iter_init_append(message, &args);
|
dbus_message_iter_init_append(message, &args);
|
||||||
|
|||||||
@@ -777,6 +777,7 @@ extern struct daemon {
|
|||||||
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
|
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
|
||||||
unsigned int duid_enterprise, duid_config_len;
|
unsigned int duid_enterprise, duid_config_len;
|
||||||
unsigned char *duid_config;
|
unsigned char *duid_config;
|
||||||
|
char *dbus_name;
|
||||||
|
|
||||||
/* globally used stuff for DNS */
|
/* globally used stuff for DNS */
|
||||||
char *packet; /* packet buffer */
|
char *packet; /* packet buffer */
|
||||||
|
|||||||
12
src/option.c
12
src/option.c
@@ -184,7 +184,7 @@ static const struct myoption opts[] =
|
|||||||
{ "localise-queries", 0, 0, 'y' },
|
{ "localise-queries", 0, 0, 'y' },
|
||||||
{ "txt-record", 1, 0, 'Y' },
|
{ "txt-record", 1, 0, 'Y' },
|
||||||
{ "dns-rr", 1, 0, LOPT_RR },
|
{ "dns-rr", 1, 0, LOPT_RR },
|
||||||
{ "enable-dbus", 0, 0, '1' },
|
{ "enable-dbus", 2, 0, '1' },
|
||||||
{ "bootp-dynamic", 2, 0, '3' },
|
{ "bootp-dynamic", 2, 0, '3' },
|
||||||
{ "dhcp-mac", 1, 0, '4' },
|
{ "dhcp-mac", 1, 0, '4' },
|
||||||
{ "no-ping", 0, 0, '5' },
|
{ "no-ping", 0, 0, '5' },
|
||||||
@@ -326,7 +326,7 @@ static struct {
|
|||||||
{ LOPT_INTNAME, ARG_DUP, "<name>,<interface>", gettext_noop("Give DNS name to IPv4 address of interface."), NULL },
|
{ LOPT_INTNAME, ARG_DUP, "<name>,<interface>", gettext_noop("Give DNS name to IPv4 address of interface."), NULL },
|
||||||
{ 'z', OPT_NOWILD, NULL, gettext_noop("Bind only to interfaces in use."), NULL },
|
{ 'z', OPT_NOWILD, NULL, gettext_noop("Bind only to interfaces in use."), NULL },
|
||||||
{ 'Z', OPT_ETHERS, NULL, gettext_noop("Read DHCP static host information from %s."), ETHERSFILE },
|
{ 'Z', OPT_ETHERS, NULL, gettext_noop("Read DHCP static host information from %s."), ETHERSFILE },
|
||||||
{ '1', OPT_DBUS, NULL, gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL },
|
{ '1', ARG_ONE, "[=<busname>]", gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL },
|
||||||
{ '2', ARG_DUP, "<interface>", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
|
{ '2', ARG_DUP, "<interface>", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
|
||||||
{ '3', ARG_DUP, "[=tag:<tag>]...", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
|
{ '3', ARG_DUP, "[=tag:<tag>]...", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
|
||||||
{ '4', ARG_DUP, "set:<tag>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
|
{ '4', ARG_DUP, "set:<tag>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
|
||||||
@@ -1285,6 +1285,14 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case '1': /* --enable-dbus */
|
||||||
|
set_option_bool(OPT_DBUS);
|
||||||
|
if (arg)
|
||||||
|
daemon->dbus_name = opt_string_alloc(arg);
|
||||||
|
else
|
||||||
|
daemon->dbus_name = DNSMASQ_SERVICE;
|
||||||
|
break;
|
||||||
|
|
||||||
case '8': /* --log-facility */
|
case '8': /* --log-facility */
|
||||||
/* may be a filename */
|
/* may be a filename */
|
||||||
if (strchr(arg, '/') || strcmp (arg, "-") == 0)
|
if (strchr(arg, '/') || strcmp (arg, "-") == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user