render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
032100
From c6ea67c481a2f447951449bd9b2746cfaaf385fd Mon Sep 17 00:00:00 2001
032100
Message-Id: <c6ea67c481a2f447951449bd9b2746cfaaf385fd@dist-git>
032100
From: "Richard W.M. Jones" <rjones@redhat.com>
032100
Date: Mon, 25 Jul 2022 14:09:39 +0100
032100
Subject: [PATCH] rpc: Pass OPENSSL_CONF through to ssh invocations
032100
032100
It's no longer possible for libvirt to connect over the ssh transport
032100
from RHEL 9 to RHEL 5.  This is because SHA1 signatures have been
032100
effectively banned in RHEL 9 at the openssl level.  They are required
032100
to check the RHEL 5 host key.  Note this is a separate issue from
032100
openssh requiring additional configuration in order to connect to
032100
older servers.
032100
032100
Connecting from a RHEL 9 client to RHEL 5 server:
032100
032100
$ cat ~/.ssh/config
032100
Host 192.168.0.91
032100
  KexAlgorithms            +diffie-hellman-group14-sha1
032100
  MACs                     +hmac-sha1
032100
  HostKeyAlgorithms        +ssh-rsa
032100
  PubkeyAcceptedKeyTypes   +ssh-rsa
032100
  PubkeyAcceptedAlgorithms +ssh-rsa
032100
032100
$ virsh -c 'qemu+ssh://root@192.168.0.91/system' list
032100
error: failed to connect to the hypervisor
032100
error: Cannot recv data: ssh_dispatch_run_fatal: Connection to 192.168.0.91 port 22: error in libcrypto: Connection reset by peer
032100
032100
"error in libcrypto: Connection reset by peer" is the characteristic
032100
error of openssl having been modified to disable SHA1 by default.
032100
(You will not see this on non-RHEL-derived distros.)
032100
032100
You could enable the legacy crypto policy which downgrades security on
032100
the entire host, but a more fine-grained way to do this is to create
032100
an alternate openssl configuration file that enables the "forbidden"
032100
signatures.  However this requires passing the OPENSSL_CONF
032100
environment variable through to ssh to specify the alternate
032100
configuration.  Libvirt filters out this environment variable, but
032100
this commit allows it through.  With this commit:
032100
032100
$ cat /var/tmp/openssl.cnf
032100
.include /etc/ssl/openssl.cnf
032100
[openssl_init]
032100
alg_section = evp_properties
032100
[evp_properties]
032100
rh-allow-sha1-signatures = yes
032100
032100
$ OPENSSL_CONF=/var/tmp/openssl.cnf ./run virsh -c 'qemu+ssh://root@192.168.0.91/system' list
032100
root@192.168.0.91's password:
032100
 Id   Name   State
032100
--------------------
032100
032100
Essentially my argument here is that OPENSSL_CONF is sufficiently
032100
similar in nature to KRB5CCNAME, SSH* and XAUTHORITY that we should
032100
permit it to be passed through.
032100
032100
virt-v2v bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2062360
032100
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
032100
Acked-by: Laszlo Ersek <lersek@redhat.com>
032100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
032100
032100
(cherry picked from commit 45912ac399abd9d4eba21fa3f15cb7587351f959)
032100
Libvirt BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2112348
032100
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
032100
---
032100
 src/rpc/virnetsocket.c | 1 +
032100
 1 file changed, 1 insertion(+)
032100
032100
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
032100
index 32f506d2d4..8280bda007 100644
032100
--- a/src/rpc/virnetsocket.c
032100
+++ b/src/rpc/virnetsocket.c
032100
@@ -855,6 +855,7 @@ int virNetSocketNewConnectSSH(const char *nodename,
032100
     virCommandAddEnvPass(cmd, "KRB5CCNAME");
032100
     virCommandAddEnvPass(cmd, "SSH_AUTH_SOCK");
032100
     virCommandAddEnvPass(cmd, "SSH_ASKPASS");
032100
+    virCommandAddEnvPass(cmd, "OPENSSL_CONF");
032100
     virCommandAddEnvPass(cmd, "DISPLAY");
032100
     virCommandAddEnvPass(cmd, "XAUTHORITY");
032100
     virCommandClearCaps(cmd);
032100
-- 
032100
2.35.1
032100