mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 02:08:24 +00:00
Fix breakage in DBus FilterA and FilterAAAA methods.
In generalising the RR filter code, the Dbus methods controlling filtering A and AAAA records got severely broken. This, and the previous commit, fixes things.
This commit is contained in:
67
src/dbus.c
67
src/dbus.c
@@ -485,28 +485,37 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
||||
return error;
|
||||
}
|
||||
|
||||
static DBusMessage *dbus_set_bool(DBusMessage *message, int flag, char *name)
|
||||
static DBusMessage *dbus_get_bool(DBusMessage *message, dbus_bool_t *enabled, char *name)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
dbus_bool_t enabled;
|
||||
|
||||
if (!dbus_message_iter_init(message, &iter) || dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
|
||||
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, "Expected boolean argument");
|
||||
|
||||
dbus_message_iter_get_basic(&iter, &enabled);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
my_syslog(LOG_INFO, _("Enabling --%s option from D-Bus"), name);
|
||||
set_option_bool(flag);
|
||||
}
|
||||
dbus_message_iter_get_basic(&iter, enabled);
|
||||
|
||||
if (*enabled)
|
||||
my_syslog(LOG_INFO, _("Enabling --%s option from D-Bus"), name);
|
||||
else
|
||||
my_syslog(LOG_INFO, _("Disabling --%s option from D-Bus"), name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static DBusMessage *dbus_set_bool(DBusMessage *message, int flag, char *name)
|
||||
{
|
||||
dbus_bool_t val;
|
||||
DBusMessage *reply = dbus_get_bool(message, &val, name);
|
||||
|
||||
if (!reply)
|
||||
{
|
||||
my_syslog(LOG_INFO, _("Disabling --%s option from D-Bus"), name);
|
||||
reset_option_bool(flag);
|
||||
if (val)
|
||||
set_option_bool(flag);
|
||||
else
|
||||
reset_option_bool(flag);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return reply;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DHCP
|
||||
@@ -829,25 +838,37 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
||||
else if (strcmp(method, "SetFilterA") == 0)
|
||||
{
|
||||
static int done = 0;
|
||||
static struct rrlist list = { T_A, NULL };
|
||||
static struct rrlist list = { 0, NULL };
|
||||
dbus_bool_t enabled;
|
||||
|
||||
if (!done)
|
||||
if (!(reply = dbus_get_bool(message, &enabled, "filter-A")))
|
||||
{
|
||||
done = 1;
|
||||
list.next = daemon->filter_rr;
|
||||
daemon->filter_rr = &list;
|
||||
if (!done)
|
||||
{
|
||||
done = 1;
|
||||
list.next = daemon->filter_rr;
|
||||
daemon->filter_rr = &list;
|
||||
}
|
||||
|
||||
list.rr = enabled ? T_A : 0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(method, "SetFilterAAAA") == 0)
|
||||
{
|
||||
static int done = 0;
|
||||
static struct rrlist list = { T_AAAA, NULL };
|
||||
|
||||
if (!done)
|
||||
static struct rrlist list = { 0, NULL };
|
||||
dbus_bool_t enabled;
|
||||
|
||||
if (!(reply = dbus_get_bool(message, &enabled, "filter-AAAA")))
|
||||
{
|
||||
done = 1;
|
||||
list.next = daemon->filter_rr;
|
||||
daemon->filter_rr = &list;
|
||||
if (!done)
|
||||
{
|
||||
done = 1;
|
||||
list.next = daemon->filter_rr;
|
||||
daemon->filter_rr = &list;
|
||||
}
|
||||
|
||||
list.rr = enabled ? T_AAAA : 0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(method, "SetLocaliseQueriesOption") == 0)
|
||||
|
||||
@@ -119,7 +119,7 @@ int rr_on_list(struct rrlist *list, unsigned short rr)
|
||||
{
|
||||
while (list)
|
||||
{
|
||||
if (list->rr == rr)
|
||||
if (list->rr != 0 && list->rr == rr)
|
||||
return 1;
|
||||
|
||||
list = list->next;
|
||||
|
||||
Reference in New Issue
Block a user