1 |
Author: zmedico |
2 |
Date: 2010-01-31 00:43:59 +0000 (Sun, 31 Jan 2010) |
3 |
New Revision: 15295 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/cache/flat_hash.py |
7 |
Log: |
8 |
Bug #302764 - Inside __iter__, only recurse 1 deep, in order to avoid |
9 |
iteration over entries from another nested cache instance. This can |
10 |
happen if the user nests an overlay inside /usr/portage/local. Thanks |
11 |
to Vlastimil Babka <caster@g.o> for this patch. |
12 |
|
13 |
|
14 |
Modified: main/trunk/pym/portage/cache/flat_hash.py |
15 |
=================================================================== |
16 |
--- main/trunk/pym/portage/cache/flat_hash.py 2010-01-30 22:49:12 UTC (rev 15294) |
17 |
+++ main/trunk/pym/portage/cache/flat_hash.py 2010-01-31 00:43:59 UTC (rev 15295) |
18 |
@@ -120,11 +120,12 @@ |
19 |
|
20 |
def __iter__(self): |
21 |
"""generator for walking the dir struct""" |
22 |
- dirs = [self.location] |
23 |
+ dirs = [(0, self.location)] |
24 |
len_base = len(self.location) |
25 |
while len(dirs): |
26 |
try: |
27 |
- dir_list = os.listdir(dirs[0]) |
28 |
+ depth = dirs[0][0] |
29 |
+ dir_list = os.listdir(dirs[0][1]) |
30 |
except OSError as e: |
31 |
if e.errno != errno.ENOENT: |
32 |
raise |
33 |
@@ -134,10 +135,15 @@ |
34 |
for l in dir_list: |
35 |
if l.endswith(".cpickle"): |
36 |
continue |
37 |
- p = os.path.join(dirs[0],l) |
38 |
+ p = os.path.join(dirs[0][1], l) |
39 |
st = os.lstat(p) |
40 |
if stat.S_ISDIR(st.st_mode): |
41 |
- dirs.append(p) |
42 |
+ # Only recurse 1 deep, in order to avoid iteration over |
43 |
+ # entries from another nested cache instance. This can |
44 |
+ # happen if the user nests an overlay inside |
45 |
+ # /usr/portage/local as in bug #302764. |
46 |
+ if depth < 1: |
47 |
+ dirs.append((depth+1, p)) |
48 |
continue |
49 |
yield p[len_base+1:] |
50 |
dirs.pop(0) |