Ignore file access errors when scanning .so files in system libdirs
@@ -152,7 +152,10 @@ class CLikeCompiler:
if not files:
retval.append(d)
continue
- file_to_check = os.path.join(d, files[0])
+
+ 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
@@ -161,6 +164,12 @@ class CLikeCompiler:
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()
