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
6ca8172d
Unverified
Commit
6ca8172d
authored
May 24, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
seccomp: parse_config()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
9c3798eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
seccomp.c
src/lxc/seccomp.c
+19
-10
No files found.
src/lxc/seccomp.c
View file @
6ca8172d
...
...
@@ -1035,7 +1035,7 @@ static int parse_config_v2(FILE *f, char *line, struct lxc_conf *conf)
*/
static
int
parse_config
(
FILE
*
f
,
struct
lxc_conf
*
conf
)
{
char
line
[
1024
];
char
line
[
MAXPATHLEN
];
int
ret
,
version
;
ret
=
fscanf
(
f
,
"%d
\n
"
,
&
version
);
...
...
@@ -1043,10 +1043,12 @@ static int parse_config(FILE *f, struct lxc_conf *conf)
ERROR
(
"Invalid version"
);
return
-
1
;
}
if
(
!
fgets
(
line
,
1024
,
f
))
{
if
(
!
fgets
(
line
,
MAXPATHLEN
,
f
))
{
ERROR
(
"Invalid config file"
);
return
-
1
;
}
if
(
version
==
1
&&
!
strstr
(
line
,
"whitelist"
))
{
ERROR
(
"Only whitelist policy is supported"
);
return
-
1
;
...
...
@@ -1059,6 +1061,7 @@ static int parse_config(FILE *f, struct lxc_conf *conf)
if
(
version
==
1
)
return
parse_config_v1
(
f
,
conf
);
return
parse_config_v2
(
f
,
line
,
conf
);
}
...
...
@@ -1071,34 +1074,40 @@ static int parse_config(FILE *f, struct lxc_conf *conf)
*/
static
bool
use_seccomp
(
void
)
{
FILE
*
f
=
fopen
(
"/proc/self/status"
,
"r"
);
char
line
[
1024
];
bool
already_enabled
=
false
;
bool
found
=
false
;
int
ret
,
v
;
FILE
*
f
;
size_t
line_bufsz
=
0
;
char
*
line
=
NULL
;
bool
already_enabled
=
false
,
found
=
false
;
f
=
fopen
(
"/proc/self/status"
,
"r"
);
if
(
!
f
)
return
true
;
while
(
fgets
(
line
,
1024
,
f
)
)
{
while
(
getline
(
&
line
,
&
line_bufsz
,
f
)
!=
-
1
)
{
if
(
strncmp
(
line
,
"Seccomp:"
,
8
)
==
0
)
{
found
=
true
;
ret
=
sscanf
(
line
+
8
,
"%d"
,
&
v
);
if
(
ret
==
1
&&
v
!=
0
)
already_enabled
=
true
;
break
;
}
}
free
(
line
);
fclose
(
f
);
if
(
!
found
)
{
/* no Seccomp line, no seccomp in kernel */
if
(
!
found
)
{
INFO
(
"Seccomp is not enabled in the kernel"
);
return
false
;
}
if
(
already_enabled
)
{
/* already seccomp-confined */
if
(
already_enabled
)
{
INFO
(
"Already seccomp-confined, not loading new policy"
);
return
false
;
}
return
true
;
}
...
...
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