import sys
blocks = []
#
# blocks is an array of paths under which we want to block by
# default.
#
# blocks[0] = ['path' = '/sys', 'children' = [A,B] ]
# A = [ 'path' = 'fs', children = [C] ]
# C = [ 'path' = 'cgroup', children = [F] ]
# B = [ 'path' = 'class', children = [D] ]
# D = [ 'path' = 'net', children = [F] ]
# E = [ 'path' = 'shm*' ]
# F = [ 'path' = '**' ]
for b in blocks:
if b['path'] == path:
# duplicate
return
# @prev is an array of dicts which containing 'path' and
# 'children'. @path is a string. We are looking for an entry
# in @prev which contains @path, and will return its
# children array.
for p in prev:
if p['path'] == path:
return p['children']
return None
# find which block we belong to
found = None
for b in blocks:
l = len(b['path'])
continue
# TODO - should we find the longest match?
found = b
break
if found is None:
print("allow with no previous block at %s" % path)
while p[:1] == "/":
p = p[1:]
prev = b['children']
for s in p.split('/'):
if tmp is not None:
else:
prev = n['children']
for x in f.readlines():
x.strip()
if x[:1] == '#':
continue
try:
except: # blank line
continue
if cmd == "block":
elif cmd == "allow":
else:
print("Unknown command: %s" % cmd)
denies = []
r = ""
for c in children:
continue
continue
if c['path'][index] not in r:
r = r + c['path'][index]
return r
def append_deny(s):
s = "%s wklx," % s
if s not in denies:
for c in children:
continue
continue
elif c['path'] != '**':
for b in blocks:
genby += " %s" % a
print(genby)
for d in denies:
print(" %s" % d)