| 1 |
# Copyright 1999-2011 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sec-policy/selinux-base-policy/selinux-base-policy-2.20101213-r12.ebuild,v 1.1 2011/04/16 13:02:44 blueness Exp $
|
| 4 |
|
| 5 |
EAPI="1"
|
| 6 |
IUSE="+peer_perms open_perms"
|
| 7 |
|
| 8 |
inherit eutils
|
| 9 |
|
| 10 |
PATCHBUNDLE="${FILESDIR}/patchbundle-${PF}.tar.bz2"
|
| 11 |
DESCRIPTION="Gentoo base policy for SELinux"
|
| 12 |
HOMEPAGE="http://www.gentoo.org/proj/en/hardened/selinux/"
|
| 13 |
SRC_URI="http://oss.tresys.com/files/refpolicy/refpolicy-${PV}.tar.bz2"
|
| 14 |
LICENSE="GPL-2"
|
| 15 |
SLOT="0"
|
| 16 |
|
| 17 |
KEYWORDS="~amd64 ~x86"
|
| 18 |
|
| 19 |
RDEPEND=">=sys-apps/policycoreutils-1.30.30
|
| 20 |
>=sys-fs/udev-151"
|
| 21 |
DEPEND="${RDEPEND}
|
| 22 |
sys-devel/m4
|
| 23 |
>=sys-apps/checkpolicy-1.30.12"
|
| 24 |
|
| 25 |
S=${WORKDIR}/
|
| 26 |
|
| 27 |
src_unpack() {
|
| 28 |
[ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
|
| 29 |
MOD_CONF_VER="20090730"
|
| 30 |
|
| 31 |
unpack ${A}
|
| 32 |
|
| 33 |
cd "${S}"
|
| 34 |
epatch "${PATCHBUNDLE}"
|
| 35 |
cd "${S}/refpolicy"
|
| 36 |
# Fix bug 257111
|
| 37 |
sed -i -e 's:system_crond_t:system_cronjob_t:g' \
|
| 38 |
"${S}/refpolicy/config/appconfig-standard/default_contexts"
|
| 39 |
|
| 40 |
if ! use peer_perms; then
|
| 41 |
sed -i -e '/network_peer_controls/d' \
|
| 42 |
"${S}/refpolicy/policy/policy_capabilities"
|
| 43 |
fi
|
| 44 |
|
| 45 |
if ! use open_perms; then
|
| 46 |
sed -i -e '/open_perms/d' \
|
| 47 |
"${S}/refpolicy/policy/policy_capabilities"
|
| 48 |
fi
|
| 49 |
|
| 50 |
for i in ${POLICY_TYPES}; do
|
| 51 |
cp -a "${S}/refpolicy" "${S}/${i}"
|
| 52 |
|
| 53 |
cd "${S}/${i}";
|
| 54 |
make conf || die "${i} reconfiguration failed"
|
| 55 |
|
| 56 |
cp "${FILESDIR}/modules.conf.${i}.${MOD_CONF_VER}" \
|
| 57 |
"${S}/${i}/policy/modules.conf" \
|
| 58 |
|| die "failed to set up modules.conf"
|
| 59 |
sed -i -e '/^QUIET/s/n/y/' -e '/^MONOLITHIC/s/y/n/' \
|
| 60 |
-e "/^NAME/s/refpolicy/$i/" "${S}/${i}/build.conf" \
|
| 61 |
|| die "build.conf setup failed."
|
| 62 |
|
| 63 |
echo "DISTRO = gentoo" >> "${S}/${i}/build.conf"
|
| 64 |
|
| 65 |
if [ "${i}" == "targeted" ]; then
|
| 66 |
sed -i -e '/root/d' -e 's/user_u/unconfined_u/' \
|
| 67 |
"${S}/${i}/config/appconfig-standard/seusers" \
|
| 68 |
|| die "targeted seusers setup failed."
|
| 69 |
fi
|
| 70 |
done
|
| 71 |
}
|
| 72 |
|
| 73 |
src_compile() {
|
| 74 |
[ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
|
| 75 |
|
| 76 |
for i in ${POLICY_TYPES}; do
|
| 77 |
cd "${S}/${i}"
|
| 78 |
make base || die "${i} compile failed"
|
| 79 |
done
|
| 80 |
}
|
| 81 |
|
| 82 |
src_install() {
|
| 83 |
[ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
|
| 84 |
|
| 85 |
for i in ${POLICY_TYPES}; do
|
| 86 |
cd "${S}/${i}"
|
| 87 |
|
| 88 |
make DESTDIR="${D}" install \
|
| 89 |
|| die "${i} install failed."
|
| 90 |
|
| 91 |
make DESTDIR="${D}" install-headers \
|
| 92 |
|| die "${i} headers install failed."
|
| 93 |
|
| 94 |
echo "run_init_t" > "${D}/etc/selinux/${i}/contexts/run_init_type"
|
| 95 |
|
| 96 |
echo "textrel_shlib_t" >> "${D}/etc/selinux/${i}/contexts/customizable_types"
|
| 97 |
|
| 98 |
# libsemanage won't make this on its own
|
| 99 |
keepdir "/etc/selinux/${i}/policy"
|
| 100 |
done
|
| 101 |
|
| 102 |
dodoc doc/Makefile.example doc/example.{te,fc,if}
|
| 103 |
|
| 104 |
insinto /etc/selinux
|
| 105 |
doins "${FILESDIR}/config"
|
| 106 |
}
|
| 107 |
|
| 108 |
pkg_postinst() {
|
| 109 |
[ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="strict targeted"
|
| 110 |
|
| 111 |
for i in ${POLICY_TYPES}; do
|
| 112 |
einfo "Inserting base module into ${i} module store."
|
| 113 |
|
| 114 |
cd "/usr/share/selinux/${i}"
|
| 115 |
semodule -s "${i}" -b base.pp
|
| 116 |
done
|
| 117 |
}
|