Replace use of the gnulib base64 module with glib's own base64 API family.
Signed-off-by: Daniel P. Berrangé
---
bootstrap.conf| 1 -
configure.ac | 5 -
src/conf/virsecretobj.c | 26 --
src/libvirt_private.syms | 1 -
src/libxl/libxl_conf.c| 3 +--
src/qemu/qemu_agent.c | 6 ++
src/qemu/qemu_command.c | 5 ++---
src/qemu/qemu_domain.c| 8 +++-
src/secret/secret_driver.c| 1 -
src/storage/storage_backend_rbd.c | 4 +---
src/util/virstring.c | 21 -
src/util/virstring.h | 2 --
tools/virsh-secret.c | 17 -
13 files changed, 17 insertions(+), 83 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 7105ae2eeb..acb0e25a37 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -20,7 +20,6 @@
gnulib_modules='
accept
areadlink
-base64
bind
byteswap
c-ctype
diff --git a/configure.ac b/configure.ac
index 81f061f058..1782665835 100644
--- a/configure.ac
+++ b/configure.ac
@@ -911,11 +911,6 @@ test "x$lv_cv_static_analysis" = xyes && t=1
AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
[Define to 1 when performing static analysis.])
-# Some GNULIB base64 symbols clash with a kerberos library
-AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[Hack to avoid symbol
clash])
-AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avoid
symbol clash])
-AC_DEFINE_UNQUOTED([base64_encode_alloc],[libvirt_gl_base64_encode_alloc],[Hack
to avoid symbol clash])
-
AC_CONFIG_FILES([run],
[chmod +x,-w run])
AC_CONFIG_FILES([\
diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index aeae82332b..5bd84d82ed 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -31,7 +31,6 @@
#include "virhash.h"
#include "virlog.h"
#include "virstring.h"
-#include "base64.h"
#define VIR_FROM_THIS VIR_FROM_SECRET
@@ -698,8 +697,7 @@ virSecretObjSaveData(virSecretObjPtr obj)
if (!obj->value)
return 0;
-if (!(base64 = virStringEncodeBase64(obj->value, obj->value_size)))
-return -1;
+base64 = g_base64_encode(obj->value, obj->value_size);
if (virFileRewriteStr(obj->base64File, S_IRUSR | S_IWUSR, base64) < 0)
return -1;
@@ -825,8 +823,6 @@ virSecretLoadValue(virSecretObjPtr obj)
int ret = -1, fd = -1;
struct stat st;
g_autofree char *contents = NULL;
-char *value = NULL;
-size_t value_size;
if ((fd = open(obj->base64File, O_RDONLY)) == -1) {
if (errno == ENOENT) {
@@ -851,7 +847,7 @@ virSecretLoadValue(virSecretObjPtr obj)
goto cleanup;
}
-if (VIR_ALLOC_N(contents, st.st_size) < 0)
+if (VIR_ALLOC_N(contents, st.st_size + 1) < 0)
goto cleanup;
if (saferead(fd, contents, st.st_size) != st.st_size) {
@@ -859,29 +855,15 @@ virSecretLoadValue(virSecretObjPtr obj)
obj->base64File);
goto cleanup;
}
+contents[st.st_size] = '\0';
VIR_FORCE_CLOSE(fd);
-if (!base64_decode_alloc(contents, st.st_size, , _size)) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
- _("invalid base64 in '%s'"),
- obj->base64File);
-goto cleanup;
-}
-if (value == NULL)
-goto cleanup;
-
-obj->value = (unsigned char *)value;
-value = NULL;
-obj->value_size = value_size;
+obj->value = g_base64_decode(contents, >value_size);
ret = 0;
cleanup:
-if (value != NULL) {
-memset(value, 0, value_size);
-VIR_FREE(value);
-}
if (contents != NULL)
memset(contents, 0, st.st_size);
VIR_FORCE_CLOSE(fd);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index eeab820eca..b27b20ecd0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3069,7 +3069,6 @@ virSkipSpacesBackwards;
virStrcpy;
virStrdup;
virStringBufferIsPrintable;
-virStringEncodeBase64;
virStringFilterChars;
virStringHasCaseSuffix;
virStringHasChars;
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index c76704a11d..de56567cf0 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -999,8 +999,7 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char
**srcstr)
goto cleanup;
/* RBD expects an encoded secret */
-if (!(base64secret = virStringEncodeBase64(secret, secretlen)))
-goto cleanup;
+base64secret = g_base64_encode(secret, secretlen);
}
if (!(*srcstr = libxlMakeNetworkDiskSrcStr(src, username, base64secret)))
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 34e1a85d64..0ef8b563f5 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -39,7 +39,6 @@
#include "virtime.h"
#include "virobject.h"
#include "virstring.h"
-#include "base64.h"