From 75fa25f9133e2319505fa4da8d3a6e2024a1b952 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Mon, 7 May 2012 11:49:55 +0300 Subject: [PATCH] Utils: add debian init script and required directories --- debian/smack-utils.dirs | 3 +++ debian/smack-utils.init | 1 + init/smack.rc | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 debian/smack-utils.dirs create mode 120000 debian/smack-utils.init create mode 100644 init/smack.rc diff --git a/debian/smack-utils.dirs b/debian/smack-utils.dirs new file mode 100644 index 0000000..306968f --- /dev/null +++ b/debian/smack-utils.dirs @@ -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 index 0000000..4b7441d --- /dev/null +++ b/debian/smack-utils.init @@ -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 index 0000000..6bc115c --- /dev/null +++ b/init/smack.rc @@ -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 +# +# 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 -- 2.7.4