mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
qemuDomainSecretStorageSourcePrepare: Setup secret for http cookies
QEMU's curl driver requires the cookies concatenated and allows themi to be passed in via a secret. Prepare the value for the secret and encrypt it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4e8faa5cdc
commit
877cd35887
@ -1732,6 +1732,30 @@ qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static qemuDomainSecretInfoPtr
|
||||||
|
qemuDomainSecretStorageSourcePrepareCookies(qemuDomainObjPrivatePtr priv,
|
||||||
|
virStorageSourcePtr src,
|
||||||
|
const char *aliasprotocol)
|
||||||
|
{
|
||||||
|
g_autofree char *secretalias = qemuAliasForSecret(aliasprotocol, "httpcookie");
|
||||||
|
g_autofree char *cookies = NULL;
|
||||||
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < src->ncookies; i++) {
|
||||||
|
virStorageNetCookieDefPtr cookie = src->cookies[i];
|
||||||
|
|
||||||
|
virBufferAsprintf(&buf, "%s=%s; ", cookie->name, cookie->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferTrim(&buf, "; ");
|
||||||
|
cookies = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
|
return qemuDomainSecretAESSetup(priv, secretalias, NULL,
|
||||||
|
(uint8_t *) cookies, strlen(cookies));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuDomainSecretStorageSourcePrepare:
|
* qemuDomainSecretStorageSourcePrepare:
|
||||||
* @priv: domain private object
|
* @priv: domain private object
|
||||||
@ -1757,7 +1781,7 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
|
|||||||
bool hasAuth = qemuDomainStorageSourceHasAuth(src);
|
bool hasAuth = qemuDomainStorageSourceHasAuth(src);
|
||||||
bool hasEnc = qemuDomainDiskHasEncryptionSecret(src);
|
bool hasEnc = qemuDomainDiskHasEncryptionSecret(src);
|
||||||
|
|
||||||
if (!hasAuth && !hasEnc)
|
if (!hasAuth && !hasEnc && src->ncookies == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
|
if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
|
||||||
@ -1797,6 +1821,13 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->ncookies &&
|
||||||
|
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) &&
|
||||||
|
!(srcPriv->httpcookie = qemuDomainSecretStorageSourcePrepareCookies(priv,
|
||||||
|
src,
|
||||||
|
aliasprotocol)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user