lxc-generate-aa-rules.py revision e2f91e3434ddf2d4cb85d2385057a492eb462166
953e611ceabed9ccf986e0b234379c2af4bb331aJames Hunt# blocks is an array of paths under which we want to block by
953e611ceabed9ccf986e0b234379c2af4bb331aJames Hunt# blocks[0] = ['path' = '/sys', 'children' = [A,B] ]
5c320b769229d713e84b02ed6b7ae1309ac31dbbGuido Trotter# blocks[1] = ['path' = '/proc/sys', 'children' = [ E ] ]
55fc19a1042bca36ae431cb4a51c2abc0ca4d801Stéphane Graber# A = [ 'path' = 'fs', children = [C] ]
55fc19a1042bca36ae431cb4a51c2abc0ca4d801Stéphane Graber# C = [ 'path' = 'cgroup', children = [F] ]
c13c0e08da7dbfecb52e85233ac6cd17afa5d818Stéphane Graber# B = [ 'path' = 'class', children = [D] ]
892bd61e0fcc788390abfadd32b1897943290879dlezcano# D = [ 'path' = 'net', children = [F] ]
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano# E = [ 'path' = 'shm*' ]
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano# F = [ 'path' = '**' ]
2b47bac3f81af9eb8ba392867c78fe3dec40a36aChristian Brauner blocks.append({'path': path.strip(), 'children': []})
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano# @prev is an array of dicts which containing 'path' and
03f09a8ada8dcf15923b5913ec832e005179f962Wolfgang Bumiller# 'children'. @path is a string. We are looking for an entry
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano# in @prev which contains @path, and will return its
4019712d198a7d50b08b326ade17f5ff1666efbbStéphane Graber# children array.
813a4837659d5d7a2c0d0abe03c87196747217e9Serge Hallyn return p['children']
d1de19abd0067f38bc08a4a3357de701a4e5571ddlezcano return None
810567bbbe283c547e4ac837545d1e592916df26Serge Hallyn # find which block we belong to
55fc19a1042bca36ae431cb4a51c2abc0ca4d801Stéphane Graber # TODO - should we find the longest match?
7822022c4c72cee06905b540b89b653491d6f6b2Stéphane Graber if tmp is not None:
denies = []
for c in children:
def append_deny(s):
if s not in denies:
for c in children:
for b in blocks:
print(genby)
for d in denies: