Skip to content

Instantly share code, notes, and snippets.

@GaryLee
Created November 12, 2015 06:48
Show Gist options
  • Save GaryLee/5d0131ec85935b0ec5b5 to your computer and use it in GitHub Desktop.
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.
#!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