diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-03-02 19:50:25 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-03-02 19:50:25 +0000 |
commit | ad36ecfecd121902aae78681b26828c86e14db6c (patch) | |
tree | c98e3afa8fb70932c0d2d4f78984f4ef66f3c3eb | |
parent | 8bedbdce7f2d62a0d195c093b3d84218c279db0b (diff) | |
download | portage-ad36ecfecd121902aae78681b26828c86e14db6c.tar.gz portage-ad36ecfecd121902aae78681b26828c86e14db6c.tar.bz2 portage-ad36ecfecd121902aae78681b26828c86e14db6c.zip |
Bug #302764 - Inside __iter__, only recurse 1 deep, in order to avoid
iteration over entries from another nested cache instance. This can
happen if the user nests an overlay inside /usr/portage/local. Thanks
to Vlastimil Babka <caster@g.o> for this patch. (trunk r15295)
svn path=/main/branches/2.1.7/; revision=15534
-rw-r--r-- | pym/portage/cache/flat_hash.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py index 934115805..f882c2475 100644 --- a/pym/portage/cache/flat_hash.py +++ b/pym/portage/cache/flat_hash.py @@ -120,11 +120,12 @@ class database(fs_template.FsBased): def __iter__(self): """generator for walking the dir struct""" - dirs = [self.location] + dirs = [(0, self.location)] len_base = len(self.location) while len(dirs): try: - dir_list = os.listdir(dirs[0]) + depth = dirs[0][0] + dir_list = os.listdir(dirs[0][1]) except OSError as e: if e.errno != errno.ENOENT: raise @@ -134,10 +135,15 @@ class database(fs_template.FsBased): for l in dir_list: if l.endswith(".cpickle"): continue - p = os.path.join(dirs[0],l) + p = os.path.join(dirs[0][1], l) st = os.lstat(p) if stat.S_ISDIR(st.st_mode): - dirs.append(p) + # Only recurse 1 deep, in order to avoid iteration over + # entries from another nested cache instance. This can + # happen if the user nests an overlay inside + # /usr/portage/local as in bug #302764. + if depth < 1: + dirs.append((depth+1, p)) continue yield p[len_base+1:] dirs.pop(0) |