summaryrefslogtreecommitdiff
blob: cc7fe49628b574bee9d7c9c548f0617aca706657 (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
93
94
95
96
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/gradm2/gradm2-0.0_pre4-r1.ebuild,v 1.3 2003/07/07 05:24:48 solar Exp $

MY_PV=2.0-pre4

MAINTAINER="solar@gentoo.org"
DESCRIPTION="Administrative interface for grsecuritys2 access control lists"
SRC_URI="http://www.grsecurity.net/gradm-${MY_PV}.tar.gz"
HOMEPAGE="http://www.grsecurity.net/"
LICENSE="GPL-2"
KEYWORDS="x86 amd64 ~sparc"
SLOT="0"

IUSE=""
DEPEND="virtual/glibc
	sys-devel/bison
	sys-devel/flex
	sys-apps/chpax"

S="${WORKDIR}/${PN}"

src_unpack() {
	unpack ${A} || die "Cant unpack ${A}"
	cd ${S}
	mv Makefile{,.orig}
	ebegin "Patching Makefile to use gentoo CFLAGS"
	sed -e "s|-O2|${CFLAGS}|" Makefile.orig > Makefile
	eend $?
	ebegin "Patching manpage"
	sed -e "s:gradm:gradm2:" -e "s:GRADM:GRADM2:" < gradm.8 > gradm2.8
	eend $?
	for f in Makefile acl gradm_defs.h grlearn.c; do
		[ -f ${f} ] && {
			ebegin "Patching ${f} to use /etc/grsec2"
			sed -e "s:/etc/grsec:/etc/grsec2:" \
			< ${f} > ${f}~ && cp ${f}~ ${f}
			eend $?
		}
	done
	# rm *~
}

src_compile() {
	cd ${S}
	emake CC="${CC}" || die "compile problem"
}

src_install() {
	cd ${S}
	# Were not ready for init.d,script functions yet.
		#exeinto /etc/init.d
		#newexe ${FILESDIR}/grsecurity2.rc grsecurity2
		#insinto /etc/conf.d
		#doins ${FILESDIR}/grsecurity2

	mkdir -p -m 755 ${D}/dev/
	mknod -m 0622 ${D}/dev/grsec c 1 10 || die "Cant mknod for grsec learning device"
	mkdir -p -m 700 ${D}/etc/grsec2
	doman gradm2.8
	dodoc acl

	into /
	mv gradm{,2}
	dosbin grlearn
	dosbin gradm2

	# Normal users can authenticate to special roles now and thus 
	# need execution permission on gradm2. We remove group,other readable bits 
	# to help ensure that our gradm2 binary is as protected from misbehaving users.
	fperms 711 ${D}/sbin/gradm2
}

pkg_setup() {
	if [ -e /usr/src/linux/grsecurity ]; then
		if [ ! -e /usr/src/linux/grsecurity/gracl_learn.c ]; then
			ewarn "gradm2 was designed to be used with grsecurity2 but it looks like your using grsecurity1"
			ewarn "we hope you know what your doing"
			einfo "(hint try emerge sys-apps/gradm) If you need support for grsecurity 1.x"
			echo
		fi
	else
		ewarn "Your going to need to a grsecurity2 enabled kernel to take advantage of the tool"
	fi
}

pkg_postinst() {
	[ ! -d /proc/sys/kernel/grsecurity ] && ewarn "This kernel does not seem to be a grsec enabled kernel (or we are in chroot install?)"
	if [ ! -f /usr/src/linux/grsecurity/gracl_learn.c ]; then
		ewarn "It does not seem that your are running a grsec2 enabled kernel"
		einfo "(hint >=hardened-sources-2.4.20-r3) was the first kernel to include support"
	else
		einfo "Everything looks good and you seem to be using a grsec2 enabled kernel"
	fi
	einfo "Bugs can be reported to <${MAINTAINER}> using http://bugs.gentoo.org"
}