Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 629398 | Differences between
and this patch

Collapse All | Expand All

(-)a/bin/install-qa-check.d/90bad-bin-group-write (-1 / +40 lines)
Line 0 Link Here
0
- 
1
# Copyright 1999-2018 Gentoo Foundation
2
# Distributed under the terms of the GNU General Public License v2
3
4
bad_bin_group_write_check() {
5
	# Warn about globally-installed executables (in /bin, /usr/bin, /sbin,
6
	# or /usr/sbin) that are group-writable by a nonzero GID.
7
8
	# This check doesn't work on non-root prefix installations at
9
	# the moment, because every executable therein is owned by a
10
	# nonzero GID.
11
	[[ "${EUID}" -ne "0" || "${PORTAGE_INST_UID}" -ne "0" ]] && return
12
13
	local d f found=()
14
15
	for d in "${ED%/}/bin" "${ED%/}/usr/bin" "${ED%/}/sbin" "${ED%/}/usr/sbin"; do
16
		test -d "${d}" || continue
17
18
		# Read the results of the "find" command into the "found" bash
19
		# array. Use -L to catch symlinks whose targets are vulnerable,
20
		# even though it won't catch ABSOLUTE symlinks until the package
21
		# is RE-installed (the first time around, the target won't exist).
22
		# We match the GID and not the name "root" here because (for
23
		# example) on FreeBSD, the superuser group is "wheel".
24
		while read -r -d '' f; do
25
			found+=( "${f}" )
26
		done < <(find -L "${d}" -maxdepth 1 -type f -perm /g+w ! -gid 0 -print0)
27
28
		if [[ ${found[@]} ]]; then
29
			eqawarn "system executables group-writable by nonzero gid:"
30
			for f in "${found[@]}"; do
31
				# Strip off the leading destdir before outputting the path,
32
				# but leave the prefix if there is one.
33
				eqawarn "  ${f#${D%/}/}"
34
			done
35
		fi
36
	done
37
}
38
39
bad_bin_group_write_check
40
:

Return to bug 629398