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

EAPI=7

inherit flag-o-matic toolchain-funcs

DESCRIPTION="Add and remove SCSI devices from your Linux system during runtime"
HOMEPAGE="https://llg.cubic.org/tools/"
SRC_URI="https://llg.cubic.org/tools/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="suid"

RDEPEND="suid? ( acct-group/scsi )"
BDEPEND="${RDEPEND}"

src_prepare() {
	default

	# Remove 'strip' command, as portage handles this
	sed -e "s:^\(.*strip.*\):#\1:g" -i Makefile.in || die

	# Convert docs to UTF-8
	if [ -x "$(type -p iconv)" ]; then
		for X in NEWS README; do
			iconv -f LATIN1 -t UTF8 -o "${X}~" "${X}" \
				&& mv -f "${X}~" "${X}" \
				|| rm -f "${X}~" || die
		done
	fi
}

src_compile() {
	# Extra safety for suid
	append-ldflags -Wl,-z,now

	# Use system compiler
	tc-export CC

	default
}

src_install() {
	dosbin scsiadd

	if use suid; then
		fowners root:scsi /usr/sbin/scsiadd
		fperms 4710 /usr/sbin/scsiadd
	fi

	doman scsiadd.8

	einstalldocs
}

pkg_postinst() {
	if use suid; then
		ewarn "You have chosen to install ${PN} with the binary setuid root. This"
		ewarn "means that if there any undetected vulnerabilities in the binary,"
		ewarn "then local users may be able to gain root access on your machine."
	fi
}