mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
a22a36e8fe
Commit a56c347
introduced a use of random numbers into seclabel
handling, but failed to initialize the random number generator
in the testsuite. Also, fail with usual status, not 255.
* tests/seclabeltest.c (main): Initialize randomness.
47 lines
1.0 KiB
C
47 lines
1.0 KiB
C
#include <config.h>
|
|
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include "security/security_driver.h"
|
|
#include "virrandom.h"
|
|
|
|
int
|
|
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
|
{
|
|
virSecurityManagerPtr mgr;
|
|
const char *doi, *model;
|
|
|
|
if (virThreadInitialize() < 0 ||
|
|
virRandomInitialize(time(NULL) ^ getpid()))
|
|
exit(EXIT_FAILURE);
|
|
|
|
mgr = virSecurityManagerNew(NULL, "QEMU", false, true, false);
|
|
if (mgr == NULL) {
|
|
fprintf (stderr, "Failed to start security driver");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
model = virSecurityManagerGetModel(mgr);
|
|
if (!model)
|
|
{
|
|
fprintf (stderr, "Failed to copy secModel model: %s",
|
|
strerror (errno));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
doi = virSecurityManagerGetDOI(mgr);
|
|
if (!doi)
|
|
{
|
|
fprintf (stderr, "Failed to copy secModel DOI: %s",
|
|
strerror (errno));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
virSecurityManagerFree(mgr);
|
|
|
|
return 0;
|
|
}
|