options: allow a UUID as identifier for --key

This way it is possible to specify the UUID of the LUKS device instead
of the libguestfs device name to decrypt a device during the inspection.

Make the usage of the new luks_uuid API conditional, so other projects
using the common submodule do not require a libguestfs version bump.

(cherry picked from commit bb4a2dc17a78b53437896d4215ae82df8e11b788
in libguestfs-common)

PT: the documentation was amended manually.
This commit is contained in:
Pino Toscano
2019-11-29 12:07:13 +01:00
parent 3afce3e84c
commit abb0a1dcc6
17 changed files with 40 additions and 34 deletions

View File

@@ -124,8 +124,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -108,8 +108,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -355,8 +355,8 @@ L</RECURSIVE LONG LISTING> above.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -126,8 +126,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -86,7 +86,13 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
CLEANUP_FREE_STRING_LIST char **keys = get_keys (ks, partitions[i]);
#ifdef GUESTFS_HAVE_LUKS_UUID
CLEANUP_FREE char *uuid = guestfs_luks_uuid (g, partitions[i]);
#else
const char *uuid = NULL;
#endif
CLEANUP_FREE_STRING_LIST char **keys = get_keys (ks, partitions[i], uuid);
assert (guestfs_int_count_strings (keys) > 0);
/* Try each key in turn. */

View File

@@ -126,7 +126,7 @@ read_first_line_from_file (const char *filename)
* keystore, ask the user.
*/
char **
get_keys (struct key_store *ks, const char *device)
get_keys (struct key_store *ks, const char *device, const char *uuid)
{
size_t i, j, len;
char **r;
@@ -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->id, device))
if (STRNEQ (key->id, device) && (uuid && STRNEQ (key->id, uuid)))
continue;
switch (key->type) {

View File

@@ -104,8 +104,8 @@ struct mp {
/* A key in the key store. */
struct key_store_key {
/* An ID for the device this key refers to. It must be the libguestfs
* device name.
/* An ID for the device this key refers to. It can be either the libguestfs
* device name, or the UUID.
*
* There may be multiple matching devices in the list.
*/
@@ -150,7 +150,7 @@ extern void print_inspect_prompt (void);
/* in key.c */
extern char *read_key (const char *param);
extern char **get_keys (struct key_store *ks, const char *device);
extern char **get_keys (struct key_store *ks, const char *device, const char *uuid);
extern struct key_store *key_store_add_from_selector (struct key_store *ks, const char *selector);
extern struct key_store *key_store_import_key (struct key_store *ks, const struct key_store_key *key);
extern void free_key_store (struct key_store *ks);

View File

@@ -141,8 +141,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -169,8 +169,8 @@ Display file sizes in human-readable format.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -156,8 +156,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -283,8 +283,8 @@ were found.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -249,8 +249,8 @@ mounted on the real virtual machine.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -92,8 +92,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -117,8 +117,8 @@ ensure the format is always specified.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -233,8 +233,8 @@ See L</IN-PLACE SPARSIFICATION> below.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -189,8 +189,8 @@ security problem with malicious guests (CVE-2010-3851).
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4

View File

@@ -337,8 +337,8 @@ through VDDK.
=item B<--key> SELECTOR
Specify a key for LUKS, to automatically open a LUKS device when using
the inspection. C<ID> must be the libguestfs device name of the LUKS
device.
the inspection. C<ID> can be either the libguestfs device name, or
the UUID of the LUKS device.
=over 4