|
@@ -2306,20 +2306,48 @@ static int wpa_supplicant_ctrl_iface_add_cred(struct wpa_supplicant *wpa_s,
|
|
|
}
|
|
|
|
|
|
|
|
|
+static int wpas_ctrl_remove_cred(struct wpa_supplicant *wpa_s,
|
|
|
+ struct wpa_cred *cred)
|
|
|
+{
|
|
|
+ struct wpa_ssid *ssid;
|
|
|
+ char str[20];
|
|
|
+
|
|
|
+ if (cred == NULL || wpa_config_remove_cred(wpa_s->conf, cred->id) < 0) {
|
|
|
+ wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Remove any network entry created based on the removed credential */
|
|
|
+ ssid = wpa_s->conf->ssid;
|
|
|
+ while (ssid) {
|
|
|
+ if (ssid->parent_cred == cred) {
|
|
|
+ wpa_printf(MSG_DEBUG, "Remove network id %d since it "
|
|
|
+ "used the removed credential", ssid->id);
|
|
|
+ os_snprintf(str, sizeof(str), "%d", ssid->id);
|
|
|
+ ssid = ssid->next;
|
|
|
+ wpa_supplicant_ctrl_iface_remove_network(wpa_s, str);
|
|
|
+ } else
|
|
|
+ ssid = ssid->next;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
|
|
|
char *cmd)
|
|
|
{
|
|
|
int id;
|
|
|
- struct wpa_cred *cred;
|
|
|
+ struct wpa_cred *cred, *prev;
|
|
|
|
|
|
/* cmd: "<cred id>" or "all" */
|
|
|
if (os_strcmp(cmd, "all") == 0) {
|
|
|
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED all");
|
|
|
cred = wpa_s->conf->cred;
|
|
|
while (cred) {
|
|
|
- id = cred->id;
|
|
|
+ prev = cred;
|
|
|
cred = cred->next;
|
|
|
- wpa_config_remove_cred(wpa_s->conf, id);
|
|
|
+ wpas_ctrl_remove_cred(wpa_s, prev);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -2328,14 +2356,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
|
|
|
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED id=%d", id);
|
|
|
|
|
|
cred = wpa_config_get_cred(wpa_s->conf, id);
|
|
|
- if (cred == NULL ||
|
|
|
- wpa_config_remove_cred(wpa_s->conf, id) < 0) {
|
|
|
- wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred id=%d",
|
|
|
- id);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
+ return wpas_ctrl_remove_cred(wpa_s, cred);
|
|
|
}
|
|
|
|
|
|
|