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

Pino Toscano
Fri, 24 Jul 2015 13:26:45 -0000

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
--
2.1.0