1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
8 if [[ ${PV} == 9999* ]]; then
9 EGIT_REPO_URI="${SELINUX_GIT_REPO:-git://anongit.gentoo.org/proj/hardened-refpolicy.git https://anongit.gentoo.org/git/proj/hardened-refpolicy.git}"
10 EGIT_BRANCH="${SELINUX_GIT_BRANCH:-master}"
11 EGIT_CHECKOUT_DIR="${WORKDIR}/refpolicy"
17 SRC_URI="https://raw.githubusercontent.com/wiki/TresysTechnology/refpolicy/files/refpolicy-${PV}.tar.bz2
18 https://dev.gentoo.org/~swift/patches/selinux-base-policy/patchbundle-selinux-base-policy-${PVR}.tar.bz2"
20 KEYWORDS="~amd64 ~x86"
23 IUSE="+peer_perms +open_perms +ubac +unconfined doc"
25 DESCRIPTION="Gentoo base policy for SELinux"
26 HOMEPAGE="https://www.gentoo.org/proj/en/hardened/selinux/"
30 RDEPEND=">=sys-apps/policycoreutils-2.3
32 !<=sec-policy/selinux-base-policy-2.20120725"
35 >=sys-apps/checkpolicy-2.3"
44 if [[ ${PV} != 9999* ]]; then
45 # Apply the gentoo patches to the policy. These patches are only necessary
46 # for base policies, or for interface changes on modules.
47 EPATCH_MULTI_MSG="Applying SELinux policy updates ... " \
48 EPATCH_SUFFIX="patch" \
49 EPATCH_SOURCE="${WORKDIR}" \
61 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
63 # Update the SELinux refpolicy capabilities based on the users' USE flags.
65 if ! use peer_perms; then
66 sed -i -e '/network_peer_controls/d' \
67 "${S}/refpolicy/policy/policy_capabilities"
70 if ! use open_perms; then
71 sed -i -e '/open_perms/d' \
72 "${S}/refpolicy/policy/policy_capabilities"
76 sed -i -e '/^UBAC/s/y/n/' "${S}/refpolicy/build.conf" \
77 || die "Failed to disable User Based Access Control"
80 echo "DISTRO = gentoo" >> "${S}/refpolicy/build.conf"
82 # Prepare initial configuration
84 make conf || die "Make conf failed"
86 # Setup the policies based on the types delivered by the end user.
87 # These types can be "targeted", "strict", "mcs" and "mls".
88 for i in ${POLICY_TYPES}; do
89 cp -a "${S}/refpolicy" "${S}/${i}"
92 #cp "${FILESDIR}/modules-2.20120215.conf" "${S}/${i}/policy/modules.conf"
93 sed -i -e "/= module/d" "${S}/${i}/policy/modules.conf"
95 sed -i -e '/^QUIET/s/n/y/' -e "/^NAME/s/refpolicy/$i/" \
96 "${S}/${i}/build.conf" || die "build.conf setup failed."
98 if [[ "${i}" == "mls" ]] || [[ "${i}" == "mcs" ]];
100 # MCS/MLS require additional settings
101 sed -i -e "/^TYPE/s/standard/${i}/" "${S}/${i}/build.conf" \
102 || die "failed to set type to mls"
105 if [ "${i}" == "targeted" ]; then
106 sed -i -e '/root/d' -e 's/user_u/unconfined_u/' \
107 "${S}/${i}/config/appconfig-standard/seusers" \
108 || die "targeted seusers setup failed."
111 if [ "${i}" != "targeted" ] && [ "${i}" != "strict" ] && use unconfined; then
112 sed -i -e '/root/d' -e 's/user_u/unconfined_u/' \
113 "${S}/${i}/config/appconfig-${i}/seusers" \
114 || die "policy seusers setup failed."
120 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
122 for i in ${POLICY_TYPES}; do
124 emake base || die "${i} compile failed"
132 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
134 for i in ${POLICY_TYPES}; do
137 make DESTDIR="${D}" install \
138 || die "${i} install failed."
140 make DESTDIR="${D}" install-headers \
141 || die "${i} headers install failed."
143 echo "run_init_t" > "${D}/etc/selinux/${i}/contexts/run_init_type"
145 echo "textrel_shlib_t" >> "${D}/etc/selinux/${i}/contexts/customizable_types"
147 # libsemanage won't make this on its own
148 keepdir "/etc/selinux/${i}/policy"
154 insinto /usr/share/selinux/devel;
155 doins doc/policy.xml;
159 dodoc doc/Makefile.example doc/example.{te,fc,if}
164 doins "${FILESDIR}/config"
168 has_version "<${CATEGORY}/${PN}-2.20101213-r13"
169 previous_less_than_r13=$?