* [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
@ 2018-09-17 6:52 Michał Górny
2018-09-17 16:42 ` Michael Orlitzky
0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2018-09-17 6:52 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
---
bin/ebuild-helpers/fowners | 15 +++++++++++++++
bin/ebuild-helpers/fperms | 15 +++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index 68004210b..70297c6e6 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then
EPREFIX= ED=${D}
fi
+got_owner=
+for arg; do
+ [[ ${arg} == -* ]] && continue
+ if [[ ! ${got_owner} ]]; then
+ got_owner=1
+ continue
+ fi
+ if [[ ${arg} != /* ]]; then
+ eqawarn "Relative path passed to '${0##*/}': ${arg}"
+ eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
+ eqawarn "outside the installation image (\${ED})."
+ fi
+done
+
+
# we can't prefix all arguments because
# chown takes random options
slash="/"
diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
index c63a6abc3..f98560039 100755
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@ -8,6 +8,21 @@ if ! ___eapi_has_prefix_variables; then
ED=${D}
fi
+got_mode=
+for arg; do
+ # - can either be an option or a mode string
+ [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
+ if [[ ! ${got_mode} ]]; then
+ got_mode=1
+ continue
+ fi
+ if [[ ${arg} != /* ]]; then
+ eqawarn "Relative path passed to '${0##*/}': ${arg}"
+ eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
+ eqawarn "outside the installation image (\${ED})."
+ fi
+done
+
# we can't prefix all arguments because
# chmod takes random options
slash="/"
--
2.19.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
2018-09-17 6:52 [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path Michał Górny
@ 2018-09-17 16:42 ` Michael Orlitzky
2018-09-17 17:10 ` Michał Górny
0 siblings, 1 reply; 3+ messages in thread
From: Michael Orlitzky @ 2018-09-17 16:42 UTC (permalink / raw
To: gentoo-portage-dev
On 09/17/2018 02:52 AM, Michał Górny wrote:
>
> --- a/bin/ebuild-helpers/fowners
> +++ b/bin/ebuild-helpers/fowners
> ...
> + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
This one should be 'chown' instead of 'chmod'.
(Calling chown on the live filesystem is often also a dangerous mistake,
but this probably isn't the place to fuss about it.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
2018-09-17 16:42 ` Michael Orlitzky
@ 2018-09-17 17:10 ` Michał Górny
0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2018-09-17 17:10 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On Mon, 2018-09-17 at 12:42 -0400, Michael Orlitzky wrote:
> On 09/17/2018 02:52 AM, Michał Górny wrote:
> >
> > --- a/bin/ebuild-helpers/fowners
> > +++ b/bin/ebuild-helpers/fowners
> > ...
> > + eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
>
> This one should be 'chown' instead of 'chmod'.
Good catch, thanks!
>
> (Calling chown on the live filesystem is often also a dangerous mistake,
> but this probably isn't the place to fuss about it.)
>
I think this is more likely to be triggered on chown-ing stuff inside
${S}.
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 963 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-17 17:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-17 6:52 [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path Michał Górny
2018-09-17 16:42 ` Michael Orlitzky
2018-09-17 17:10 ` Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox