source code open - smack
[framework/security/smack.git] / utils / smackcipso.c
1 /*
2  * This file is part of libsmack
3  *
4  * Copyright (C) 2011 Intel Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * version 2.1 as published by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA
19  *
20  * Authors:
21  * Brian McGillion <brian.mcgillion@intel.com>
22  */
23
24 #include "common.h"
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <unistd.h>
28
29 int main(int argc, char **argv)
30 {
31         if (is_smackfs_mounted() != 1) {
32                 fprintf(stderr, "SmackFS is not mounted.\n");
33                 exit(1);
34         }
35
36         if (argc > 2) {
37                 fprintf(stderr, "Usage: %s <path>\n", argv[0]);
38                 exit(1);
39         }
40
41         if (argc == 1) {
42                 if (apply_cipso_file(STDIN_FILENO)) {
43                         perror("apply_cipso_file");
44                         exit(1);
45                 }
46         } else {
47                 if (apply_cipso(argv[1])) {
48                         perror("apply_cipso");
49                         exit(1);
50                 }
51         }
52
53         exit(0);
54 }