aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_flask.c
blob: 23f24766e9a80a9ebf88ac5f0e74942dc1029018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 *
 *  Author: Machon Gregory, <mbgrego@tycho.ncsc.mil>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2,
 *  as published by the Free Software Foundation.
 */

#include "libxl_osdeps.h" /* must come before any other headers */

#include "libxl_internal.h"

int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
                               uint32_t *ssidref)
{
    int rc;

    rc = xc_flask_context_to_sid(ctx->xch, buf, len, ssidref);

    return rc;
}

int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref,
                               char **buf, size_t *len)
{
    int rc;
    char tmp[XC_PAGE_SIZE];

    rc = xc_flask_sid_to_context(ctx->xch, ssidref, tmp, sizeof(tmp));

    if (!rc) {
        *len = strlen(tmp);
        *buf = strdup(tmp);
    }

    return rc;
}

int libxl_flask_getenforce(libxl_ctx *ctx)
{
    int rc;

    rc = xc_flask_getenforce(ctx->xch);

    return rc;
}

int libxl_flask_setenforce(libxl_ctx *ctx, int mode)
{
    int rc;

    rc = xc_flask_setenforce(ctx->xch, mode);

    return rc;
}

int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size)
{

    int rc;

    rc = xc_flask_load(ctx->xch, policy, size);

    return rc;
}

/*
 * Local variables:
 * mode: C
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */