From 9f1aee46d55a90e9bd2490b256d464de1e675b91 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Wed, 27 Nov 2024 11:55:37 +0100 Subject: [PATCH] Rename 'keyring' member to 'keyring_key_type' in volume_key. The keyring field is misleading since the field indeed contains the type identification id. --- lib/internal.h | 4 ++-- lib/libdevmapper.c | 4 ++-- lib/setup.c | 4 ++-- lib/volumekey.c | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/internal.h b/lib/internal.h index db7c158c..d959e34e 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -53,7 +53,7 @@ struct volume_key { int id; size_t keylength; /* length in bytes */ const char *key_description; /* keyring key name/description */ - key_type_t keyring; /* type of keyring where the key is stored */ + key_type_t keyring_key_type; /* kernel keyring key type */ bool uploaded; /* uploaded to keyring, can drop it */ struct volume_key *next; char key[]; @@ -63,7 +63,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key); struct volume_key *crypt_generate_volume_key(struct crypt_device *cd, size_t keylength); void crypt_free_volume_key(struct volume_key *vk); int crypt_volume_key_set_description(struct volume_key *key, - const char *key_description, key_type_t keyring); + const char *key_description, key_type_t keyring_key_type); int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *key_name); void crypt_volume_key_set_id(struct volume_key *vk, int id); int crypt_volume_key_get_id(const struct volume_key *vk); diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index f4a4091f..f34cb440 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -591,7 +591,7 @@ static char *get_dm_crypt_params(const struct dm_target *tgt, uint32_t flags) if (null_cipher) hexkey = crypt_bytes_to_hex(0, NULL); else if (flags & CRYPT_ACTIVATE_KEYRING_KEY) { - if (!tgt->u.crypt.vk->key_description || tgt->u.crypt.vk->keyring == INVALID_KEY) + if (!tgt->u.crypt.vk->key_description || tgt->u.crypt.vk->keyring_key_type == INVALID_KEY) goto out; keystr_len = strlen(tgt->u.crypt.vk->key_description) + int_log10(tgt->u.crypt.vk->keylength) + @@ -600,7 +600,7 @@ static char *get_dm_crypt_params(const struct dm_target *tgt, uint32_t flags) if (!hexkey) goto out; r = snprintf(hexkey, keystr_len, ":%zu:%s:%s", tgt->u.crypt.vk->keylength, - key_type_name(tgt->u.crypt.vk->keyring), tgt->u.crypt.vk->key_description); + key_type_name(tgt->u.crypt.vk->keyring_key_type), tgt->u.crypt.vk->key_description); if (r < 0 || r >= keystr_len) goto out; } else diff --git a/lib/setup.c b/lib/setup.c index b1f08bdb..0d694d24 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -3357,7 +3357,7 @@ static int _reload_device(struct crypt_device *cd, const char *name, if (tgt->type == DM_CRYPT && sdmd->flags & CRYPT_ACTIVATE_KEYRING_KEY) { r = crypt_volume_key_set_description(tgt->u.crypt.vk, src->u.crypt.vk->key_description, - src->u.crypt.vk->keyring); + src->u.crypt.vk->keyring_key_type); if (r) goto out; } else if (tgt->type == DM_CRYPT) { @@ -3479,7 +3479,7 @@ static int _reload_device_with_integrity(struct crypt_device *cd, if (sdmd->flags & CRYPT_ACTIVATE_KEYRING_KEY) { r = crypt_volume_key_set_description(tgt->u.crypt.vk, src->u.crypt.vk->key_description, - src->u.crypt.vk->keyring); + src->u.crypt.vk->keyring_key_type); if (r) goto out; } else { diff --git a/lib/volumekey.c b/lib/volumekey.c index e4da1f88..506dc291 100644 --- a/lib/volumekey.c +++ b/lib/volumekey.c @@ -25,7 +25,7 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key) return NULL; vk->key_description = NULL; - vk->keyring = INVALID_KEY; + vk->keyring_key_type = INVALID_KEY; vk->keylength = keylength; vk->uploaded = false; vk->id = KEY_NOT_VERIFIED; @@ -43,14 +43,14 @@ struct volume_key *crypt_alloc_volume_key(size_t keylength, const char *key) } int crypt_volume_key_set_description(struct volume_key *vk, - const char *key_description, key_type_t keyring) + const char *key_description, key_type_t keyring_key_type) { if (!vk) return -EINVAL; free(CONST_CAST(void*)vk->key_description); vk->key_description = NULL; - vk->keyring = keyring; + vk->keyring_key_type = keyring_key_type; if (key_description && !(vk->key_description = strdup(key_description))) return -ENOMEM; @@ -60,12 +60,12 @@ int crypt_volume_key_set_description(struct volume_key *vk, int crypt_volume_key_set_description_by_name(struct volume_key *vk, const char *key_name) { const char *key_description = NULL; - key_type_t keyring = keyring_type_and_name(key_name, &key_description); + key_type_t keyring_key_type = keyring_type_and_name(key_name, &key_description); - if (keyring == INVALID_KEY) + if (keyring_key_type == INVALID_KEY) return -EINVAL; - return crypt_volume_key_set_description(vk, key_description, keyring); + return crypt_volume_key_set_description(vk, key_description, keyring_key_type); } void crypt_volume_key_set_id(struct volume_key *vk, int id)