In the future it will be also something else other than the device name. --- mltools/tools_utils-c.c | 4 ++-- options/key-option.pod | 7 ++++--- options/keys.c | 8 ++++---- options/options.h | 8 +++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mltools/tools_utils-c.c b/mltools/tools_utils-c.c index 3b80091..6c43b8d 100644 --- a/mltools/tools_utils-c.c +++ b/mltools/tools_utils-c.c @@ -57,8 +57,8 @@ guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv) struct key_store_key key; elemv = Field (keysv, 0); - key.device = strdup (String_val (Field (elemv, 0))); - if (!key.device) + key.id = strdup (String_val (Field (elemv, 0))); + if (!key.id) caml_raise_out_of_memory (); v = Field (elemv, 1); diff --git a/options/key-option.pod b/options/key-option.pod index cc188dc..02dcf18 100644 --- a/options/key-option.pod +++ b/options/key-option.pod @@ -1,15 +1,16 @@ =item B<--key> SELECTOR Specify a key for LUKS, to automatically open a LUKS device when using -the inspection. +the inspection. C<ID> must be the libguestfs device name of the LUKS +device. =over 4 -=item B<--key> C<DEVICE>:key:KEY_STRING +=item B<--key> C<ID>:key:KEY_STRING Use the specified C<KEY_STRING> as passphrase. -=item B<--key> C<DEVICE>:file:FILENAME +=item B<--key> C<ID>:file:FILENAME Read the passphrase from F<FILENAME>. diff --git a/options/keys.c b/options/keys.c index 782bdb6..7c391ac 100644 --- a/options/keys.c +++ b/options/keys.c @@ -148,7 +148,7 @@ get_keys (struct key_store *ks, const char *device) for (i = 0; i < ks->nr_keys; ++i) { struct key_store_key *key = &ks->keys[i]; - if (STRNEQ (key->device, device)) + if (STRNEQ (key->id, device)) continue; switch (key->type) { @@ -193,8 +193,8 @@ key_store_add_from_selector (struct key_store *ks, const char *selector) } /* 1: device */ - key.device = strdup (fields[0]); - if (!key.device) + key.id = strdup (fields[0]); + if (!key.id) error (EXIT_FAILURE, errno, "strdup"); /* 2: key type */ @@ -265,6 +265,6 @@ free_key_store (struct key_store *ks) free (key->file.name); break; } - free (key->device); + free (key->id); } } diff --git a/options/options.h b/options/options.h index 510e8a8..b83a92b 100644 --- a/options/options.h +++ b/options/options.h @@ -104,10 +104,12 @@ struct mp { /* A key in the key store. */ struct key_store_key { - /* The device this key refers to. There may be multiple matching - * devices in the list. + /* An ID for the device this key refers to. It must be the libguestfs + * device name. + * + * There may be multiple matching devices in the list. */ - char *device; + char *id; enum { key_string, /* key specified as string */ -- 2.21.0