Add init scripts
authorBrian McGillion <brian.mcgillion@intel.com>
Mon, 6 Feb 2012 15:40:31 +0000 (17:40 +0200)
committerBrian McGillion <brian.mcgillion@intel.com>
Mon, 6 Feb 2012 15:40:31 +0000 (17:40 +0200)
Makefile.am
configure.ac
init/Makefile.am [new file with mode: 0644]
init/smack.mount [new file with mode: 0644]
init/smack.service [new file with mode: 0644]
utils/common.c
utils/common.h
utils/smackctl.c

index 41fefd8..4f90bc5 100644 (file)
@@ -1,4 +1,4 @@
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 AM_MAKEFLAGS = --no-print-directory
 
-SUBDIRS = libsmack utils doc
+SUBDIRS = libsmack utils doc init
index 9d87b27..6e4d7a1 100644 (file)
@@ -23,6 +23,6 @@ fi
 AM_CONDITIONAL([ENABLE_DOXYGEN],[test ! -z "$DOXYGEN"], [Build API documentation.])
 AC_SUBST([DOXYGEN], [$DOXYGEN])
 
-AC_CONFIG_FILES([Makefile libsmack/Makefile libsmack/libsmack.pc utils/Makefile doc/Makefile])
+AC_CONFIG_FILES([Makefile libsmack/Makefile libsmack/libsmack.pc utils/Makefile doc/Makefile init/Makefile])
 
 AC_OUTPUT
diff --git a/init/Makefile.am b/init/Makefile.am
new file mode 100644 (file)
index 0000000..8fad8e5
--- /dev/null
@@ -0,0 +1,2 @@
+initdir = /lib/systemd/system
+init_DATA = smack.mount smack.service
diff --git a/init/smack.mount b/init/smack.mount
new file mode 100644 (file)
index 0000000..312e077
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Smack filesystem mounting
+Before=local-fs.target
+
+[Mount]
+What=smackfs
+Where=/smack
+Type=smackfs
diff --git a/init/smack.service b/init/smack.service
new file mode 100644 (file)
index 0000000..ac4115c
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=Smack
+After=basic.target
+
+[Service]
+ExecStart=/usr/bin/smackctl apply
+ExecStop=/usr/bin/smackctl clear
+RemainAfterExit=yes
index bf9d2f7..246e990 100644 (file)
@@ -197,10 +197,6 @@ static int apply_rules_cb(const char *fpath, const struct stat *sb, int typeflag
        if (fd < 0)
                return -1;
 
-       fd = open(fpath, O_RDONLY);
-       if (fd < 0)
-               return -1;
-
        ret = apply_rules_file(fd, 0) ? FTW_STOP : FTW_CONTINUE;
        close(fd);
        return ret;
index cde6209..366ba9b 100644 (file)
@@ -27,9 +27,7 @@
 
 #define LABEL_LEN 23
 #define SMACKFS_MNT "/smack"
-#define ACCESSES_PATH "/etc/smack/accesses"
 #define ACCESSES_D_PATH "/etc/smack/accesses.d"
-#define CIPSO_PATH "/etc/smack/cipso"
 #define CIPSO_D_PATH "/etc/smack/cipso.d"
 
 int clear(void);
index 485b394..82b6291 100644 (file)
@@ -37,15 +37,9 @@ static int apply_all(void)
        if (clear())
                return -1;
 
-       if (apply_rules(ACCESSES_PATH, 0))
-               perror("apply_rules File");
-
        if (apply_rules(ACCESSES_D_PATH, 0))
                perror("apply_rules Path");
 
-       if (apply_cipso(CIPSO_PATH))
-               perror("apply_cipso File");
-
        if (apply_cipso(CIPSO_D_PATH))
                perror("apply_cipso Path");