/[gentoo-alt]/trunk/prefix/eclass/selinux-policy.eclass
Gentoo

Contents of /trunk/prefix/eclass/selinux-policy.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 2912 byte(s)
Initial eclass import from gentoo-x86
1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/selinux-policy.eclass,v 1.15 2005/07/06 20:23:20 agriffis Exp $
4
5 # Eclass for installing SELinux policy, and optionally
6 # reloading the policy
7
8 inherit eutils
9
10 HOMEPAGE="http://www.gentoo.org/proj/en/hardened/selinux/"
11 SRC_URI="mirror://gentoo/${P}.tar.bz2"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 S="${WORKDIR}/${PN/selinux-}"
16
17 IUSE=""
18
19 RDEPEND=">=sec-policy/selinux-base-policy-20030729"
20
21 [ -z "${POLICYDIR}" ] && POLICYDIR="/etc/security/selinux/src/policy"
22
23 SAVENAME="`date +%Y%m%d%H%M`-${PN}.tar.bz2"
24 SAVEDIR="`echo "${POLICYDIR}" | cut -d/ -f6`"
25
26 selinux-policy_src_compile() {
27 cd ${S}
28
29 einfo "Backup of policy source is \"${SAVENAME}\"."
30 debug-print "POLICYDIR is \"${POLICYDIR}\""
31 debug-print "SAVEDIR is \"${SAVEDIR}\""
32
33 # create a backup of the current policy
34 tar -C /etc/security/selinux/src --exclude policy.12 --exclude tmp \
35 --exclude policy.conf -jcf ${SAVENAME} ${SAVEDIR}/
36 }
37
38 selinux-policy_src_install() {
39 cd ${S}
40
41 insinto /etc/security/selinux/src/policy-backup
42 doins ${SAVENAME}
43
44 if [ -n "${TEFILES}" ]; then
45 debug-print "TEFILES is \"${TEFILES}\""
46 insinto ${POLICYDIR}/domains/program
47 doins ${TEFILES} || die
48 fi
49
50 if [ -n "${TEMISC}" ]; then
51 debug-print "TEMISC is \"${TEMISC}\""
52 insinto ${POLICYDIR}/domains/misc
53 doins ${TEMISC} || die
54 fi
55
56 if [ -n "${FCFILES}" ]; then
57 debug-print "FCFILES is \"${FCFILES}\""
58 insinto ${POLICYDIR}/file_contexts/program
59 doins ${FCFILES} || die
60 fi
61
62 if [ -n "${FCMISC}" ]; then
63 debug-print "FCMISC is \"${FCMISC}\""
64 insinto ${POLICYDIR}/file_contexts/misc
65 doins ${FCMISC} || die
66 fi
67
68 if [ -n "${MACROS}" ]; then
69 debug-print "MACROS is \"${MACROS}\""
70 insinto ${POLICYDIR}/macros/program
71 doins ${MACROS} || die
72 fi
73 }
74
75 selinux-policy_pkg_postinst() {
76 if has "loadpolicy" $FEATURES ; then
77 if [ -x /usr/bin/checkpolicy -a -x /usr/sbin/load_policy -a -x /usr/sbin/setfiles ]; then
78 # only do this if all tools are installed
79
80 ebegin "Automatically loading policy"
81 make -C ${POLICYDIR} load
82 eend $?
83
84 ebegin "Regenerating file contexts"
85 [ -f ${POLICYDIR}/file_contexts/file_contexts ] && \
86 rm -f ${POLICYDIR}/file_contexts/file_contexts
87 make -C ${POLICYDIR} file_contexts/file_contexts &> /dev/null
88
89 # do a test relabel to make sure file
90 # contexts work (doesnt change any labels)
91 echo "/etc/passwd" | /usr/sbin/setfiles \
92 ${POLICYDIR}/file_contexts/file_contexts -sqn
93 eend $?
94 fi
95 else
96 echo
97 echo
98 eerror "Policy has not been loaded. It is strongly suggested"
99 eerror "that the policy be loaded before continuing!!"
100 echo
101 einfo "Automatic policy loading can be enabled by adding"
102 einfo "\"loadpolicy\" to the FEATURES in make.conf."
103 echo
104 echo
105 ebeep 4
106 epause 4
107 fi
108 }
109
110 EXPORT_FUNCTIONS src_compile src_install pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20