debuggers.hg

view tools/flask/utils/getenforce.c @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents 779c0ef9682c
children
line source
1 /*
2 *
3 * Author: Machon Gregory, <mbgrego@tycho.ncsc.mil>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2,
7 * as published by the Free Software Foundation.
8 */
10 #include <stdlib.h>
11 #include <errno.h>
12 #include <stdio.h>
13 #include <xenctrl.h>
14 #include <fcntl.h>
15 #include <sys/mman.h>
16 #include <sys/stat.h>
17 #include <string.h>
18 #include <unistd.h>
19 #include <libflask.h>
21 static void usage (int argCnt, const char *args[])
22 {
23 fprintf(stderr, "Usage: %s\n", args[0]);
24 exit(1);
25 }
27 int main (int argCnt, const char *args[])
28 {
29 int ret;
30 xc_interface *xch = 0;
32 if (argCnt != 1)
33 usage(argCnt, args);
35 xch = xc_interface_open(0,0,0);
36 if ( !xch )
37 {
38 fprintf(stderr, "Unable to create interface to xenctrl: %s\n",
39 strerror(errno));
40 ret = -1;
41 goto done;
42 }
44 ret = flask_getenforce(xch);
45 if ( ret < 0 )
46 {
47 errno = -ret;
48 fprintf(stderr, "Unable to get enforcing mode: %s\n",
49 strerror(errno));
50 ret = -1;
51 goto done;
52 }
53 else
54 {
55 if(ret)
56 printf("Enforcing\n");
57 else
58 printf("Permissive\n");
59 }
61 done:
62 if ( xch )
63 xc_interface_close(xch);
65 return ret;
66 }