sbkeysync: add keystore_entry->root
Helps to show where the keys are loaded from. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
This commit is contained in:
parent
add8d00f31
commit
1a431a5a2d
1 changed files with 6 additions and 4 deletions
|
@ -109,6 +109,7 @@ struct key_database {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct keystore_entry {
|
struct keystore_entry {
|
||||||
|
const char *root;
|
||||||
const char *name;
|
const char *name;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -414,11 +415,11 @@ static int check_efivars_mount(const char *mountpoint)
|
||||||
* add file to keystore
|
* add file to keystore
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int keystore_entry_read(struct keystore_entry *ke, const char *root)
|
static int keystore_entry_read(struct keystore_entry *ke)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
path = talloc_asprintf(ke, "%s/%s", root, ke->name);
|
path = talloc_asprintf(ke, "%s/%s", ke->root, ke->name);
|
||||||
|
|
||||||
if (fileio_read_file(ke, path, &ke->data, &ke->len)) {
|
if (fileio_read_file(ke, path, &ke->data, &ke->len)) {
|
||||||
talloc_free(ke);
|
talloc_free(ke);
|
||||||
|
@ -474,9 +475,10 @@ static int update_keystore(struct keystore *keystore, const char *root)
|
||||||
|
|
||||||
ke = talloc(keystore, struct keystore_entry);
|
ke = talloc(keystore, struct keystore_entry);
|
||||||
ke->name = filename;
|
ke->name = filename;
|
||||||
|
ke->root = root;
|
||||||
talloc_steal(ke, ke->name);
|
talloc_steal(ke, ke->name);
|
||||||
|
|
||||||
if (keystore_entry_read(ke, root))
|
if (keystore_entry_read(ke))
|
||||||
talloc_free(ke);
|
talloc_free(ke);
|
||||||
else
|
else
|
||||||
list_add(&keystore->keys, &ke->list);
|
list_add(&keystore->keys, &ke->list);
|
||||||
|
@ -512,7 +514,7 @@ static void print_keystore(struct keystore *keystore)
|
||||||
printf("Filesystem keystore:\n");
|
printf("Filesystem keystore:\n");
|
||||||
|
|
||||||
list_for_each(&keystore->keys, ke, list)
|
list_for_each(&keystore->keys, ke, list)
|
||||||
printf(" %s [%zd bytes]\n", ke->name, ke->len);
|
printf(" %s/%s [%zd bytes]\n", ke->root, ke->name, ke->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct option options[] = {
|
static struct option options[] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue