[PATCH 07/12] qemu: Remove VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN and associated code

Peter Krempa posted 12 patches 3 years, 1 month ago
[PATCH 07/12] qemu: Remove VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN and associated code
Posted by Peter Krempa 3 years, 1 month ago
There's no code which could set it any more so we can remove the
generators.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_command.c | 29 +----------------------------
 src/qemu/qemu_domain.c  | 13 -------------
 src/qemu/qemu_domain.h  |  9 ---------
 3 files changed, 1 insertion(+), 50 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 39659fe4f6..6e8699a3c6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -760,28 +760,13 @@ qemuBuildObjectSecretCommandLine(virCommand *cmd,
  * -1 and error message if fail to add secret information
  */
 static int
-qemuBuildGeneralSecinfoURI(virURI *uri,
+qemuBuildGeneralSecinfoURI(virURI *uri G_GNUC_UNUSED,
                            qemuDomainSecretInfo *secinfo)
 {
     if (!secinfo)
         return 0;

     switch ((qemuDomainSecretInfoType) secinfo->type) {
-    case VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN:
-        if (secinfo->s.plain.secret) {
-            if (!virStringBufferIsPrintable(secinfo->s.plain.secret,
-                                            secinfo->s.plain.secretlen)) {
-                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                               _("found non printable characters in secret"));
-                return -1;
-            }
-            uri->user = g_strdup_printf("%s:%s", secinfo->s.plain.username,
-                                        secinfo->s.plain.secret);
-        } else {
-            uri->user = g_strdup(secinfo->s.plain.username);
-        }
-        break;
-
     case VIR_DOMAIN_SECRET_INFO_TYPE_AES:
     case VIR_DOMAIN_SECRET_INFO_TYPE_LAST:
         return -1;
@@ -806,24 +791,12 @@ static int
 qemuBuildRBDSecinfoURI(virBuffer *buf,
                        qemuDomainSecretInfo *secinfo)
 {
-    g_autofree char *base64secret = NULL;
-
     if (!secinfo) {
         virBufferAddLit(buf, ":auth_supported=none");
         return 0;
     }

     switch ((qemuDomainSecretInfoType) secinfo->type) {
-    case VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN:
-        base64secret = g_base64_encode(secinfo->s.plain.secret,
-                                       secinfo->s.plain.secretlen);
-        virBufferEscape(buf, '\\', ":", ":id=%s", secinfo->s.plain.username);
-        virBufferEscape(buf, '\\', ":",
-                        ":key=%s:auth_supported=cephx\\;none",
-                        base64secret);
-        virSecureEraseString(base64secret);
-        break;
-
     case VIR_DOMAIN_SECRET_INFO_TYPE_AES:
         virBufferEscape(buf, '\\', ":", ":id=%s:auth_supported=cephx\\;none",
                         secinfo->s.aes.username);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 73e69d1558..e9c1f3eacb 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -657,15 +657,6 @@ qemuDomainMasterKeyCreate(virDomainObj *vm)
 }


-static void
-qemuDomainSecretPlainClear(struct _qemuDomainSecretPlain *secret)
-{
-    VIR_FREE(secret->username);
-    virSecureErase(secret->secret, secret->secretlen);
-    g_clear_pointer(&secret->secret, g_free);
-}
-
-
 static void
 qemuDomainSecretAESClear(struct _qemuDomainSecretAES *secret,
                          bool keepAlias)
@@ -687,10 +678,6 @@ qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo,
         return;

     switch ((qemuDomainSecretInfoType) secinfo->type) {
-    case VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN:
-        qemuDomainSecretPlainClear(&secinfo->s.plain);
-        break;
-
     case VIR_DOMAIN_SECRET_INFO_TYPE_AES:
         qemuDomainSecretAESClear(&secinfo->s.aes, keepAlias);
         break;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 08f33f0f9e..cb5c665766 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -92,19 +92,11 @@ struct _qemuDomainUnpluggingDevice {

 /* Type of domain secret */
 typedef enum {
-    VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN = 0,
     VIR_DOMAIN_SECRET_INFO_TYPE_AES,  /* utilize GNUTLS_CIPHER_AES_256_CBC */

     VIR_DOMAIN_SECRET_INFO_TYPE_LAST
 } qemuDomainSecretInfoType;

-typedef struct _qemuDomainSecretPlain qemuDomainSecretPlain;
-struct _qemuDomainSecretPlain {
-    char *username;
-    uint8_t *secret;
-    size_t secretlen;
-};
-
 #define QEMU_DOMAIN_AES_IV_LEN 16   /* 16 bytes for 128 bit random */
                                     /*    initialization vector */
 typedef struct _qemuDomainSecretAES qemuDomainSecretAES;
@@ -119,7 +111,6 @@ typedef struct _qemuDomainSecretInfo qemuDomainSecretInfo;
 struct _qemuDomainSecretInfo {
     qemuDomainSecretInfoType type;
     union {
-        qemuDomainSecretPlain plain;
         qemuDomainSecretAES aes;
     } s;
 };
-- 
2.31.1