trap-manager: Uninstall trap policies by name and not reqid

If a trap policy is concurrently uninstalled and reinstalled under a
different name the reqid will be the same so the wrong trap might be
removed.
This commit is contained in:
Tobias Brunner
2018-02-22 11:31:05 +01:00
parent 6f569263a0
commit ca213e1907
6 changed files with 23 additions and 72 deletions
+2 -20
View File
@@ -730,31 +730,13 @@ METHOD(stroke_control_t, route, void,
METHOD(stroke_control_t, unroute, void,
private_stroke_control_t *this, stroke_msg_t *msg, FILE *out)
{
child_sa_t *child_sa;
enumerator_t *enumerator;
uint32_t id = 0;
if (charon->shunts->uninstall(charon->shunts, NULL, msg->unroute.name))
{
fprintf(out, "shunt policy '%s' uninstalled\n", msg->unroute.name);
return;
}
enumerator = charon->traps->create_enumerator(charon->traps);
while (enumerator->enumerate(enumerator, NULL, &child_sa))
else if (charon->traps->uninstall(charon->traps, NULL, msg->unroute.name))
{
if (streq(msg->unroute.name, child_sa->get_name(child_sa)))
{
id = child_sa->get_reqid(child_sa);
break;
}
}
enumerator->destroy(enumerator);
if (id)
{
charon->traps->uninstall(charon->traps, id);
fprintf(out, "configuration '%s' unrouted\n", msg->unroute.name);
fprintf(out, "trap policy '%s' unrouted\n", msg->unroute.name);
}
else
{