summaryrefslogtreecommitdiff
blob: 64ae0f6ef45bb5f3dde5d0a6b003cd2660a7702e (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit user

DESCRIPTION="An ethernet monitor program that keeps track of ethernet/IP address pairings"
HOMEPAGE="https://ee.lbl.gov/"
LICENSE="BSD GPL-2"
SLOT="0"

ETHERCODES_DATE=20200628
SRC_URI="
	https://ee.lbl.gov/downloads/${PN}/${P}.tar.gz
	https://dev.gentoo.org/~jer/ethercodes.dat-${ETHERCODES_DATE}.xz
"

KEYWORDS="~amd64 ~hppa ~ppc ~sparc ~x86"
IUSE="selinux"

DEPEND="
	net-libs/libpcap
	sys-libs/ncurses:*
"
RDEPEND="
	${DEPEND}
	selinux? ( sec-policy/selinux-arpwatch )
	virtual/mta
"

pkg_setup() {
	# We need to create /var/lib/arpwatch with this group, so it must
	# exist during src_install.
	enewgroup arpwatch
}

pkg_postinst() {
	# The user, however, is not needed until runtime.
	enewuser arpwatch -1 -1 -1 arpwatch
}

src_configure() {
	econf \
		ac_cv_path_V_SENDMAIL=sendmail
}

src_install() {
	dosbin arp2ethers arpfetch arpsnmp arpwatch bihourly.sh massagevendor.py update-ethercodes.sh
	doman arpsnmp.8 arpwatch.8

	insinto /usr/share/arpwatch
	newins "${WORKDIR}"/ethercodes.dat-${ETHERCODES_DATE} ethercodes.dat

	insinto /usr/share/arpwatch/awk
	doins d.awk duplicates.awk e.awk euppertolower.awk p.awk

	diropts --group=arpwatch --mode=770
	keepdir /var/lib/arpwatch
	dodoc README CHANGES

	newconfd "${FILESDIR}"/arpwatch.confd-r2 arpwatch
	newinitd "${FILESDIR}"/arpwatch.initd-r2 arpwatch
}

pkg_postinst() {
	# Previous revisions installed /var/lib/arpwatch with the wrong
	# ownership. Instead of the intended arpwatch:root, it was left as
	# root:root. If we find any such mis-owned directories, we fix them,
	# and then set the permission bits how we want them in *this*
	# revision.
	#
	# The "--from" flag ensures that we only fix directories that need
	# fixing, and the "&& chmod" ensures that we only adjust the
	# permissions if the owner also needed fixing.
	chown \
		--from=root:root \
		--no-dereference \
		:arpwatch \
		"${ROOT}"/var/lib/arpwatch && \
		chmod 770 "${ROOT}"/var/lib/arpwatch
}