seclabeltest.c 1000 字节
Newer Older
1 2 3 4 5 6 7
#include <config.h>

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
8
#include "security/security_driver.h"
9 10 11 12 13 14 15 16 17

int
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
    int ret;

    const char *doi, *model;
    virSecurityDriverPtr security_drv;

18
    ret = virSecurityDriverStartup (&security_drv, "selinux", false);
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
    if (ret == -1)
    {
        fprintf (stderr, "Failed to start security driver");
        exit (-1);
    }
    /* No security driver wanted to be enabled: just return */
    if (ret == -2)
        return 0;

    model = virSecurityDriverGetModel (security_drv);
    if (!model)
    {
        fprintf (stderr, "Failed to copy secModel model: %s",
                 strerror (errno));
        exit (-1);
    }

    doi = virSecurityDriverGetDOI (security_drv);
    if (!doi)
    {
        fprintf (stderr, "Failed to copy secModel DOI: %s",
                 strerror (errno));
        exit (-1);
    }

    return 0;
}