diff mbox series

[2/3] block: support sha256 fingerprint with pre-blockdev options

Message ID 20211118143547.2045554-3-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series block: misc fixes & improvements for SSH block driver key fingerprints | expand

Commit Message

Daniel P. Berrangé Nov. 18, 2021, 2:35 p.m. UTC
When support for sha256 fingerprint checking was aded in

  commit bf783261f0aee6e81af3916bff7606d71ccdc153
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Jun 22 12:51:56 2021 +0100

    block/ssh: add support for sha256 host key fingerprints

it was only made to work with -blockdev. Getting it working with
-drive requires some extra custom parsing.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 block/ssh.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Hanna Czenczek Dec. 23, 2021, 9:45 a.m. UTC | #1
On 18.11.21 15:35, Daniel P. Berrangé wrote:
> When support for sha256 fingerprint checking was aded in
>
>    commit bf783261f0aee6e81af3916bff7606d71ccdc153
>    Author: Daniel P. Berrangé <berrange@redhat.com>
>    Date:   Tue Jun 22 12:51:56 2021 +0100
>
>      block/ssh: add support for sha256 host key fingerprints
>
> it was only made to work with -blockdev. Getting it working with
> -drive requires some extra custom parsing.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   block/ssh.c | 5 +++++
>   1 file changed, 5 insertions(+)

Reviewed-by: Hanna Reitz <hreitz@redhat.com>
diff mbox series

Patch

diff --git a/block/ssh.c b/block/ssh.c
index e0fbb4934b..fcc0ab765a 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -556,6 +556,11 @@  static bool ssh_process_legacy_options(QDict *output_opts,
             qdict_put_str(output_opts, "host-key-check.type", "sha1");
             qdict_put_str(output_opts, "host-key-check.hash",
                           &host_key_check[5]);
+        } else if (strncmp(host_key_check, "sha256:", 7) == 0) {
+            qdict_put_str(output_opts, "host-key-check.mode", "hash");
+            qdict_put_str(output_opts, "host-key-check.type", "sha256");
+            qdict_put_str(output_opts, "host-key-check.hash",
+                          &host_key_check[7]);
         } else if (strcmp(host_key_check, "yes") == 0) {
             qdict_put_str(output_opts, "host-key-check.mode", "known_hosts");
         } else {