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:
@@ -2030,7 +2030,6 @@ static void clear_start_action(private_vici_config_t *this, char *peer_name,
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
child_sa_t *child_sa;
|
||||
peer_cfg_t *peer_cfg;
|
||||
ike_sa_t *ike_sa;
|
||||
uint32_t id = 0, others;
|
||||
array_t *ids = NULL, *ikeids = NULL;
|
||||
@@ -2121,22 +2120,7 @@ static void clear_start_action(private_vici_config_t *this, char *peer_name,
|
||||
charon->shunts->uninstall(charon->shunts, peer_name, name);
|
||||
break;
|
||||
default:
|
||||
enumerator = charon->traps->create_enumerator(charon->traps);
|
||||
while (enumerator->enumerate(enumerator, &peer_cfg,
|
||||
&child_sa))
|
||||
{
|
||||
if (streq(peer_name, peer_cfg->get_name(peer_cfg)) &&
|
||||
streq(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);
|
||||
}
|
||||
charon->traps->uninstall(charon->traps, peer_name, name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -679,10 +679,6 @@ CALLBACK(install, vici_message_t*,
|
||||
CALLBACK(uninstall, vici_message_t*,
|
||||
private_vici_control_t *this, char *name, u_int id, vici_message_t *request)
|
||||
{
|
||||
peer_cfg_t *peer_cfg;
|
||||
child_sa_t *child_sa;
|
||||
enumerator_t *enumerator;
|
||||
uint32_t reqid = 0;
|
||||
char *child, *ike;
|
||||
|
||||
child = request->get_str(request, NULL, "child");
|
||||
@@ -698,26 +694,9 @@ CALLBACK(uninstall, vici_message_t*,
|
||||
{
|
||||
return send_reply(this, NULL);
|
||||
}
|
||||
|
||||
enumerator = charon->traps->create_enumerator(charon->traps);
|
||||
while (enumerator->enumerate(enumerator, &peer_cfg, &child_sa))
|
||||
else if (charon->traps->uninstall(charon->traps, ike, child))
|
||||
{
|
||||
if ((!ike || streq(ike, peer_cfg->get_name(peer_cfg))) &&
|
||||
streq(child, child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (reqid)
|
||||
{
|
||||
if (charon->traps->uninstall(charon->traps, reqid))
|
||||
{
|
||||
return send_reply(this, NULL);
|
||||
}
|
||||
return send_reply(this, "uninstalling policy '%s' failed", child);
|
||||
return send_reply(this, NULL);
|
||||
}
|
||||
return send_reply(this, "policy '%s' not found", child);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user