|
|
383d26 |
From f4ab0fe995c89692656af2c792a66892fcfbb862 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Wed, 27 Mar 2019 17:23:06 +0100
|
|
|
383d26 |
Subject: [PATCH 128/163] iotests: avoid broken pipe with certtool
|
|
|
383d26 |
MIME-Version: 1.0
|
|
|
383d26 |
Content-Type: text/plain; charset=UTF-8
|
|
|
383d26 |
Content-Transfer-Encoding: 8bit
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20190327172308.31077-54-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 85220
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 53/55] iotests: avoid broken pipe with certtool
|
|
|
383d26 |
Bugzilla: 1691009
|
|
|
383d26 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
From: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
When we run "certtool 2>&1 | head -1" the latter command is likely to
|
|
|
383d26 |
complete and exit before certtool has written everything it wants to
|
|
|
383d26 |
stderr. In at least the RHEL-7 gnutls 3.3.29 this causes certtool to
|
|
|
383d26 |
quit with broken pipe before it has finished writing the desired
|
|
|
383d26 |
output file to disk. This causes non-deterministic failures of the
|
|
|
383d26 |
iotest 233 because the certs are sometimes zero length files.
|
|
|
383d26 |
If certtool fails the "head -1" means we also lose any useful error
|
|
|
383d26 |
message it would have printed.
|
|
|
383d26 |
|
|
|
383d26 |
Thus this patch gets rid of the pipe and post-processes the output in a
|
|
|
383d26 |
more flexible & reliable manner.
|
|
|
383d26 |
|
|
|
383d26 |
Reported-by: Thomas Huth <thuth@redhat.com>
|
|
|
383d26 |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
383d26 |
Message-Id: <20190220145819.30969-3-berrange@redhat.com>
|
|
|
383d26 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 3e6f45446b11ccc20b4b751f70331f03d70369b8)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
tests/qemu-iotests/common.tls | 48 ++++++++++++++++++++++++++++---------------
|
|
|
383d26 |
1 file changed, 32 insertions(+), 16 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/tests/qemu-iotests/common.tls b/tests/qemu-iotests/common.tls
|
|
|
383d26 |
index eae8178..3caf989 100644
|
|
|
383d26 |
--- a/tests/qemu-iotests/common.tls
|
|
|
383d26 |
+++ b/tests/qemu-iotests/common.tls
|
|
|
383d26 |
@@ -29,6 +29,17 @@ tls_x509_cleanup()
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
|
|
|
383d26 |
+tls_certtool()
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ certtool "$@" 1>"${tls_dir}"/certtool.log 2>&1
|
|
|
383d26 |
+ if test "$?" = 0; then
|
|
|
383d26 |
+ head -1 "${tls_dir}"/certtool.log
|
|
|
383d26 |
+ else
|
|
|
383d26 |
+ cat "${tls_dir}"/certtool.log
|
|
|
383d26 |
+ fi
|
|
|
383d26 |
+ rm -f "${tls_dir}"/certtool.log
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
tls_x509_init()
|
|
|
383d26 |
{
|
|
|
383d26 |
(certtool --help) >/dev/null 2>&1 || \
|
|
|
383d26 |
@@ -71,10 +82,11 @@ ca
|
|
|
383d26 |
cert_signing_key
|
|
|
383d26 |
EOF
|
|
|
383d26 |
|
|
|
383d26 |
- certtool --generate-self-signed \
|
|
|
383d26 |
- --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
- --template "${tls_dir}/ca.info" \
|
|
|
383d26 |
- --outfile "${tls_dir}/$name-cert.pem" 2>&1 | head -1
|
|
|
383d26 |
+ tls_certtool \
|
|
|
383d26 |
+ --generate-self-signed \
|
|
|
383d26 |
+ --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
+ --template "${tls_dir}/ca.info" \
|
|
|
383d26 |
+ --outfile "${tls_dir}/$name-cert.pem"
|
|
|
383d26 |
|
|
|
383d26 |
rm -f "${tls_dir}/ca.info"
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -98,12 +110,14 @@ encryption_key
|
|
|
383d26 |
signing_key
|
|
|
383d26 |
EOF
|
|
|
383d26 |
|
|
|
383d26 |
- certtool --generate-certificate \
|
|
|
383d26 |
- --load-ca-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
- --load-ca-certificate "${tls_dir}/$caname-cert.pem" \
|
|
|
383d26 |
- --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
- --template "${tls_dir}/cert.info" \
|
|
|
383d26 |
- --outfile "${tls_dir}/$name/server-cert.pem" 2>&1 | head -1
|
|
|
383d26 |
+ tls_certtool \
|
|
|
383d26 |
+ --generate-certificate \
|
|
|
383d26 |
+ --load-ca-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
+ --load-ca-certificate "${tls_dir}/$caname-cert.pem" \
|
|
|
383d26 |
+ --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
+ --template "${tls_dir}/cert.info" \
|
|
|
383d26 |
+ --outfile "${tls_dir}/$name/server-cert.pem"
|
|
|
383d26 |
+
|
|
|
383d26 |
ln -s "${tls_dir}/$caname-cert.pem" "${tls_dir}/$name/ca-cert.pem"
|
|
|
383d26 |
ln -s "${tls_dir}/key.pem" "${tls_dir}/$name/server-key.pem"
|
|
|
383d26 |
|
|
|
383d26 |
@@ -127,12 +141,14 @@ encryption_key
|
|
|
383d26 |
signing_key
|
|
|
383d26 |
EOF
|
|
|
383d26 |
|
|
|
383d26 |
- certtool --generate-certificate \
|
|
|
383d26 |
- --load-ca-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
- --load-ca-certificate "${tls_dir}/$caname-cert.pem" \
|
|
|
383d26 |
- --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
- --template "${tls_dir}/cert.info" \
|
|
|
383d26 |
- --outfile "${tls_dir}/$name/client-cert.pem" 2>&1 | head -1
|
|
|
383d26 |
+ tls_certtool \
|
|
|
383d26 |
+ --generate-certificate \
|
|
|
383d26 |
+ --load-ca-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
+ --load-ca-certificate "${tls_dir}/$caname-cert.pem" \
|
|
|
383d26 |
+ --load-privkey "${tls_dir}/key.pem" \
|
|
|
383d26 |
+ --template "${tls_dir}/cert.info" \
|
|
|
383d26 |
+ --outfile "${tls_dir}/$name/client-cert.pem"
|
|
|
383d26 |
+
|
|
|
383d26 |
ln -s "${tls_dir}/$caname-cert.pem" "${tls_dir}/$name/ca-cert.pem"
|
|
|
383d26 |
ln -s "${tls_dir}/key.pem" "${tls_dir}/$name/client-key.pem"
|
|
|
383d26 |
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|