qemusecuritytest: Skip on non supported platforms

For seclabel remembering we need to have XATTRs and a special
namespace that is accessibly to CAP_SYS_ADMIN only (we don't want
regular users to trick us into restoring to a different label).
And what qemusecuritytest does is it checks whether we have not
left any path behind with XATTRs or not restored to original
seclabel after setAll + restoreAll round trip. But it can hardly
do so if ran on a platform where there's no XATTR namespace we
can use.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2020-11-03 13:26:00 +01:00
parent df8ff46a16
commit 995394c5a3
4 changed files with 24 additions and 0 deletions

View File

@ -1609,6 +1609,10 @@ virSecurityManagerTransactionStart;
virSecurityManagerVerify;
# security/security_util.h
virSecurityXATTRNamespaceDefined;
# util/glibcompat.h
vir_g_canonicalize_filename;
vir_g_fsync;

View File

@ -107,6 +107,17 @@ virSecurityGetTimestampAttrName(const char *name G_GNUC_UNUSED)
#endif /* !XATTR_NAMESPACE */
bool
virSecurityXATTRNamespaceDefined(void)
{
#ifdef XATTR_NAMESPACE
return true;
#else
return false;
#endif
}
static char *
virSecurityGetTimestamp(void)
{

View File

@ -32,3 +32,6 @@ int
virSecurityMoveRememberedLabel(const char *name,
const char *src,
const char *dst);
bool
virSecurityXATTRNamespaceDefined(void);

View File

@ -22,6 +22,7 @@
#include "testutils.h"
#include "testutilsqemu.h"
#include "security/security_manager.h"
#include "security/security_util.h"
#include "conf/domain_conf.h"
#include "qemu/qemu_domain.h"
#include "qemu/qemu_security.h"
@ -148,6 +149,11 @@ mymain(void)
qemuTestDriverInit(&driver) < 0)
return -1;
if (!virSecurityXATTRNamespaceDefined()) {
ret = EXIT_AM_SKIP;
goto cleanup;
}
/* Now fix the secdriver */
virObjectUnref(driver.securityManager);