1 |
W dniu nie, 29.07.2018 o godzinie 13∶37 -0400, użytkownik Michael |
2 |
Orlitzky napisał: |
3 |
> System executables that are not owned by root pose a security |
4 |
> risk. The owner of the executable is free to modify it at any time; |
5 |
> so, for example, he can change a daemon's behavior to make it |
6 |
> malicious before the next time the service is started (usually by |
7 |
> root). |
8 |
> |
9 |
> On a "normal" system, there is no good reason why the superuser should |
10 |
> not own every system executable. This commit adds a new install-time |
11 |
> check that reports any such binaries with a QA warning. To avoid false |
12 |
> positives, non-"normal" systems (like prefix) are skipped at the moment. |
13 |
> |
14 |
> Bug: https://bugs.gentoo.org/629398 |
15 |
> --- |
16 |
> bin/install-qa-check.d/90bad-bin-owner | 38 ++++++++++++++++++++++++++++++++++ |
17 |
> 1 file changed, 38 insertions(+) |
18 |
> create mode 100644 bin/install-qa-check.d/90bad-bin-owner |
19 |
> |
20 |
> diff --git a/bin/install-qa-check.d/90bad-bin-owner b/bin/install-qa-check.d/90bad-bin-owner |
21 |
> new file mode 100644 |
22 |
> index 000000000..188d67a51 |
23 |
> --- /dev/null |
24 |
> +++ b/bin/install-qa-check.d/90bad-bin-owner |
25 |
> @@ -0,0 +1,38 @@ |
26 |
> +# Copyright 1999-2018 Gentoo Foundation |
27 |
> +# Distributed under the terms of the GNU General Public License v2 |
28 |
> + |
29 |
> +bad_bin_owner_check() { |
30 |
> + # Warn about globally-installed executables (in /bin, /usr/bin, /sbin, |
31 |
> + # or /usr/sbin) that are owned by a nonzero UID. |
32 |
> + |
33 |
> + # This check doesn't work on non-root prefix installations at |
34 |
> + # the moment, because every executable therein is owned by a |
35 |
> + # nonzero UID. |
36 |
> + [[ "${EUID}" -ne "0" || "${PORTAGE_INST_UID}" -ne "0" ]] && return |
37 |
> + |
38 |
> + local d f found=() |
39 |
> + |
40 |
> + for d in "${ED%/}/bin" "${ED%/}/usr/bin" "${ED%/}/sbin" "${ED%/}/usr/sbin"; do |
41 |
|
42 |
I think you should include /opt/bin as well. Or maybe simply all |
43 |
locations on ${PATH}. |
44 |
|
45 |
> + [[ -d "${d}" ]] || continue |
46 |
> + |
47 |
> + # Read the results of the "find" command into the "found" bash array. |
48 |
> + # Use -L to catch symlinks whose targets are owned by a non-root user, |
49 |
> + # even though it won't catch ABSOLUTE symlinks until the package |
50 |
> + # is RE-installed (the first time around, the target won't exist). |
51 |
> + while read -r -d '' f; do |
52 |
> + found+=( "${f}" ) |
53 |
> + done < <(find -L "${d}" -maxdepth 1 -type f ! -uid 0 -print0) |
54 |
> + |
55 |
> + if [[ ${found[@]} ]]; then |
56 |
> + eqawarn "system executables owned by nonzero uid:" |
57 |
> + for f in "${found[@]}"; do |
58 |
> + # Strip off the leading destdir before outputting the path, |
59 |
> + # but leave the prefix if there is one. |
60 |
> + eqawarn " ${f#${D%/}/}" |
61 |
> + done |
62 |
> + fi |
63 |
> + done |
64 |
> +} |
65 |
> + |
66 |
> +bad_bin_owner_check |
67 |
> +: |
68 |
|
69 |
-- |
70 |
Best regards, |
71 |
Michał Górny |