Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] epatch: reject patches with relative paths
Date: Fri, 31 Dec 2010 00:05:47
Message-Id: 201012301904.26180.vapier@gentoo.org
1 epatch was changed to auto-skip the first path element when it is absolute
2 (starts with a slash). the reason was to avoid issues with patches touching
3 files outside of $PWD (which is bad if sandbox is disabled).
4
5 along those lines, we should start rejecting relative paths. we cant auto-
6 skip the leading elements since relative paths could appear anywhere.
7
8 rather than making it fatal right away, this patch adds some ewarns. after a
9 while, we can convert it to a die.
10 -mike
11
12 --- eutils.eclass 22 Nov 2010 00:31:03 -0000 1.352
13 +++ eutils.eclass 30 Dec 2010 23:52:41 -0000
14 @@ -360,6 +360,12 @@ epatch() {
15 count=1
16 printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}"
17 fi
18 + # Similar reason, but with relative paths.
19 + local rel_paths=$(egrep -n '^[-+]{3} [^\t]*[.][.]/' "${PATCH_TARGET}")
20 + if [[ -n ${rel_paths} ]] ; then
21 + ewarn "Your patch has relative paths; in the future this will fail:"
22 + ewarn "${rel_paths}"
23 + fi
24
25 # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/
26 while [[ ${count} -lt 5 ]] ; do

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] epatch: reject patches with relative paths "Robin H. Johnson" <robbat2@g.o>
Re: [gentoo-dev] epatch: reject patches with relative paths James Cloos <cloos@×××××××.com>