Utils: add debian init script and required directories
authorBrian McGillion <brian.mcgillion@intel.com>
Mon, 7 May 2012 08:49:55 +0000 (11:49 +0300)
committerBrian McGillion <brian.mcgillion@intel.com>
Mon, 7 May 2012 08:49:55 +0000 (11:49 +0300)
debian/smack-utils.dirs [new file with mode: 0644]
debian/smack-utils.init [new symlink]
init/smack.rc [new file with mode: 0644]

diff --git a/debian/smack-utils.dirs b/debian/smack-utils.dirs
new file mode 100644 (file)
index 0000000..306968f
--- /dev/null
@@ -0,0 +1,3 @@
+smack
+etc/smack/accesses.d
+etc/smack/cipso.d
\ No newline at end of file
diff --git a/debian/smack-utils.init b/debian/smack-utils.init
new file mode 120000 (symlink)
index 0000000..4b7441d
--- /dev/null
@@ -0,0 +1 @@
+../init/smack.rc
\ No newline at end of file
diff --git a/init/smack.rc b/init/smack.rc
new file mode 100644 (file)
index 0000000..6bc115c
--- /dev/null
@@ -0,0 +1,65 @@
+#! /bin/bash
+#
+# Copyright (c) 2012 Intel Corporation
+#
+#      This program is free software; you can redistribute it and/or modify
+#      it under the terms of the GNU General Public License as published by
+#      the Free Software Foundation, version 2.
+#
+#      This program 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
+#      General Public License for more details.
+#
+#      You should have received a copy of the GNU General Public
+#      License along with this program; 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>
+#
+# description: Initialize Smack policy
+### BEGIN INIT INFO
+# Provides: smack-utils
+# Required-Start: $local_fs
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Set up Smack policy
+# Description: Smack is an LSM that provides Mandatory Access Control.
+### END INIT INFO
+
+#
+# Mount smackfs in /smack
+#
+mount_smack() {
+    if [ ! -d /smack ] ; then
+       rm -f /smack
+       mkdir /smack
+    fi
+    mount -t smackfs smackfs /smack >& /dev/null
+}
+
+case "$1" in
+   start)
+       mount_smack
+       /usr/bin/smackctl apply
+       ;;
+   status)
+       if [ ! -e /smack/load2 ] ; then
+               exit -1
+       fi
+       ;;
+   reload|force-reload|restart|try-restart)
+       /usr/bin/smackctl clear
+       /usr/bin/smackctl apply
+       ;;
+   stop)
+       /usr/bin/smackctl clear
+       ;;
+   *)
+       ;;
+esac
+
+exit 0
\ No newline at end of file