From 1f2af127a3fb97237b4d1a25c8640f2460f435d3 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Mon, 6 Feb 2012 17:40:31 +0200 Subject: [PATCH] Add init scripts --- Makefile.am | 2 +- configure.ac | 2 +- init/Makefile.am | 2 ++ init/smack.mount | 8 ++++++++ init/smack.service | 8 ++++++++ utils/common.c | 4 ---- utils/common.h | 2 -- utils/smackctl.c | 6 ------ 8 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 init/Makefile.am create mode 100644 init/smack.mount create mode 100644 init/smack.service diff --git a/Makefile.am b/Makefile.am index 41fefd8..4f90bc5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} AM_MAKEFLAGS = --no-print-directory -SUBDIRS = libsmack utils doc +SUBDIRS = libsmack utils doc init diff --git a/configure.ac b/configure.ac index 9d87b27..6e4d7a1 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 0000000..8fad8e5 --- /dev/null +++ b/init/Makefile.am @@ -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 index 0000000..312e077 --- /dev/null +++ b/init/smack.mount @@ -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 index 0000000..ac4115c --- /dev/null +++ b/init/smack.service @@ -0,0 +1,8 @@ +[Unit] +Description=Smack +After=basic.target + +[Service] +ExecStart=/usr/bin/smackctl apply +ExecStop=/usr/bin/smackctl clear +RemainAfterExit=yes diff --git a/utils/common.c b/utils/common.c index bf9d2f7..246e990 100644 --- a/utils/common.c +++ b/utils/common.c @@ -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; diff --git a/utils/common.h b/utils/common.h index cde6209..366ba9b 100644 --- a/utils/common.h +++ b/utils/common.h @@ -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); diff --git a/utils/smackctl.c b/utils/smackctl.c index 485b394..82b6291 100644 --- a/utils/smackctl.c +++ b/utils/smackctl.c @@ -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"); -- 2.7.4