Re: [Libguestfs] [PATCH] customize: password: improve unknown default crypto message

Richard W.M. Jones
Fri, 24 Jul 2015 14:02:11 -0000

On Fri, Jul 24, 2015 at 03:26:45PM +0200, Pino Toscano
wrote:
> When warning that there is no known default password encryption for the
> current guest, print its version in MAJOR.MINOR format if MAJOR is zero.
>
> Also, fix wrapping (and indentation) of the message.
> ---
>  customize/password.ml | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/customize/password.ml b/customize/password.ml
> index 111240e..7a050d6 100644
> --- a/customize/password.ml
> +++ b/customize/password.ml
> @@ -163,6 +163,13 @@ and default_crypto g root >    |
"ubuntu", _ -> `MD5
>
>    | _, _ ->
> -    warning (f_"password: using insecure md5 password encryption for
> -guest of type %s version %d.\nIf this is incorrect, use --password-crypto
option and file a bug.") distro major;
> +    let verstr > +      let minor = g#inspect_get_minor_version root in
> +      match major, minor with
> +      | x, _ when x > 0 -> string_of_int x
> +      | 0, 0 -> "0"
> +      | x, y -> "0." ^ string_of_int y in
> +    warning (f_"password: using insecure md5 password encryption for
guest of type %s version %s.
> +If this is incorrect, use --password-crypto option and file a bug.")
> +      distro verstr;
>      `MD5

Since this is basically a debugging message for us, wouldn't it be
better to report the major and minor numbers directly, ie just print
%d.%d instead of verstr?

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.