From d008267960337e9e44b270b26555a7a894808746 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 24 Apr 2017 08:33:11 -0400 Subject: Clean up pkey slots and volatile keys on client logout. --- ks_volatile.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'ks_volatile.c') diff --git a/ks_volatile.c b/ks_volatile.c index d565c60..363441a 100644 --- a/ks_volatile.c +++ b/ks_volatile.c @@ -614,6 +614,33 @@ static hal_error_t ks_get_attributes(hal_ks_t *ks, return err; } +static void ks_client_cleanup(hal_ks_t *ks, + hal_client_handle_t client) +{ + if (ks == NULL || client.handle = HAL_HANDLE_NONE) + return HAL_ERROR_BAD_ARGUMENTS; + + ks_t *ksv = ks_to_ksv(ks); + hal_error_t err = HAL_OK; + + hal_ks_lock(); + + for (int i = 0; i < ksv->db->ksi.used; i++) { + unsigned b = ksv->db->ksi.index[i]; + if (ksv->db->keys[b].client.handle == client.handle) { + int hint = i; + if ((err = hal_ks_index_delete(&ksv->db->ksi, &ksv->db->ksi.names[b].name, 0, NULL, &hint)) != HAL_OK) + goto done; + memset(&ksv->db->keys[b], 0, sizeof(ksv->db->keys[b])); + i--; + } + } + + done: + hal_ks_unlock(); + return err; +} + const hal_ks_driver_t hal_ks_volatile_driver[1] = {{ .init = ks_volatile_init, .shutdown = ks_volatile_shutdown, @@ -624,7 +651,8 @@ const hal_ks_driver_t hal_ks_volatile_driver[1] = {{ .delete = ks_delete, .match = ks_match, .set_attributes = ks_set_attributes, - .get_attributes = ks_get_attributes + .get_attributes = ks_get_attributes, + .client_cleanup = ks_client_cleanup }}; #endif /* STATIC_KS_VOLATILE_SLOTS > 0 */ -- cgit v1.2.3 From 4ee44177c6da04e210a52528763b2c96a8f3d824 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 24 Apr 2017 17:23:17 -0400 Subject: Call a portable entrenching tool a portable entrenching tool. --- ks_volatile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ks_volatile.c') diff --git a/ks_volatile.c b/ks_volatile.c index 363441a..29c3576 100644 --- a/ks_volatile.c +++ b/ks_volatile.c @@ -614,8 +614,8 @@ static hal_error_t ks_get_attributes(hal_ks_t *ks, return err; } -static void ks_client_cleanup(hal_ks_t *ks, - hal_client_handle_t client) +static void ks_logout(hal_ks_t *ks, + hal_client_handle_t client) { if (ks == NULL || client.handle = HAL_HANDLE_NONE) return HAL_ERROR_BAD_ARGUMENTS; @@ -652,7 +652,7 @@ const hal_ks_driver_t hal_ks_volatile_driver[1] = {{ .match = ks_match, .set_attributes = ks_set_attributes, .get_attributes = ks_get_attributes, - .client_cleanup = ks_client_cleanup + .logout = ks_logout }}; #endif /* STATIC_KS_VOLATILE_SLOTS > 0 */ -- cgit v1.2.3 From 358b3803cdedad607cf649221d0b7e3ce66b45f2 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 25 Apr 2017 17:14:40 -0400 Subject: Shake dumb compile-time bugs out of new logout code. What I get for writing code while build and test environment is tied up with a multi-day run testing something else. --- ks_volatile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ks_volatile.c') diff --git a/ks_volatile.c b/ks_volatile.c index 29c3576..6a17e45 100644 --- a/ks_volatile.c +++ b/ks_volatile.c @@ -614,10 +614,10 @@ static hal_error_t ks_get_attributes(hal_ks_t *ks, return err; } -static void ks_logout(hal_ks_t *ks, - hal_client_handle_t client) +static hal_error_t ks_logout(hal_ks_t *ks, + hal_client_handle_t client) { - if (ks == NULL || client.handle = HAL_HANDLE_NONE) + if (ks == NULL || client.handle == HAL_HANDLE_NONE) return HAL_ERROR_BAD_ARGUMENTS; ks_t *ksv = ks_to_ksv(ks); -- cgit v1.2.3