Create smackload based on libsmack
authorBrian McGillion <brian.mcgillion@intel.com>
Fri, 11 Nov 2011 08:25:42 +0000 (10:25 +0200)
committerBrian McGillion <brian.mcgillion@intel.com>
Fri, 11 Nov 2011 08:25:42 +0000 (10:25 +0200)
utils/Makefile.am
utils/smackload.c [new file with mode: 0644]

index 06f0424..be466ae 100644 (file)
@@ -1,5 +1,5 @@
 instdir = ${bindir}
-inst_PROGRAMS = smackctl smackaccess smackself
+inst_PROGRAMS = smackctl smackaccess smackself smackload
 AM_CPPFLAGS = \
        -I$(top_srcdir)/libsmack
 
@@ -11,3 +11,6 @@ smackaccess_LDADD = ../libsmack/libsmack.la
 
 smackself_SOURCES = smackself.c
 smackself_LDADD = ../libsmack/libsmack.la
+
+smackload_SOURCES = smackload.c common.c
+smackload_LDADD = ../libsmack/libsmack.la
diff --git a/utils/smackload.c b/utils/smackload.c
new file mode 100644 (file)
index 0000000..b86ee81
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+       int clear = 0;
+       int c;
+
+       while ((c = getopt(argc, argv, "c")) != -1) {
+               switch (c) {
+                       case 'c':
+                               clear = 1;
+                               break;
+                       default:
+                               fprintf(stderr, "Usage: %s [-c] <path>\n", argv[0]);
+                               exit(1);
+               }
+       }
+
+       if (is_smackfs_mounted() != 1) {
+               fprintf(stderr, "ERROR: SmackFS is not mounted.\n");
+               return -1;
+       }
+
+       if (apply_rules(argv[optind], clear))
+               perror("Applying rules");
+
+       exit(0);
+}