summaryrefslogtreecommitdiffstats
path: root/src/cryptenroll/cryptenroll-wipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptenroll/cryptenroll-wipe.c')
-rw-r--r--src/cryptenroll/cryptenroll-wipe.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/cryptenroll/cryptenroll-wipe.c b/src/cryptenroll/cryptenroll-wipe.c
index 314ebd3113..703342f758 100644
--- a/src/cryptenroll/cryptenroll-wipe.c
+++ b/src/cryptenroll/cryptenroll-wipe.c
@@ -1,8 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "sd-json.h"
+
#include "cryptenroll-wipe.h"
#include "cryptenroll.h"
-#include "json.h"
+#include "json-util.h"
#include "memory-util.h"
#include "parse-util.h"
#include "set.h"
@@ -100,8 +102,8 @@ static int find_slots_by_mask(
/* Find all slots that are associated with a token of a type in the specified token type mask */
for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
- _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
- JsonVariant *w, *z;
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
+ sd_json_variant *w, *z;
EnrollType t;
r = cryptsetup_get_token_as_json(cd, token, NULL, &v);
@@ -112,16 +114,16 @@ static int find_slots_by_mask(
continue;
}
- w = json_variant_by_key(v, "type");
- if (!w || !json_variant_is_string(w)) {
+ w = sd_json_variant_by_key(v, "type");
+ if (!w || !sd_json_variant_is_string(w)) {
log_warning("Token JSON data lacks type field, ignoring.");
continue;
}
- t = luks2_token_type_from_string(json_variant_string(w));
+ t = luks2_token_type_from_string(sd_json_variant_string(w));
- w = json_variant_by_key(v, "keyslots");
- if (!w || !json_variant_is_array(w)) {
+ w = sd_json_variant_by_key(v, "keyslots");
+ if (!w || !sd_json_variant_is_array(w)) {
log_warning("Token JSON data lacks keyslots field, ignoring.");
continue;
}
@@ -129,12 +131,12 @@ static int find_slots_by_mask(
JSON_VARIANT_ARRAY_FOREACH(z, w) {
int slot;
- if (!json_variant_is_string(z)) {
+ if (!sd_json_variant_is_string(z)) {
log_warning("Token JSON data's keyslot field is not an array of strings, ignoring.");
continue;
}
- r = safe_atoi(json_variant_string(z), &slot);
+ r = safe_atoi(sd_json_variant_string(z), &slot);
if (r < 0) {
log_warning_errno(r, "Token JSON data's keyslot filed is not an integer formatted as string, ignoring.");
continue;
@@ -200,9 +202,9 @@ static int find_slot_tokens(struct crypt_device *cd, Set *wipe_slots, Set *keep_
* the slots sets according to the token data: add any other slots listed in the tokens we act on. */
for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
- _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
bool shall_wipe = false;
- JsonVariant *w, *z;
+ sd_json_variant *w, *z;
r = cryptsetup_get_token_as_json(cd, token, NULL, &v);
if (IN_SET(r, -ENOENT, -EINVAL))
@@ -212,8 +214,8 @@ static int find_slot_tokens(struct crypt_device *cd, Set *wipe_slots, Set *keep_
continue;
}
- w = json_variant_by_key(v, "keyslots");
- if (!w || !json_variant_is_array(w)) {
+ w = sd_json_variant_by_key(v, "keyslots");
+ if (!w || !sd_json_variant_is_array(w)) {
log_warning("Token JSON data lacks keyslots field, ignoring.");
continue;
}
@@ -222,12 +224,12 @@ static int find_slot_tokens(struct crypt_device *cd, Set *wipe_slots, Set *keep_
JSON_VARIANT_ARRAY_FOREACH(z, w) {
int slot;
- if (!json_variant_is_string(z)) {
+ if (!sd_json_variant_is_string(z)) {
log_warning("Token JSON data's keyslot field is not an array of strings, ignoring.");
continue;
}
- r = safe_atoi(json_variant_string(z), &slot);
+ r = safe_atoi(sd_json_variant_string(z), &slot);
if (r < 0) {
log_warning_errno(r, "Token JSON data's keyslot filed is not an integer formatted as string, ignoring.");
continue;
@@ -249,9 +251,9 @@ static int find_slot_tokens(struct crypt_device *cd, Set *wipe_slots, Set *keep_
JSON_VARIANT_ARRAY_FOREACH(z, w) {
int slot;
- if (!json_variant_is_string(z))
+ if (!sd_json_variant_is_string(z))
continue;
- if (safe_atoi(json_variant_string(z), &slot) < 0)
+ if (safe_atoi(sd_json_variant_string(z), &slot) < 0)
continue;
if (set_put(shall_wipe ? wipe_slots : keep_slots, INT_TO_PTR(slot)) < 0)