提交 8be83eef 编写于 作者: J John Ferlan

qemu: Remove authdef from secret setup

Rather than pass authdef, pass the 'authdef->username' and the
'&authdef->secdef'

Note that a username may be NULL.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 23c5f1b0
...@@ -815,7 +815,8 @@ qemuDomainHostdevPrivateDispose(void *obj) ...@@ -815,7 +815,8 @@ qemuDomainHostdevPrivateDispose(void *obj)
* @conn: Pointer to connection * @conn: Pointer to connection
* @secinfo: Pointer to secret info * @secinfo: Pointer to secret info
* @secretUsageType: The virSecretUsageType * @secretUsageType: The virSecretUsageType
* @authdef: Pointer to auth data * @username: username to use for authentication (may be NULL)
* @seclookupdef: Pointer to seclookupdef data
* *
* Taking a secinfo, fill in the plaintext information * Taking a secinfo, fill in the plaintext information
* *
...@@ -825,14 +826,14 @@ static int ...@@ -825,14 +826,14 @@ static int
qemuDomainSecretPlainSetup(virConnectPtr conn, qemuDomainSecretPlainSetup(virConnectPtr conn,
qemuDomainSecretInfoPtr secinfo, qemuDomainSecretInfoPtr secinfo,
virSecretUsageType secretUsageType, virSecretUsageType secretUsageType,
virStorageAuthDefPtr authdef) const char *username,
virSecretLookupTypeDefPtr seclookupdef)
{ {
secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN; secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN;
if (VIR_STRDUP(secinfo->s.plain.username, authdef->username) < 0) if (VIR_STRDUP(secinfo->s.plain.username, username) < 0)
return -1; return -1;
return virSecretGetSecretString(conn, &authdef->seclookupdef, return virSecretGetSecretString(conn, seclookupdef, secretUsageType,
secretUsageType,
&secinfo->s.plain.secret, &secinfo->s.plain.secret,
&secinfo->s.plain.secretlen); &secinfo->s.plain.secretlen);
} }
...@@ -844,7 +845,8 @@ qemuDomainSecretPlainSetup(virConnectPtr conn, ...@@ -844,7 +845,8 @@ qemuDomainSecretPlainSetup(virConnectPtr conn,
* @secinfo: Pointer to secret info * @secinfo: Pointer to secret info
* @srcalias: Alias of the disk/hostdev used to generate the secret alias * @srcalias: Alias of the disk/hostdev used to generate the secret alias
* @secretUsageType: The virSecretUsageType * @secretUsageType: The virSecretUsageType
* @authdef: Pointer to auth data * @username: username to use for authentication (may be NULL)
* @seclookupdef: Pointer to seclookupdef data
* *
* Taking a secinfo, fill in the AES specific information using the * Taking a secinfo, fill in the AES specific information using the
* *
...@@ -856,7 +858,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn, ...@@ -856,7 +858,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
qemuDomainSecretInfoPtr secinfo, qemuDomainSecretInfoPtr secinfo,
const char *srcalias, const char *srcalias,
virSecretUsageType secretUsageType, virSecretUsageType secretUsageType,
virStorageAuthDefPtr authdef) const char *username,
virSecretLookupTypeDefPtr seclookupdef)
{ {
int ret = -1; int ret = -1;
uint8_t *raw_iv = NULL; uint8_t *raw_iv = NULL;
...@@ -867,7 +870,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn, ...@@ -867,7 +870,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
size_t ciphertextlen = 0; size_t ciphertextlen = 0;
secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES; secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
if (VIR_STRDUP(secinfo->s.aes.username, authdef->username) < 0) if (VIR_STRDUP(secinfo->s.aes.username, username) < 0)
return -1; return -1;
if (!(secinfo->s.aes.alias = qemuDomainGetSecretAESAlias(srcalias))) if (!(secinfo->s.aes.alias = qemuDomainGetSecretAESAlias(srcalias)))
...@@ -882,7 +885,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn, ...@@ -882,7 +885,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
goto cleanup; goto cleanup;
/* Grab the unencoded secret */ /* Grab the unencoded secret */
if (virSecretGetSecretString(conn, &authdef->seclookupdef, secretUsageType, if (virSecretGetSecretString(conn, seclookupdef, secretUsageType,
&secret, &secretlen) < 0) &secret, &secretlen) < 0)
goto cleanup; goto cleanup;
...@@ -917,7 +920,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn, ...@@ -917,7 +920,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
* @secinfo: Pointer to secret info * @secinfo: Pointer to secret info
* @srcalias: Alias of the disk/hostdev used to generate the secret alias * @srcalias: Alias of the disk/hostdev used to generate the secret alias
* @secretUsageType: The virSecretUsageType * @secretUsageType: The virSecretUsageType
* @authdef: Pointer to auth data * @username: username to use for authentication (may be NULL)
* @seclookupdef: Pointer to seclookupdef data
* *
* If we have the encryption API present and can support a secret object, then * If we have the encryption API present and can support a secret object, then
* build the AES secret; otherwise, build the Plain secret. This is the magic * build the AES secret; otherwise, build the Plain secret. This is the magic
...@@ -932,17 +936,19 @@ qemuDomainSecretSetup(virConnectPtr conn, ...@@ -932,17 +936,19 @@ qemuDomainSecretSetup(virConnectPtr conn,
qemuDomainSecretInfoPtr secinfo, qemuDomainSecretInfoPtr secinfo,
const char *srcalias, const char *srcalias,
virSecretUsageType secretUsageType, virSecretUsageType secretUsageType,
virStorageAuthDefPtr authdef) const char *username,
virSecretLookupTypeDefPtr seclookupdef)
{ {
if (virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) && if (virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) &&
secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH) { secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH) {
if (qemuDomainSecretAESSetup(conn, priv, secinfo, srcalias, if (qemuDomainSecretAESSetup(conn, priv, secinfo, srcalias,
secretUsageType, authdef) < 0) secretUsageType, username,
seclookupdef) < 0)
return -1; return -1;
} else { } else {
if (qemuDomainSecretPlainSetup(conn, secinfo, secretUsageType, if (qemuDomainSecretPlainSetup(conn, secinfo, secretUsageType,
authdef) < 0) username, seclookupdef) < 0)
return -1; return -1;
} }
return 0; return 0;
...@@ -999,7 +1005,8 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, ...@@ -999,7 +1005,8 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
secretUsageType = VIR_SECRET_USAGE_TYPE_CEPH; secretUsageType = VIR_SECRET_USAGE_TYPE_CEPH;
if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias, if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias,
secretUsageType, src->auth) < 0) secretUsageType, src->auth->username,
&src->auth->seclookupdef) < 0)
goto error; goto error;
diskPriv->secinfo = secinfo; diskPriv->secinfo = secinfo;
...@@ -1065,7 +1072,8 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn, ...@@ -1065,7 +1072,8 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
if (qemuDomainSecretSetup(conn, priv, secinfo, hostdev->info->alias, if (qemuDomainSecretSetup(conn, priv, secinfo, hostdev->info->alias,
VIR_SECRET_USAGE_TYPE_ISCSI, VIR_SECRET_USAGE_TYPE_ISCSI,
iscsisrc->auth) < 0) iscsisrc->auth->username,
&iscsisrc->auth->seclookupdef) < 0)
goto error; goto error;
hostdevPriv->secinfo = secinfo; hostdevPriv->secinfo = secinfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册