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_SOURCEDIR="${WORKDIR}/refpolicy"
17 SRC_URI="http://oss.tresys.com/files/refpolicy/refpolicy-${PV}.tar.bz2
18 https://dev.gentoo.org/~swift/patches/selinux-base-policy/patchbundle-selinux-base-policy-${PVR}.tar.bz2"
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}" \
56 # Fix bug 257111 - Correct the initial sid for cron-started jobs in the
58 sed -i -e 's:system_crond_t:system_cronjob_t:g' \
59 "${S}/refpolicy/config/appconfig-standard/default_contexts"
60 sed -i -e 's|system_r:cronjob_t|system_r:system_cronjob_t|g' \
61 "${S}/refpolicy/config/appconfig-mls/default_contexts"
62 sed -i -e 's|system_r:cronjob_t|system_r:system_cronjob_t|g' \
63 "${S}/refpolicy/config/appconfig-mcs/default_contexts"
69 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
71 # Update the SELinux refpolicy capabilities based on the users' USE flags.
73 if ! use peer_perms; then
74 sed -i -e '/network_peer_controls/d' \
75 "${S}/refpolicy/policy/policy_capabilities"
78 if ! use open_perms; then
79 sed -i -e '/open_perms/d' \
80 "${S}/refpolicy/policy/policy_capabilities"
84 sed -i -e '/^UBAC/s/y/n/' "${S}/refpolicy/build.conf" \
85 || die "Failed to disable User Based Access Control"
88 echo "DISTRO = gentoo" >> "${S}/refpolicy/build.conf"
90 # Prepare initial configuration
92 make conf || die "Make conf failed"
94 # Setup the policies based on the types delivered by the end user.
95 # These types can be "targeted", "strict", "mcs" and "mls".
96 for i in ${POLICY_TYPES}; do
97 cp -a "${S}/refpolicy" "${S}/${i}"
100 #cp "${FILESDIR}/modules-2.20120215.conf" "${S}/${i}/policy/modules.conf"
101 sed -i -e "/= module/d" "${S}/${i}/policy/modules.conf"
103 sed -i -e '/^QUIET/s/n/y/' -e "/^NAME/s/refpolicy/$i/" \
104 "${S}/${i}/build.conf" || die "build.conf setup failed."
106 if [[ "${i}" == "mls" ]] || [[ "${i}" == "mcs" ]];
108 # MCS/MLS require additional settings
109 sed -i -e "/^TYPE/s/standard/${i}/" "${S}/${i}/build.conf" \
110 || die "failed to set type to mls"
113 if [ "${i}" == "targeted" ]; then
114 sed -i -e '/root/d' -e 's/user_u/unconfined_u/' \
115 "${S}/${i}/config/appconfig-standard/seusers" \
116 || die "targeted seusers setup failed."
119 if [ "${i}" != "targeted" ] && [ "${i}" != "strict" ] && use unconfined; then
120 sed -i -e '/root/d' -e 's/user_u/unconfined_u/' \
121 "${S}/${i}/config/appconfig-${i}/seusers" \
122 || die "policy seusers setup failed."
128 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
130 for i in ${POLICY_TYPES}; do
132 make base || die "${i} compile failed"
140 [ -z "${POLICY_TYPES}" ] && local POLICY_TYPES="targeted strict mls mcs"
142 for i in ${POLICY_TYPES}; do
145 make DESTDIR="${D}" install \
146 || die "${i} install failed."
148 make DESTDIR="${D}" install-headers \
149 || die "${i} headers install failed."
151 echo "run_init_t" > "${D}/etc/selinux/${i}/contexts/run_init_type"
153 echo "textrel_shlib_t" >> "${D}/etc/selinux/${i}/contexts/customizable_types"
155 # libsemanage won't make this on its own
156 keepdir "/etc/selinux/${i}/policy"
162 insinto /usr/share/selinux/devel;
163 doins doc/policy.xml;
167 dodoc doc/Makefile.example doc/example.{te,fc,if}
172 doins "${FILESDIR}/config"
176 has_version "<${CATEGORY}/${PN}-2.20101213-r13"
177 previous_less_than_r13=$?