Created
November 12, 2015 06:48
-
-
Save GaryLee/5d0131ec85935b0ec5b5 to your computer and use it in GitHub Desktop.
A python script which check the output of 'ldconfig -p' and see if any library which is not readable for everyone. The output of ldconfig should put into the file which ld_list_file spcified.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
import os, re | |
ld_list_file = 'ldconfig.list' | |
pattern = re.compile(r'.*=>\s*(?P<libfile>.*)\s*') | |
lib_files = map(lambda x: x.groupdict()['libfile'], | |
filter(lambda x: x, | |
map(lambda ln: pattern.match(ln), | |
file(ld_list_file, 'r')))) | |
for filepath in lib_files: | |
try: | |
fstat = os.stat(filepath) | |
if (fstat.st_mode & 0o444) != 0o444: | |
print '%o' % (fstat.st_mode & 0o777), filepath | |
except OSError: | |
print '[???]', filepath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment