[Libguestfs] [PATCH common v2 2/3] options: Allow multiple --key parameters.

Richard W.M. Jones rjones at redhat.com
Thu Nov 28 10:01:04 UTC 2019


On Wed, Nov 27, 2019 at 06:45:37PM +0100, Pino Toscano wrote:
> On Tuesday, 26 November 2019 17:40:47 CET Richard W.M. Jones wrote:
> > This allows multiple --key parameters on the command line to match a
> > single device.  For example:
> > 
> >   tool --key /dev/sda1:key:trykey1 --key /dev/sda1:key:trykey2
> > 
> > would try "trykey1" and "trykey2" against /dev/sda1.
> > ---
> 
> Mostly LGTM, just one note/question below.
> 
> > +      CLEANUP_FREE_STRING_LIST char **keys = get_keys (ks, partitions[i]);
> > +
> > +      if (guestfs_int_count_strings (keys) == 0)
> > +        error (EXIT_FAILURE, 0,
> > +               _("no key was provided to open LUKS encrypted %s, "
> > +                 "try using --key on the command line"),
> > +               partitions[i]);
> 
> Is this check ever going to be true? get_keys() calls read_key() to ask
> the user for a key if none were provided, and on read_key() failure
> error() is called directly.  In case this might be dead code, I'd place
> an assert instead or a non-translatable internal error.

It looks like this shouldn't ever be true because of:

    s = read_key (device);
    if (!s)
      error (EXIT_FAILURE, 0, _("could not read key from user"));

in get_keys, so I'll replace this with an internal error of some sort.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list