Fix detect chroot function.

develop
Mike Hiretsky 14 years ago
parent c8b8ef797d
commit 9273f2d49a

@ -510,20 +510,10 @@ class varsShare:
if reRes:
return reRes.group()
reChroot = re.compile("^(?:_=.*bin/chroot|CHROOT=on)$",re.S)
def isChroot(self,pid):
"""Recursive detect chroot mode"""
if not os.access('/proc/%d/environ'%pid,R_OK):
"""Detect chroot mode by different mountinfo"""
if not os.access('/proc/self/mountinfo',R_OK) or \
not os.access('/proc/1/mountinfo',R_OK):
return False
if filter(self.reChroot.match,
open('/proc/%d/environ'%pid,'r').read().split('\x00')):
return True
else:
ppid = filter(lambda x:x.startswith('PPid:'),
open('/proc/%d/status'%pid,'r').readlines())[0]
ppid = int(ppid.strip().partition('\t')[2])
if ppid == 0:
return False
else:
return self.isChroot(ppid)
return open('/proc/1/mountinfo','r').read() != \
open('/proc/self/mountinfo','r').read()

Loading…
Cancel
Save