public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: /, bin/ebuild-helpers/
@ 2023-04-30 19:31 Ulrich Müller
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Müller @ 2023-04-30 19:31 UTC (permalink / raw
  To: gentoo-commits

commit:     6fc4a7d45798f5ef6605419c684e0ddaa2e812ef
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 28 09:20:02 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Apr 30 07:54:34 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6fc4a7d4

fowners, fperms: Fix handling of relative pathnames

PMS section 12.3.9 specifies that fowners and fperms "[take] paths
relative to the image directory."

Currently, these helpers interpret any pathnames not beginning with a
slash as relative to the current working directory (after printing a
QA warning). This contradicts the spec.

It is also inconsistent with other helpers like insinto or dostrip,
which expand their pathnames relative to ${ED}.

Bug: https://bugs.gentoo.org/905223
Closes: https://github.com/gentoo/portage/pull/1027
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 NEWS                       |  3 +++
 bin/ebuild-helpers/fowners | 26 ++++++++++----------------
 bin/ebuild-helpers/fperms  | 25 ++++++++++---------------
 3 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/NEWS b/NEWS
index 77eaa9d7a..6c06d4e42 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Bug fixes:
+* fowners, fperms: Fix handling of relative pathnames (bug #905223).
+
 portage-3.0.47 (2023-04-30)
 ---------------
 

diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index d245062e7..ca847cd26 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -8,27 +8,21 @@ if ! ___eapi_has_prefix_variables; then
 	EPREFIX= ED=${D}
 fi
 
+args=()
 got_owner=
 for arg; do
-	[[ ${arg} == -* ]] && continue
-
-	if [[ ! ${got_owner} ]]; then
+	if [[ ${arg} == -* ]]; then
+		args+=( "${arg}" )
+	elif [[ ! ${got_owner} ]]; then
+		# the first non-option is the owner and must not be prefixed
 		got_owner=1
-		continue
-	fi
-
-	if [[ ${arg} != /* ]]; then
-		eqawarn "Relative path passed to '${0##*/}': ${arg}"
-		eqawarn "This is unsupported. Please use 'chown' when you need to work on files"
-		eqawarn "outside the installation image (\${ED})."
+		args+=( "${arg}" )
+	else
+		args+=( "${ED%/}/${arg#/}" )
 	fi
 done
 
-
-# we can't prefix all arguments because
-# chown takes random options
-slash="/"
-chown "${@/#${slash}/${ED%/}${slash}}"
+chown "${args[@]}"
 ret=$?
 
 [[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"

diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
index 9e5da5d16..989075eb7 100755
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -8,27 +8,22 @@ if ! ___eapi_has_prefix_variables; then
 	ED=${D}
 fi
 
+args=()
 got_mode=
 for arg; do
 	# - can either be an option or a mode string
-	[[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
-
-	if [[ ! ${got_mode} ]]; then
+	if [[ ${arg} == -* && ${arg} != -[ugorwxXst] ]]; then
+		args+=( "${arg}" )
+	elif [[ ! ${got_mode} ]]; then
+		# the first non-option is the mode and must not be prefixed
 		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})."
+		args+=( "${arg}" )
+	else
+		args+=( "${ED%/}/${arg#/}" )
 	fi
 done
 
-# we can't prefix all arguments because
-# chmod takes random options
-slash="/"
-chmod "${@/#${slash}/${ED%/}${slash}}"
+chmod "${args[@]}"
 ret=$?
 [[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/portage:master commit in: /, bin/ebuild-helpers/
@ 2023-06-06 17:42 Ulrich Müller
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Müller @ 2023-06-06 17:42 UTC (permalink / raw
  To: gentoo-commits

commit:     65bb6ae01f359d82be453bf01a9e8f49171d8436
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  6 04:05:11 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Jun  6 15:50:32 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=65bb6ae0

dosym: Prevent globbing of argument in dosym_canonicalize

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 NEWS                     | 4 ++++
 bin/ebuild-helpers/dosym | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 8727e5623..09dd0675d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Bug fixes:
+* dosym: Prevent globbing of argument in dosym_canonicalize().
+
 portage-3.0.48.1 (2023-06-06)
 ----------------
 
@@ -6,6 +9,7 @@ Bug fixes:
 
 portage-3.0.48 (2023-06-01)
 --------------
+
 Breaking changes:
 * Output deprecation warnings for portageq, prepstrip and prepallstrip
   when they are called from an ebuild (bug #906129, bug #906156).

diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
index e41558a15..9ed27b8ce 100755
--- a/bin/ebuild-helpers/dosym
+++ b/bin/ebuild-helpers/dosym
@@ -1,5 +1,5 @@
 #!/usr/bin/env bash
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
@@ -33,7 +33,7 @@ if [[ ${option_r} ]]; then
 	dosym_canonicalize() {
 		local path slash i prev out IFS=/
 
-		path=( ${1} )
+		read -r -d '' -a path <<< "${1}"
 		[[ ${1} == /* ]] && slash=/
 
 		while true; do
@@ -41,7 +41,7 @@ if [[ ${option_r} ]]; then
 			# or as a special case, "/.." at the beginning of the path.
 			# Also drop empty and "." path components as we go along.
 			prev=
-			for i in ${!path[@]}; do
+			for i in "${!path[@]}"; do
 				if [[ -z ${path[i]} || ${path[i]} == . ]]; then
 					unset "path[i]"
 				elif [[ ${path[i]} != .. ]]; then


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-06 17:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-30 19:31 [gentoo-commits] proj/portage:master commit in: /, bin/ebuild-helpers/ Ulrich Müller
  -- strict thread matches above, loose matches on Subject: below --
2023-06-06 17:42 Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox