mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
87de27b7f9
All callers used the same initialization seed (well, the new viratomictest forgot to look at getpid()); so we might as well make this value automatic. And while it may feel like we are giving up functionality, I documented how to get it back in the unlikely case that you actually need to debug with a fixed pseudo-random sequence. I left that crippled by default, so that a stray environment variable doesn't cause a lack of randomness to become a security issue. * src/util/virrandom.c (virRandomInitialize): Rename... (virRandomOnceInit): ...and make static, with one-shot call. Document how to do fixed-seed debugging. * src/util/virrandom.h (virRandomInitialize): Drop prototype. * src/libvirt_private.syms (virrandom.h): Don't export it. * src/libvirt.c (virInitialize): Adjust caller. * src/lxc/lxc_controller.c (main): Likewise. * src/security/virt-aa-helper.c (main): Likewise. * src/util/iohelper.c (main): Likewise. * tests/seclabeltest.c (main): Likewise. * tests/testutils.c (virtTestMain): Likewise. * tests/viratomictest.c (mymain): Likewise.
46 lines
1003 B
C
46 lines
1003 B
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)
|
|
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;
|
|
}
|