Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
Date: Mon, 17 Sep 2018 06:52:44
Message-Id: 20180917065233.14030-1-mgorny@gentoo.org
1 ---
2 bin/ebuild-helpers/fowners | 15 +++++++++++++++
3 bin/ebuild-helpers/fperms | 15 +++++++++++++++
4 2 files changed, 30 insertions(+)
5
6 diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
7 index 68004210b..70297c6e6 100755
8 --- a/bin/ebuild-helpers/fowners
9 +++ b/bin/ebuild-helpers/fowners
10 @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then
11 EPREFIX= ED=${D}
12 fi
13
14 +got_owner=
15 +for arg; do
16 + [[ ${arg} == -* ]] && continue
17 + if [[ ! ${got_owner} ]]; then
18 + got_owner=1
19 + continue
20 + fi
21 + if [[ ${arg} != /* ]]; then
22 + eqawarn "Relative path passed to '${0##*/}': ${arg}"
23 + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
24 + eqawarn "outside the installation image (\${ED})."
25 + fi
26 +done
27 +
28 +
29 # we can't prefix all arguments because
30 # chown takes random options
31 slash="/"
32 diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
33 index c63a6abc3..f98560039 100755
34 --- a/bin/ebuild-helpers/fperms
35 +++ b/bin/ebuild-helpers/fperms
36 @@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then
37 ED=${D}
38 fi
39
40 +got_mode=
41 +for arg; do
42 + # - can either be an option or a mode string
43 + [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
44 + if [[ ! ${got_mode} ]]; then
45 + got_mode=1
46 + continue
47 + fi
48 + if [[ ${arg} != /* ]]; then
49 + eqawarn "Relative path passed to '${0##*/}': ${arg}"
50 + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
51 + eqawarn "outside the installation image (\${ED})."
52 + fi
53 +done
54 +
55 # we can't prefix all arguments because
56 # chmod takes random options
57 slash="/"
58 --
59 2.19.0

Replies