1 /*
2 * Author: Machon Gregory, <mbgrego@tycho.ncsc.mil>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; version 2.1 only. with the special
7 * exception on linking described in file LICENSE.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 */
14
15 #include "libxl_osdeps.h" /* must come before any other headers */
16
17 #include "libxl_internal.h"
18
libxl_flask_context_to_sid(libxl_ctx * ctx,char * buf,size_t len,uint32_t * ssidref)19 int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
20 uint32_t *ssidref)
21 {
22 int rc;
23
24 rc = xc_flask_context_to_sid(ctx->xch, buf, len, ssidref);
25
26 return rc;
27 }
28
libxl_flask_sid_to_context(libxl_ctx * ctx,uint32_t ssidref,char ** buf,size_t * len)29 int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref,
30 char **buf, size_t *len)
31 {
32 int rc;
33 char tmp[XC_PAGE_SIZE];
34
35 rc = xc_flask_sid_to_context(ctx->xch, ssidref, tmp, sizeof(tmp));
36
37 if (!rc) {
38 *len = strlen(tmp);
39 *buf = strdup(tmp);
40 }
41
42 return rc;
43 }
44
libxl_flask_getenforce(libxl_ctx * ctx)45 int libxl_flask_getenforce(libxl_ctx *ctx)
46 {
47 int rc;
48
49 rc = xc_flask_getenforce(ctx->xch);
50
51 return rc;
52 }
53
libxl_flask_setenforce(libxl_ctx * ctx,int mode)54 int libxl_flask_setenforce(libxl_ctx *ctx, int mode)
55 {
56 int rc;
57
58 rc = xc_flask_setenforce(ctx->xch, mode);
59
60 return rc;
61 }
62
libxl_flask_loadpolicy(libxl_ctx * ctx,void * policy,uint32_t size)63 int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size)
64 {
65
66 int rc;
67
68 rc = xc_flask_load(ctx->xch, policy, size);
69
70 return rc;
71 }
72
73 /*
74 * Local variables:
75 * mode: C
76 * c-basic-offset: 4
77 * indent-tabs-mode: nil
78 * End:
79 */
80