mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
src: elevate current identity privilege when fetching secret
When fetching the value of a private secret, we need to use an elevated identity otherwise the secret driver will deny access. When using the modular daemons, the elevated identity needs to be active before the secret driver connection is opened, and it will apply to all APIs calls made on that conncetion. When using the monolithic daemon, the identity at time of opening the connection is ignored, and the elevated identity needs to be active precisely at the time the virSecretGetValue API call is made. After acquiring the secret value, the elevated identity should be cleared. This sounds complex, but is fairly straightfoward with the automatic cleanup callbacks. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
@@ -18,10 +18,13 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#define LIBVIRT_VIRIDENTITYPRIV_H_ALLOW
|
||||
|
||||
#include "internal.h"
|
||||
#include "viralloc.h"
|
||||
#include "vircommand.h"
|
||||
#include "vircrypto.h"
|
||||
#include "viridentitypriv.h"
|
||||
#include "virmock.h"
|
||||
#include "virlog.h"
|
||||
#include "virnetdev.h"
|
||||
@@ -292,3 +295,9 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED)
|
||||
abort();
|
||||
return 1732;
|
||||
}
|
||||
|
||||
char *
|
||||
virIdentityEnsureSystemToken(void)
|
||||
{
|
||||
return g_strdup("3de80bcbf22d4833897f1638e01be9b2");
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
# include "internal.h"
|
||||
# include "viralloc.h"
|
||||
# include "viridentity.h"
|
||||
# include "qemu/qemu_alias.h"
|
||||
# include "qemu/qemu_capabilities.h"
|
||||
# include "qemu/qemu_command.h"
|
||||
@@ -650,6 +651,7 @@ testCompareXMLToArgv(const void *data)
|
||||
xmlNodePtr root;
|
||||
g_autofree char *archstr = NULL;
|
||||
virArch arch = VIR_ARCH_NONE;
|
||||
g_autoptr(virIdentity) sysident = virIdentityGetSystem();
|
||||
|
||||
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
|
||||
qemuTestSetHostArch(&driver, info->arch);
|
||||
@@ -670,6 +672,9 @@ testCompareXMLToArgv(const void *data)
|
||||
virSetConnectSecret(conn);
|
||||
virSetConnectStorage(conn);
|
||||
|
||||
if (virIdentitySetCurrent(sysident) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (testCheckExclusiveFlags(info->flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@@ -809,6 +814,7 @@ testCompareXMLToArgv(const void *data)
|
||||
VIR_FREE(log);
|
||||
virDomainChrSourceDefClear(&monitor_chr);
|
||||
virObjectUnref(vm);
|
||||
virIdentitySetCurrent(NULL);
|
||||
virSetConnectSecret(NULL);
|
||||
virSetConnectStorage(NULL);
|
||||
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
|
||||
|
||||
Reference in New Issue
Block a user