{
bool encode = false;
int secretType = VIR_SECRET_USAGE_TYPE_ISCSI;
- const char *protocolstr = virStorageNetProtocolTypeToString(protocol);
secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN;
if (VIR_STRDUP(secinfo->s.plain.username, authdef->username) < 0)
}
if (!(secinfo->s.plain.secret =
- virSecretGetSecretString(conn, protocolstr, encode,
- authdef, secretType)))
+ virSecretGetSecretString(conn, encode, authdef, secretType)))
return -1;
return 0;
/* virSecretGetSecretString:
* @conn: Pointer to the connection driver to make secret driver call
- * @scheme: Unique enough string for error message to help determine cause
* @encoded: Whether the returned secret needs to be base64 encoded
* @authdef: Pointer to the disk storage authentication
* @secretUsageType: Type of secret usage for authdef lookup
*/
char *
virSecretGetSecretString(virConnectPtr conn,
- const char *scheme,
bool encoded,
virStorageAuthDefPtr authdef,
virSecretUsageType secretUsageType)
size_t secret_size;
virSecretPtr sec = NULL;
char *secret = NULL;
- char uuidStr[VIR_UUID_STRING_BUFLEN];
- /* look up secret */
switch (authdef->secretType) {
case VIR_STORAGE_SECRET_TYPE_UUID:
- sec = virSecretLookupByUUID(conn, authdef->secret.uuid);
- virUUIDFormat(authdef->secret.uuid, uuidStr);
+ sec = conn->secretDriver->secretLookupByUUID(conn, authdef->secret.uuid);
break;
+
case VIR_STORAGE_SECRET_TYPE_USAGE:
- sec = virSecretLookupByUsage(conn, secretUsageType,
- authdef->secret.usage);
+ sec = conn->secretDriver->secretLookupByUsage(conn, secretUsageType,
+ authdef->secret.usage);
break;
}
- if (!sec) {
- if (authdef->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
- virReportError(VIR_ERR_NO_SECRET,
- _("%s no secret matches uuid '%s'"),
- scheme, uuidStr);
- } else {
- virReportError(VIR_ERR_NO_SECRET,
- _("%s no secret matches usage value '%s'"),
- scheme, authdef->secret.usage);
- }
+ if (!sec)
goto cleanup;
- }
secret = (char *)conn->secretDriver->secretGetValue(sec, &secret_size, 0,
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
- if (!secret) {
- if (authdef->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("could not get value of the secret for "
- "username '%s' using uuid '%s'"),
- authdef->username, uuidStr);
- } else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("could not get value of the secret for "
- "username '%s' using usage value '%s'"),
- authdef->username, authdef->secret.usage);
- }
+
+ if (!secret)
goto cleanup;
- }
if (encoded) {
char *base64 = NULL;
# include "virstoragefile.h"
char *virSecretGetSecretString(virConnectPtr conn,
- const char *scheme,
bool encoded,
virStorageAuthDefPtr authdef,
virSecretUsageType secretUsageType)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4)
- ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
#endif /* __VIR_SECRET_H__ */