Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
1530ced3
Unverified
Commit
1530ced3
authored
Feb 12, 2019
by
Stéphane Graber
Committed by
GitHub
Feb 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2847 from 4383/improve-lxc-generator
apparmor: catch config file opening error
parents
b091c341
c70de0ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
31 deletions
+47
-31
.travis.yml
.travis.yml
+3
-0
lxc-generate-aa-rules.py
config/apparmor/lxc-generate-aa-rules.py
+44
-31
No files found.
.travis.yml
View file @
1530ced3
...
...
@@ -27,6 +27,9 @@ script:
-
../configure --enable-tests --with-distro=unknown
-
make -j4
-
make DESTDIR=$TRAVIS_BUILD_DIR/install install
-
cd ..
-
./config/apparmor/lxc-generate-aa-rules.py config/apparmor/container-rules.base
notifications
:
email
:
recipients
:
...
...
config/apparmor/lxc-generate-aa-rules.py
View file @
1530ced3
...
...
@@ -3,6 +3,7 @@
import
sys
blocks
=
[]
denies
=
[]
#
# blocks is an array of paths under which we want to block by
...
...
@@ -63,28 +64,6 @@ def add_allow(path):
prev
.
append
(
n
)
prev
=
n
[
'children'
]
config
=
"config"
if
len
(
sys
.
argv
)
>
1
:
config
=
sys
.
argv
[
1
]
with
open
(
config
)
as
f
:
for
x
in
f
.
readlines
():
x
.
strip
()
if
x
[:
1
]
==
'#'
:
continue
try
:
(
cmd
,
path
)
=
x
.
split
(
' '
)
except
:
# blank line
continue
if
cmd
==
"block"
:
add_block
(
path
)
elif
cmd
==
"allow"
:
add_allow
(
path
)
else
:
print
(
"Unknown command:
%
s"
%
cmd
)
sys
.
exit
(
1
)
denies
=
[]
def
collect_chars
(
children
,
ref
,
index
):
r
=
""
...
...
@@ -126,14 +105,48 @@ def gen_denies(pathsofar, children):
newpath
=
"
%
s/
%
s"
%
(
pathsofar
,
c
[
'path'
])
gen_denies
(
newpath
,
c
[
'children'
])
for
b
in
blocks
:
gen_denies
(
b
[
'path'
],
b
[
'children'
])
denies
.
sort
()
def
main
():
config
=
"config"
if
len
(
sys
.
argv
)
>
1
:
config
=
sys
.
argv
[
1
]
lines
=
None
try
:
with
open
(
config
)
as
f
:
lines
=
f
.
readlines
()
except
FileNotFoundError
as
err
:
print
(
"Config file not found"
)
print
(
err
)
sys
.
exit
(
1
)
for
line
in
lines
:
line
.
strip
()
if
line
.
startswith
(
'#'
):
continue
try
:
(
cmd
,
path
)
=
line
.
split
(
' '
)
except
:
# blank line
continue
if
cmd
==
"block"
:
add_block
(
path
)
elif
cmd
==
"allow"
:
add_allow
(
path
)
else
:
print
(
"Unknown command:
%
s"
%
cmd
)
sys
.
exit
(
1
)
for
block
in
blocks
:
gen_denies
(
block
[
'path'
],
block
[
'children'
])
denies
.
sort
()
genby
=
" # generated by: lxc-generate-aa-rules.py"
for
a
in
sys
.
argv
[
1
:]:
genby
+=
"
%
s"
%
a
print
(
genby
)
for
d
in
denies
:
print
(
"
%
s"
%
d
)
genby
=
" # generated by: lxc-generate-aa-rules.py"
for
a
in
sys
.
argv
[
1
:]:
genby
+=
"
%
s"
%
a
print
(
genby
)
for
d
in
denies
:
print
(
"
%
s"
%
d
)
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment