libsystemd: turn json.[ch] into a public API

This is preparation for making our Varlink API a public API. Since our
Varlink API is built on top of our JSON API we need to make that public
first (it's a nice API, but JSON APIs there are already enough, this is
purely about the Varlink angle).

I made most of the json.h APIs public, and just placed them in
sd-json.h. Sometimes I wasn't so sure however, since the underlying data
structures would have to be made public too. If in doubt I didn#t risk
it, and moved the relevant API to src/libsystemd/sd-json/json-util.h
instead (without any sd_* symbol prefixes).

This is mostly a giant search/replace patch.
This commit is contained in:
Lennart Poettering
2024-06-12 18:42:22 +02:00
parent f2eb7716d0
commit 309a747fa6
179 changed files with 6798 additions and 6514 deletions
+10 -10
View File
@@ -3,10 +3,11 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <p11-kit/p11-kit.h>
#include <p11-kit/uri.h>
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "cryptsetup-pkcs11.h"
@@ -15,7 +16,6 @@
#include "fileio.h"
#include "format-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "macro.h"
#include "memory-util.h"
#include "parse-util.h"
@@ -109,8 +109,8 @@ int find_pkcs11_auto_data(
/* Loads PKCS#11 metadata from LUKS2 JSON token headers. */
for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
JsonVariant *w;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
sd_json_variant *w;
int ks;
r = cryptsetup_get_token_as_json(cd, token, "systemd-pkcs11", &v);
@@ -134,12 +134,12 @@ int find_pkcs11_auto_data(
assert(keyslot < 0);
keyslot = ks;
w = json_variant_by_key(v, "pkcs11-uri");
if (!w || !json_variant_is_string(w))
w = sd_json_variant_by_key(v, "pkcs11-uri");
if (!w || !sd_json_variant_is_string(w))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"PKCS#11 token data lacks 'pkcs11-uri' field.");
uri = strdup(json_variant_string(w));
uri = strdup(sd_json_variant_string(w));
if (!uri)
return log_oom();
@@ -147,14 +147,14 @@ int find_pkcs11_auto_data(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"PKCS#11 token data contains invalid PKCS#11 URI.");
w = json_variant_by_key(v, "pkcs11-key");
if (!w || !json_variant_is_string(w))
w = sd_json_variant_by_key(v, "pkcs11-key");
if (!w || !sd_json_variant_is_string(w))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"PKCS#11 token data lacks 'pkcs11-key' field.");
assert(!key);
assert(key_size == 0);
r = unbase64mem(json_variant_string(w), &key, &key_size);
r = unbase64mem(sd_json_variant_string(w), &key, &key_size);
if (r < 0)
return log_error_errno(r, "Failed to decode base64 encoded key.");
}
@@ -7,7 +7,7 @@
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "json-util.h"
#include "luks2-fido2.h"
#include "memory-util.h"
#include "version.h"
@@ -157,59 +157,59 @@ _public_ int cryptsetup_token_validate(
const char *json /* contains valid 'type' and 'keyslots' fields. 'type' is 'systemd-fido2' */) {
int r;
JsonVariant *w;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
sd_json_variant *w;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
assert(json);
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Could not parse " TOKEN_NAME " json object: %m.");
w = json_variant_by_key(v, "fido2-credential");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "fido2-credential");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "FIDO2 token data lacks 'fido2-credential' field.");
return 1;
}
r = unbase64mem(json_variant_string(w), NULL, NULL);
r = unbase64mem(sd_json_variant_string(w), NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Invalid base64 data in 'fido2-credential' field: %m");
w = json_variant_by_key(v, "fido2-salt");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "fido2-salt");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "FIDO2 token data lacks 'fido2-salt' field.");
return 1;
}
r = unbase64mem(json_variant_string(w), NULL, NULL);
r = unbase64mem(sd_json_variant_string(w), NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Failed to decode base64 encoded salt: %m.");
/* The "rp" field is optional. */
w = json_variant_by_key(v, "fido2-rp");
if (w && !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "fido2-rp");
if (w && !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "FIDO2 token data's 'fido2-rp' field is not a string.");
return 1;
}
/* The "fido2-clientPin-required" field is optional. */
w = json_variant_by_key(v, "fido2-clientPin-required");
if (w && !json_variant_is_boolean(w)) {
w = sd_json_variant_by_key(v, "fido2-clientPin-required");
if (w && !sd_json_variant_is_boolean(w)) {
crypt_log_debug(cd, "FIDO2 token data's 'fido2-clientPin-required' field is not a boolean.");
return 1;
}
/* The "fido2-up-required" field is optional. */
w = json_variant_by_key(v, "fido2-up-required");
if (w && !json_variant_is_boolean(w)) {
w = sd_json_variant_by_key(v, "fido2-up-required");
if (w && !sd_json_variant_is_boolean(w)) {
crypt_log_debug(cd, "FIDO2 token data's 'fido2-up-required' field is not a boolean.");
return 1;
}
/* The "fido2-uv-required" field is optional. */
w = json_variant_by_key(v, "fido2-uv-required");
if (w && !json_variant_is_boolean(w)) {
w = sd_json_variant_by_key(v, "fido2-uv-required");
if (w && !sd_json_variant_is_boolean(w)) {
crypt_log_debug(cd, "FIDO2 token data's 'fido2-uv-required' field is not a boolean.");
return 1;
}
@@ -3,10 +3,11 @@
#include <errno.h>
#include <libcryptsetup.h>
#include "sd-json.h"
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "luks2-pkcs11.h"
#include "memory-util.h"
#include "pkcs11-util.h"
@@ -112,31 +113,31 @@ _public_ int cryptsetup_token_validate(
const char *json /* contains valid 'type' and 'keyslots' fields. 'type' is 'systemd-pkcs11' */) {
int r;
JsonVariant *w;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
sd_json_variant *w;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Could not parse " TOKEN_NAME " json object: %m.");
w = json_variant_by_key(v, "pkcs11-uri");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "pkcs11-uri");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "PKCS#11 token data lacks 'pkcs11-uri' field.");
return 1;
}
if (!pkcs11_uri_valid(json_variant_string(w))) {
if (!pkcs11_uri_valid(sd_json_variant_string(w))) {
crypt_log_debug(cd, "PKCS#11 token data contains invalid PKCS#11 URI.");
return 1;
}
w = json_variant_by_key(v, "pkcs11-key");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "pkcs11-key");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "PKCS#11 token data lacks 'pkcs11-key' field.");
return 1;
}
r = unbase64mem(json_variant_string(w), NULL, NULL);
r = unbase64mem(sd_json_variant_string(w), NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Failed to decode base64 encoded key: %m.");
@@ -6,7 +6,7 @@
#include "cryptsetup-token.h"
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "json-util.h"
#include "luks2-tpm2.h"
#include "memory-util.h"
#include "strv.h"
@@ -44,7 +44,7 @@ _public_ int cryptsetup_token_open_pin(
_cleanup_(erase_and_freep) char *base64_encoded = NULL, *pin_string = NULL;
_cleanup_(iovec_done) struct iovec blob = {}, pubkey = {}, policy_hash = {}, salt = {}, srk = {}, pcrlock_nv = {};
_cleanup_(iovec_done_erase) struct iovec decrypted_key = {};
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
uint32_t hash_pcr_mask, pubkey_pcr_mask;
systemd_tpm2_plugin_params params = {
.search_pcr_mask = UINT32_MAX
@@ -72,7 +72,7 @@ _public_ int cryptsetup_token_open_pin(
if (usrptr)
params = *(systemd_tpm2_plugin_params *)usrptr;
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Failed to parse token JSON data: %m");
@@ -169,7 +169,7 @@ _public_ void cryptsetup_token_dump(
_cleanup_free_ char *hash_pcrs_str = NULL, *pubkey_pcrs_str = NULL, *blob_str = NULL, *policy_hash_str = NULL, *pubkey_str = NULL;
_cleanup_(iovec_done) struct iovec blob = {}, pubkey = {}, policy_hash = {}, salt = {}, srk = {}, pcrlock_nv = {};
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
uint32_t hash_pcr_mask, pubkey_pcr_mask;
uint16_t pcr_bank, primary_alg;
TPM2Flags flags = 0;
@@ -177,7 +177,7 @@ _public_ void cryptsetup_token_dump(
assert(json);
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return (void) crypt_log_debug_errno(cd, r, "Failed to parse " TOKEN_NAME " JSON object: %m");
@@ -243,17 +243,17 @@ _public_ int cryptsetup_token_validate(
const char *json /* contains valid 'type' and 'keyslots' fields. 'type' is 'systemd-tpm2' */) {
int r;
JsonVariant *w, *e;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
sd_json_variant *w, *e;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
assert(json);
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Could not parse " TOKEN_NAME " json object: %m");
w = json_variant_by_key(v, "tpm2-pcrs");
if (!w || !json_variant_is_array(w)) {
w = sd_json_variant_by_key(v, "tpm2-pcrs");
if (!w || !sd_json_variant_is_array(w)) {
crypt_log_debug(cd, "TPM2 token data lacks 'tpm2-pcrs' field.");
return 1;
}
@@ -261,12 +261,12 @@ _public_ int cryptsetup_token_validate(
JSON_VARIANT_ARRAY_FOREACH(e, w) {
uint64_t u;
if (!json_variant_is_number(e)) {
if (!sd_json_variant_is_number(e)) {
crypt_log_debug(cd, "TPM2 PCR is not a number.");
return 1;
}
u = json_variant_unsigned(e);
u = sd_json_variant_unsigned(e);
if (!TPM2_PCR_INDEX_VALID(u)) {
crypt_log_debug(cd, "TPM2 PCR number out of range.");
return 1;
@@ -275,61 +275,61 @@ _public_ int cryptsetup_token_validate(
/* The bank field is optional, since it was added in systemd 250 only. Before the bank was hardcoded
* to SHA256. */
w = json_variant_by_key(v, "tpm2-pcr-bank");
w = sd_json_variant_by_key(v, "tpm2-pcr-bank");
if (w) {
/* The PCR bank field is optional */
if (!json_variant_is_string(w)) {
if (!sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "TPM2 PCR bank is not a string.");
return 1;
}
if (tpm2_hash_alg_from_string(json_variant_string(w)) < 0) {
crypt_log_debug(cd, "TPM2 PCR bank invalid or not supported: %s.", json_variant_string(w));
if (tpm2_hash_alg_from_string(sd_json_variant_string(w)) < 0) {
crypt_log_debug(cd, "TPM2 PCR bank invalid or not supported: %s.", sd_json_variant_string(w));
return 1;
}
}
/* The primary key algorithm field is optional, since it was also added in systemd 250 only. Before
* the algorithm was hardcoded to ECC. */
w = json_variant_by_key(v, "tpm2-primary-alg");
w = sd_json_variant_by_key(v, "tpm2-primary-alg");
if (w) {
/* The primary key algorithm is optional */
if (!json_variant_is_string(w)) {
if (!sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "TPM2 primary key algorithm is not a string.");
return 1;
}
if (tpm2_asym_alg_from_string(json_variant_string(w)) < 0) {
crypt_log_debug(cd, "TPM2 primary key algorithm invalid or not supported: %s", json_variant_string(w));
if (tpm2_asym_alg_from_string(sd_json_variant_string(w)) < 0) {
crypt_log_debug(cd, "TPM2 primary key algorithm invalid or not supported: %s", sd_json_variant_string(w));
return 1;
}
}
w = json_variant_by_key(v, "tpm2-blob");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "tpm2-blob");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "TPM2 token data lacks 'tpm2-blob' field.");
return 1;
}
r = unbase64mem(json_variant_string(w), NULL, NULL);
r = unbase64mem(sd_json_variant_string(w), NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Invalid base64 data in 'tpm2-blob' field: %m");
w = json_variant_by_key(v, "tpm2-policy-hash");
if (!w || !json_variant_is_string(w)) {
w = sd_json_variant_by_key(v, "tpm2-policy-hash");
if (!w || !sd_json_variant_is_string(w)) {
crypt_log_debug(cd, "TPM2 token data lacks 'tpm2-policy-hash' field.");
return 1;
}
r = unhexmem(json_variant_string(w), NULL, NULL);
r = unhexmem(sd_json_variant_string(w), NULL, NULL);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Invalid base64 data in 'tpm2-policy-hash' field: %m");
w = json_variant_by_key(v, "tpm2-pin");
w = sd_json_variant_by_key(v, "tpm2-pin");
if (w) {
if (!json_variant_is_boolean(w)) {
if (!sd_json_variant_is_boolean(w)) {
crypt_log_debug(cd, "TPM2 PIN policy is not a boolean.");
return 1;
}
+16 -16
View File
@@ -4,7 +4,7 @@
#include "cryptsetup-token-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "json-util.h"
#include "luks2-fido2.h"
#include "memory-util.h"
#include "strv.h"
@@ -84,8 +84,8 @@ int parse_luks2_fido2_data(
size_t cid_size = 0, salt_size = 0;
_cleanup_free_ char *rp = NULL;
int r;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
JsonVariant *w;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
sd_json_variant *w;
Fido2EnrollFlags required = 0;
assert(json);
@@ -96,54 +96,54 @@ int parse_luks2_fido2_data(
assert(ret_cid_size);
assert(ret_required);
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return crypt_log_error_errno(cd, r, "Failed to parse JSON token data: %m");
w = json_variant_by_key(v, "fido2-credential");
w = sd_json_variant_by_key(v, "fido2-credential");
if (!w)
return -EINVAL;
r = unbase64mem(json_variant_string(w), &cid, &cid_size);
r = unbase64mem(sd_json_variant_string(w), &cid, &cid_size);
if (r < 0)
return crypt_log_error_errno(cd, r, "Failed to parse 'fido2-credentials' field: %m");
w = json_variant_by_key(v, "fido2-salt");
w = sd_json_variant_by_key(v, "fido2-salt");
if (!w)
return -EINVAL;
r = unbase64mem(json_variant_string(w), &salt, &salt_size);
r = unbase64mem(sd_json_variant_string(w), &salt, &salt_size);
if (r < 0)
return crypt_log_error_errno(cd, r, "Failed to parse 'fido2-salt' field: %m");
w = json_variant_by_key(v, "fido2-rp");
w = sd_json_variant_by_key(v, "fido2-rp");
if (w) {
/* The "rp" field is optional. */
rp = strdup(json_variant_string(w));
rp = strdup(sd_json_variant_string(w));
if (!rp) {
crypt_log_error(cd, "Not enough memory.");
return -ENOMEM;
}
}
w = json_variant_by_key(v, "fido2-clientPin-required");
w = sd_json_variant_by_key(v, "fido2-clientPin-required");
if (w)
/* The "fido2-clientPin-required" field is optional. */
SET_FLAG(required, FIDO2ENROLL_PIN, json_variant_boolean(w));
SET_FLAG(required, FIDO2ENROLL_PIN, sd_json_variant_boolean(w));
else
required |= FIDO2ENROLL_PIN_IF_NEEDED; /* compat with 248, where the field was unset */
w = json_variant_by_key(v, "fido2-up-required");
w = sd_json_variant_by_key(v, "fido2-up-required");
if (w)
/* The "fido2-up-required" field is optional. */
SET_FLAG(required, FIDO2ENROLL_UP, json_variant_boolean(w));
SET_FLAG(required, FIDO2ENROLL_UP, sd_json_variant_boolean(w));
else
required |= FIDO2ENROLL_UP_IF_NEEDED; /* compat with 248 */
w = json_variant_by_key(v, "fido2-uv-required");
w = sd_json_variant_by_key(v, "fido2-uv-required");
if (w)
/* The "fido2-uv-required" field is optional. */
SET_FLAG(required, FIDO2ENROLL_UV, json_variant_boolean(w));
SET_FLAG(required, FIDO2ENROLL_UV, sd_json_variant_boolean(w));
else
required |= FIDO2ENROLL_UV_OMIT; /* compat with 248 */
@@ -3,10 +3,11 @@
#include <p11-kit/p11-kit.h>
#include <p11-kit/uri.h>
#include "sd-json.h"
#include "cryptsetup-token-util.h"
#include "escape.h"
#include "hexdecoct.h"
#include "json.h"
#include "luks2-pkcs11.h"
#include "memory-util.h"
#include "pkcs11-util.h"
@@ -236,31 +237,31 @@ int parse_luks2_pkcs11_data(
size_t key_size;
_cleanup_free_ char *uri = NULL;
_cleanup_free_ void *key = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
JsonVariant *w;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
sd_json_variant *w;
assert(json);
assert(ret_uri);
assert(ret_encrypted_key);
assert(ret_encrypted_key_size);
r = json_parse(json, 0, &v, NULL, NULL);
r = sd_json_parse(json, 0, &v, NULL, NULL);
if (r < 0)
return r;
w = json_variant_by_key(v, "pkcs11-uri");
w = sd_json_variant_by_key(v, "pkcs11-uri");
if (!w)
return -EINVAL;
uri = strdup(json_variant_string(w));
uri = strdup(sd_json_variant_string(w));
if (!uri)
return -ENOMEM;
w = json_variant_by_key(v, "pkcs11-key");
w = sd_json_variant_by_key(v, "pkcs11-key");
if (!w)
return -EINVAL;
r = unbase64mem(json_variant_string(w), &key, &key_size);
r = unbase64mem(sd_json_variant_string(w), &key, &key_size);
if (r < 0)
return crypt_log_debug_errno(cd, r, "Failed to decode base64 encoded key: %m.");
@@ -1,10 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sd-json.h"
#include "alloc-util.h"
#include "ask-password-api.h"
#include "env-util.h"
#include "hexdecoct.h"
#include "json.h"
#include "log.h"
#include "luks2-tpm2.h"
#include "parse-util.h"
@@ -31,7 +32,7 @@ int acquire_luks2_key(
TPM2Flags flags,
struct iovec *ret_decrypted_key) {
_cleanup_(json_variant_unrefp) JsonVariant *signature_json = NULL;
_cleanup_(sd_json_variant_unrefp) sd_json_variant *signature_json = NULL;
_cleanup_free_ char *auto_device = NULL;
_cleanup_(erase_and_freep) char *b64_salted_pin = NULL;
int r;
+11 -9
View File
@@ -9,6 +9,7 @@
#include <unistd.h>
#include "sd-device.h"
#include "sd-json.h"
#include "sd-messages.h"
#include "alloc-util.h"
@@ -28,6 +29,7 @@
#include "fs-util.h"
#include "fstab-util.h"
#include "hexdecoct.h"
#include "json-util.h"
#include "libfido2-util.h"
#include "log.h"
#include "main-func.h"
@@ -720,9 +722,9 @@ static PassphraseType check_registered_passwords(struct crypt_device *cd) {
/* Iterate all LUKS2 tokens and keep track of all their slots */
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;
const char *type;
JsonVariant *w, *z;
sd_json_variant *w, *z;
int tk;
tk = cryptsetup_get_token_as_json(cd, token, NULL, &v);
@@ -733,21 +735,21 @@ static PassphraseType check_registered_passwords(struct crypt_device *cd) {
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;
}
type = json_variant_string(w);
type = sd_json_variant_string(w);
if (STR_IN_SET(type, "systemd-recovery", "systemd-pkcs11", "systemd-fido2", "systemd-tpm2")) {
/* At least exists one recovery key */
if (streq(type, "systemd-recovery"))
passphrase_type |= PASSPHRASE_RECOVERY_KEY;
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;
}
@@ -756,12 +758,12 @@ static PassphraseType check_registered_passwords(struct crypt_device *cd) {
unsigned u;
int at;
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;
}
at = safe_atou(json_variant_string(z), &u);
at = safe_atou(sd_json_variant_string(z), &u);
if (at < 0) {
log_warning_errno(at, "Token JSON data's keyslot field is not an integer formatted as string, ignoring.");
continue;