1 |
On 10/11/2014 12:17 AM, Micha³ Górny wrote: |
2 |
> Dnia 2014-10-10, o godz. 21:50:53 |
3 |
> Zac Medico <zmedico@g.o> napisa³(a): |
4 |
>> + |
5 |
>> +IFS=':' |
6 |
>> + |
7 |
>> +for path in ${PATH}; do |
8 |
> |
9 |
> This will trigger unwanted filename expansion. For example, |
10 |
> |
11 |
> PATH='/*/bin' |
12 |
> |
13 |
> will trigger '/usr/bin' rather than '/*/bin' :P. |
14 |
|
15 |
Good catch, thanks. This version uses 'set -f' to fix that: |
16 |
|
17 |
From d16a4eb704fd91a60341daef7b31dcede7f17bf5 Mon Sep 17 00:00:00 2001 |
18 |
From: Zac Medico <zmedico@g.o> |
19 |
Date: Fri, 10 Oct 2014 21:32:54 -0700 |
20 |
Subject: [PATCH] bin/ebuild-helpers/portageq: fix bug #524964 |
21 |
|
22 |
Since commit 0cc4c1ac21a2ea94cfb1f6ff4b461a9e349d47df, |
23 |
$PORTAGE_BIN_PATH/portageq no longer exists, which breaks |
24 |
bin/ebuild-helpers/portageq. Note that has_version and best_version |
25 |
rely on bin/ebuild-helpers/portageq if IPC is disabled, so breakage |
26 |
extends beyond ebuilds that call portageq "illegally". Since |
27 |
$PORTAGE_BIN_PATH no longer works, use PATH to locate the real |
28 |
portageq python script. |
29 |
|
30 |
Fixes: 0cc4c1ac21a2 ("Install Portage using setup.py") |
31 |
X-Gento-Bug: 524964 |
32 |
X-Gentoo-URL: https://bugs.gentoo.org/show_bug.cgi?id=524964 |
33 |
--- |
34 |
bin/ebuild-helpers/portageq | 20 ++++++++++++++++++-- |
35 |
1 file changed, 18 insertions(+), 2 deletions(-) |
36 |
|
37 |
diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq |
38 |
index b67b03f..4151bac 100755 |
39 |
--- a/bin/ebuild-helpers/portageq |
40 |
+++ b/bin/ebuild-helpers/portageq |
41 |
@@ -2,9 +2,25 @@ |
42 |
# Copyright 2009-2013 Gentoo Foundation |
43 |
# Distributed under the terms of the GNU General Public License v2 |
44 |
|
45 |
+scriptpath=${BASH_SOURCE[0]} |
46 |
+scriptname=${scriptpath##*/} |
47 |
+ |
48 |
PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} |
49 |
PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} |
50 |
# Use safe cwd, avoiding unsafe import for bug #469338. |
51 |
cd "${PORTAGE_PYM_PATH}" |
52 |
-PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ |
53 |
- exec "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/portageq" "$@" |
54 |
+ |
55 |
+IFS=':' |
56 |
+set -f # in case ${PATH} contains any shell glob characters |
57 |
+ |
58 |
+for path in ${PATH}; do |
59 |
+ [[ -x ${path}/${scriptname} ]] || continue |
60 |
+ [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue |
61 |
+ PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ |
62 |
+ exec "${PORTAGE_PYTHON:-/usr/bin/python}" \ |
63 |
+ "${path}/${scriptname}" "$@" |
64 |
+done |
65 |
+ |
66 |
+unset IFS |
67 |
+echo "${scriptname}: command not found" 1>&2 |
68 |
+exit 127 |
69 |
-- |
70 |
1.8.5.5 |