diff options
author | Mike Gilbert <floppym@gentoo.org> | 2020-05-31 23:08:40 -0400 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-06-11 12:10:06 +0530 |
commit | 692b9af94c02f58156bc429e950d99ffff046743 (patch) | |
tree | 8289837443818e1b1dd83e2d3ccb21307ee941fd | |
parent | 8515ae2e0cbe4d501242041e3486152a14066e93 (diff) | |
download | meson-692b9af94c02f58156bc429e950d99ffff046743.zip meson-692b9af94c02f58156bc429e950d99ffff046743.tar.gz meson-692b9af94c02f58156bc429e950d99ffff046743.tar.bz2 |
Ignore file access errors when scanning .so files in system libdirs
Bug: https://bugs.gentoo.org/726524
-rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 8b62b68..336d5c6 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -158,15 +158,24 @@ class CLikeCompiler: if not files: retval.append(d) continue - file_to_check = os.path.join(d, files[0]) - with open(file_to_check, 'rb') as fd: - header = fd.read(5) - # if file is not an ELF file, it's weird, but accept dir - # if it is elf, and the class matches, accept dir - if header[1:4] != b'ELF' or int(header[4]) == elf_class: - retval.append(d) - # at this point, it's an ELF file which doesn't match the - # appropriate elf_class, so skip this one + + for f in files: + file_to_check = os.path.join(d, f) + try: + with open(file_to_check, 'rb') as fd: + header = fd.read(5) + # if file is not an ELF file, it's weird, but accept dir + # if it is elf, and the class matches, accept dir + if header[1:4] != b'ELF' or int(header[4]) == elf_class: + retval.append(d) + # at this point, it's an ELF file which doesn't match the + # appropriate elf_class, so skip this one + # stop scanning after the first sucessful read + break + except OSError: + # Skip the file if we can't read it + pass + return tuple(retval) @functools.lru_cache() |