public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path
Date: Mon, 17 Sep 2018 08:52:33 +0200	[thread overview]
Message-ID: <20180917065233.14030-1-mgorny@gentoo.org> (raw)

---
 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



             reply	other threads:[~2018-09-17  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17  6:52 Michał Górny [this message]
2018-09-17 16:42 ` [gentoo-portage-dev] [PATCH] f{owners,perms}: Warn when using relative path Michael Orlitzky
2018-09-17 17:10   ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180917065233.14030-1-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox