summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorChris PeBenito <pebenito@gentoo.org>2006-10-09 23:48:24 +0000
committerChris PeBenito <pebenito@gentoo.org>2006-10-09 23:48:24 +0000
commit8f85c014dbc45ed8e571ed24af07297e80bff275 (patch)
tree0b6d1c16520a4500fb9e06f25a9d2a164f368942 /eclass
parentFirst mainstream reference policy testing release. (diff)
downloadhistorical-8f85c014dbc45ed8e571ed24af07297e80bff275.tar.gz
historical-8f85c014dbc45ed8e571ed24af07297e80bff275.tar.bz2
historical-8f85c014dbc45ed8e571ed24af07297e80bff275.zip
selinux reference policy eclass initial commit
Diffstat (limited to 'eclass')
-rw-r--r--eclass/selinux-policy-2.eclass92
1 files changed, 92 insertions, 0 deletions
diff --git a/eclass/selinux-policy-2.eclass b/eclass/selinux-policy-2.eclass
new file mode 100644
index 000000000000..6253b28b45e2
--- /dev/null
+++ b/eclass/selinux-policy-2.eclass
@@ -0,0 +1,92 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/selinux-policy-2.eclass,v 1.1 2006/10/09 23:48:24 pebenito Exp $
+
+# Eclass for installing SELinux policy, and optionally
+# reloading the reference-policy based modules
+
+inherit eutils
+
+IUSE=""
+
+HOMEPAGE="http://www.gentoo.org/proj/en/hardened/selinux/"
+SRC_URI="http://oss.tresys.com/files/refpolicy/refpolicy-${PV}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+S="${WORKDIR}/"
+
+RDEPEND=">=sys-apps/policycoreutils-1.30.30
+ >=sec-policy/selinux-base-policy-${PV}"
+
+DEPEND="${RDEPEND}
+ sys-devel/m4
+ >=sys-apps/checkpolicy-1.30.12"
+
+selinux-policy-2_src_unpack() {
+ unpack ${A}
+
+ local modfiles
+
+ for i in ${MODS}; do
+ modfiles="`find ${S}/refpolicy/policy/modules -iname $i.te` $modfiles"
+ modfiles="`find ${S}/refpolicy/policy/modules -iname $i.fc` $modfiles"
+ # use .if from headers
+ done
+
+ for i in ${POLICY_TYPES}; do
+ mkdir ${S}/${i}
+ cp ${S}/refpolicy/doc/Makefile.example ${S}/${i}/Makefile
+
+ cp ${modfiles} ${S}/${i}
+ done
+}
+
+selinux-policy-2_src_compile() {
+ for i in ${POLICY_TYPES}; do
+ make NAME=$i -C ${S}/${i} || die "${i} compile failed"
+ done
+}
+
+selinux-policy-2_src_install() {
+ BASEDIR="/usr/share/selinux"
+
+ for i in ${POLICY_TYPES}; do
+ for j in ${MODS}; do
+ echo "Installing ${i} ${j} policy package"
+ insinto ${BASEDIR}/${i}
+ doins ${S}/${i}/${j}.pp
+ done
+ done
+}
+
+selinux-policy-2_pkg_postinst() {
+ # build up the command in the case of multiple modules
+ local COMMAND
+ for i in ${MODS}; do
+ COMMAND="-i ${i}.pp ${COMMAND}"
+ done
+
+ if has "loadpolicy" $FEATURES ; then
+ for i in ${POLICY_TYPES}; do
+ einfo "Inserting the following modules into the $i module store: ${MODS}"
+
+ cd /usr/share/selinux/${i}
+ semodule -s ${i} ${COMMAND}
+ done
+ else
+ echo
+ echo
+ eerror "Policy has not been loaded. It is strongly suggested"
+ eerror "that the policy be loaded before continuing!!"
+ echo
+ einfo "Automatic policy loading can be enabled by adding"
+ einfo "\"loadpolicy\" to the FEATURES in make.conf."
+ echo
+ echo
+ ebeep 4
+ epause 4
+ fi
+}
+
+EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst