Add smackcipso
authorBrian McGillion <brian.mcgillion@intel.com>
Fri, 11 Nov 2011 08:47:49 +0000 (10:47 +0200)
committerBrian McGillion <brian.mcgillion@intel.com>
Fri, 11 Nov 2011 08:47:49 +0000 (10:47 +0200)
utils/Makefile.am
utils/smackcipso.c [new file with mode: 0644]
utils/smackload.c

index be466ae..2cc098c 100644 (file)
@@ -1,5 +1,5 @@
 instdir = ${bindir}
-inst_PROGRAMS = smackctl smackaccess smackself smackload
+inst_PROGRAMS = smackctl smackaccess smackself smackload smackcipso
 AM_CPPFLAGS = \
        -I$(top_srcdir)/libsmack
 
@@ -14,3 +14,6 @@ smackself_LDADD = ../libsmack/libsmack.la
 
 smackload_SOURCES = smackload.c common.c
 smackload_LDADD = ../libsmack/libsmack.la
+
+smackcipso_SOURCES = smackcipso.c common.c
+smackcipso_LDADD = ../libsmack/libsmack.la
diff --git a/utils/smackcipso.c b/utils/smackcipso.c
new file mode 100644 (file)
index 0000000..74ebce5
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * This file is part of libsmack
+ *
+ * Copyright (C) 2011 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ * Authors:
+ * Brian McGillion <brian.mcgillion@intel.com>
+ */
+
+#include "common.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s <path>\n", argv[0]);
+               exit(1);
+       }
+
+       if (apply_cipso(argv[1])) {
+               perror("Failure to apply cipso : ");
+               exit(1);
+       }
+
+       exit(0);
+}
index af93153..17d3888 100644 (file)
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-static int usage(const char *bin)
+static void usage(const char *bin)
 {
        fprintf(stderr, "Usage: %s [-c] <path>\n", bin);
        exit(1);
@@ -52,11 +52,13 @@ int main(int argc, char **argv)
 
        if (is_smackfs_mounted() != 1) {
                fprintf(stderr, "ERROR: SmackFS is not mounted.\n");
-               return -1;
+               exit(1);
        }
 
-       if (apply_rules(argv[optind], clear))
-               perror("Applying rules");
+       if (apply_rules(argv[optind], clear)) {
+               perror("Failure applying rules : ");
+               exit(1);
+       }
 
        exit(0);
 }