summaryrefslogtreecommitdiff
blob: 19f29ad0298a3aa2db5a10250be638e3450ecc56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-admin/setools/setools-20030609.ebuild,v 1.4 2003/09/26 20:45:47 aliz Exp $

DESCRIPTION="SELinux graphical policy tools"
HOMEPAGE="http://www.tresys.com/selinux_policy_tools.html"
SRC_URI="http://www.tresys.com/Downloads/selinux-tools/${P}.tgz"

LICENSE="GPL-2"
SLOT="0"
S="${WORKDIR}/setools"
KEYWORDS="x86"
IUSE="selinux"

DEPEND="sys-devel/bison
	sys-devel/flex
	dev-lang/tk"

RDEPEND="dev-lang/tk
	>=dev-tcltk/bwidget-1.4.1
	selinux? ( sys-apps/selinux-small )"

src_compile() {
	# fix stupid hard-coded paths
	cd ${S}/libapol
	sed -i -e 's:local/::g' apol_tcl.h
	cd ${S}/apol
	sed -i -e 's:local/selinux/::' head.tcl
	cd ${S}/sepct
	sed -i -e 's:local/::g' top.tcl
	cd ${S}/seuser
	sed -i -e 's:local/selinux/::' seuser_head.tcl
	sed -i -e "s:/etc/security/selinux/src/policy/users:${POLICYDIR}/users:" \
		-e "s:/etc/security/selinux/src/policy$:${POLICYDIR}:" \
		seuser.conf
	cd ${S}

	# fix the Makefile to listen to portage CFLAGS
	sed -i -e 's:-g:$(EXTRA_CFLAGS):' Makefile

	# adjust for tcl/tk versions
	has_version '>=dev-lang/tk-8.4' && \
		TCL_LIBS="-ltk8.4 -ltcl8.4 -lfl -lm" || \
		TCL_LIBS="-ltk8.3 -ltcl8.3 -lfl -lm"

	emake TCL_LIBS="${TCL_LIBS}" EXTRA_CFLAGS="${CFLAGS}" all \
		|| die "compile failed"

	if [ "`use selinux`" ]; then
		# fix up the scripts we're going to install
		cd ${S}/seuser

		sed -i -e 's:local/selinux/::g' seuseradd
		sed -i -e 's:local/selinux/::g' seuserdel
		sed -i -e 's:local/selinux/::g' seusermod

		# fix up the file contexts
		cd ${S}/policy
		sed -i -e 's:local/selinux/::' -e 's:local/::' \
			seuser.fc
	fi
}

src_install() {
	dobin ${S}/apol/apol
	dobin ${S}/awish/awish
	dobin ${S}/sepct/sepcut

	insinto /usr/lib/apol
	doins ${S}/apol/{apol.tcl,apol_help.txt}
	doins ${S}/sepct/sepcut_help.txt

	if [ "`use selinux`" ]; then
		dobin ${S}/seuser/{seuser,seuseradd,seuserdel,seusermod}
		doins ${S}/seuser/{se_user.tcl,seuser_help.txt,seuser.conf}

		insinto ${POLICYDIR}/domains/program
		doins ${S}/policy/seuser.te
		insinto ${POLICYDIR}/file_contexts/program
		doins ${S}/policy/seuser.fc
	fi

	dodoc COPYING ChangeLog-setools README
}

pkg_postinst() {
	if [ "`use selinux`" ]; then
		einfo "A policy for the seuser program has been installed into"
		einfo "${POLICYDIR}.  Please reload your policy at relabel"
		einfo "setools:  rlpkg setools"
	fi
}