driver: hook up AddMatch() and RemoveMatch()
We are currently only using a global match registry, but in the future
we will extend this to per-peer and per-name registries too.
@@ -285,10 +285,46 @@ static int driver_method_get_connection_selinux_security_context(Peer *peer, CDV
}
static int driver_method_add_match(Peer *peer, CDVar *in_v, CDVar *out_v) {
+ DBusMatchRule *rule;
+ const char *rule_string;
+ int r;
+
+ c_dvar_read(in_v, "(s)", &rule_string);
+
+ r = c_dvar_end_read(in_v);
+ if (r)
+ return (r > 0) ? -ENOTRECOVERABLE : r;
+
+ r = dbus_match_rule_new(&rule, peer, rule_string);
+ if (r)
+ return (r > 0) ? -ENOTRECOVERABLE : r;
+
+ dbus_match_rule_link(rule, &peer->bus->matches);
+
+ c_dvar_write(out_v, "()");
+
return 0;
}
static int driver_method_remove_match(Peer *peer, CDVar *in_v, CDVar *out_v) {
+ DBusMatchRule *rule;
+ const char *rule_string;
+ int r;
+
+ c_dvar_read(in_v, "(s)", &rule_string);
+
+ r = c_dvar_end_read(in_v);
+ if (r)
+ return (r > 0) ? -ENOTRECOVERABLE : r;
+
+ r = dbus_match_rule_get(&rule, peer, rule_string);
+ if (r)
+ return (r > 0) ? -ENOTRECOVERABLE : r;
+
+ dbus_match_rule_unref(rule);
+
+ c_dvar_write(out_v, "()");
+
return 0;
}
