|
|
d76c62 |
From 899a3adeded6a120a9d8f1298af482247f4696fa Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <899a3adeded6a120a9d8f1298af482247f4696fa@dist-git>
|
|
|
d76c62 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Date: Mon, 16 Mar 2020 22:12:03 +0100
|
|
|
d76c62 |
Subject: [PATCH] qemuDomainSecretStorageSourcePrepare: Setup secret for http
|
|
|
d76c62 |
cookies
|
|
|
d76c62 |
MIME-Version: 1.0
|
|
|
d76c62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d76c62 |
Content-Transfer-Encoding: 8bit
|
|
|
d76c62 |
|
|
|
d76c62 |
QEMU's curl driver requires the cookies concatenated and allows themi to
|
|
|
d76c62 |
be passed in via a secret. Prepare the value for the secret and encrypt
|
|
|
d76c62 |
it.
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
(cherry picked from commit 877cd358873982d4d6a36b7e65a8605c663e5765)
|
|
|
d76c62 |
|
|
|
d76c62 |
Conflicts:
|
|
|
d76c62 |
src/qemu/qemu_domain.c:
|
|
|
d76c62 |
Refactor to virBufferTrim not backported.
|
|
|
d76c62 |
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
|
d76c62 |
Message-Id: <e61490666a540093eac6c219c07a12c6b7d4c72a.1584391727.git.pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
src/qemu/qemu_domain.c | 33 ++++++++++++++++++++++++++++++++-
|
|
|
d76c62 |
1 file changed, 32 insertions(+), 1 deletion(-)
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
d76c62 |
index 9391bc37e0..cc47e7a2f0 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_domain.c
|
|
|
d76c62 |
+++ b/src/qemu/qemu_domain.c
|
|
|
d76c62 |
@@ -1740,6 +1740,30 @@ qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
|
|
|
d76c62 |
+static qemuDomainSecretInfoPtr
|
|
|
d76c62 |
+qemuDomainSecretStorageSourcePrepareCookies(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
+ virStorageSourcePtr src,
|
|
|
d76c62 |
+ const char *aliasprotocol)
|
|
|
d76c62 |
+{
|
|
|
d76c62 |
+ g_autofree char *secretalias = qemuAliasForSecret(aliasprotocol, "httpcookie");
|
|
|
d76c62 |
+ g_autofree char *cookies = NULL;
|
|
|
d76c62 |
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
d76c62 |
+ size_t i;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ for (i = 0; i < src->ncookies; i++) {
|
|
|
d76c62 |
+ virStorageNetCookieDefPtr cookie = src->cookies[i];
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virBufferAsprintf(&buf, "%s=%s; ", cookie->name, cookie->value);
|
|
|
d76c62 |
+ }
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ virBufferTrim(&buf, "; ", -1);
|
|
|
d76c62 |
+ cookies = virBufferContentAndReset(&buf;;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+ return qemuDomainSecretAESSetup(priv, secretalias, NULL,
|
|
|
d76c62 |
+ (uint8_t *) cookies, strlen(cookies));
|
|
|
d76c62 |
+}
|
|
|
d76c62 |
+
|
|
|
d76c62 |
+
|
|
|
d76c62 |
/**
|
|
|
d76c62 |
* qemuDomainSecretStorageSourcePrepare:
|
|
|
d76c62 |
* @priv: domain private object
|
|
|
d76c62 |
@@ -1765,7 +1789,7 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
bool hasAuth = qemuDomainStorageSourceHasAuth(src);
|
|
|
d76c62 |
bool hasEnc = qemuDomainDiskHasEncryptionSecret(src);
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (!hasAuth && !hasEnc)
|
|
|
d76c62 |
+ if (!hasAuth && !hasEnc && src->ncookies == 0)
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
|
|
|
d76c62 |
@@ -1805,6 +1829,13 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
+ if (src->ncookies &&
|
|
|
d76c62 |
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) &&
|
|
|
d76c62 |
+ !(srcPriv->httpcookie = qemuDomainSecretStorageSourcePrepareCookies(priv,
|
|
|
d76c62 |
+ src,
|
|
|
d76c62 |
+ aliasprotocol)))
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
+
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.1
|
|
|
d76c62 |
|