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
f5795427
Commit
f5795427
authored
Nov 03, 2016
by
Stéphane Graber
Committed by
GitHub
Nov 03, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1275 from brauner/2016-11-04/unshare_cgroup_after_clone
start: CLONE_NEWCGROUP after we have setup cgroups
parents
8813bb24
deefdf8a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
start.c
src/lxc/start.c
+20
-4
No files found.
src/lxc/start.c
View file @
f5795427
...
@@ -854,6 +854,26 @@ static int do_start(void *data)
...
@@ -854,6 +854,26 @@ static int do_start(void *data)
if
(
lxc_sync_barrier_parent
(
handler
,
LXC_SYNC_CGROUP
))
if
(
lxc_sync_barrier_parent
(
handler
,
LXC_SYNC_CGROUP
))
goto
out_error
;
goto
out_error
;
/* Unshare cgroup namespace after we have setup our cgroups. If we do it
* earlier we end up with a wrong view of /proc/self/cgroup. For
* example, assume we unshare(CLONE_NEWCGROUP) first, and then create
* the cgroup for the container, say /sys/fs/cgroup/cpuset/lxc/c, then
* /proc/self/cgroup would show us:
*
* 8:cpuset:/lxc/c
*
* whereas it should actually show
*
* 8:cpuset:/
*/
if
(
cgns_supported
())
{
if
(
unshare
(
CLONE_NEWCGROUP
)
<
0
)
{
INFO
(
"Failed to unshare CLONE_NEWCGROUP."
);
goto
out_warn_father
;
}
INFO
(
"Unshared CLONE_NEWCGROUP."
);
}
/* Set the label to change to when we exec(2) the container's init */
/* Set the label to change to when we exec(2) the container's init */
if
(
lsm_process_label_set
(
NULL
,
handler
->
conf
,
1
,
1
)
<
0
)
if
(
lsm_process_label_set
(
NULL
,
handler
->
conf
,
1
,
1
)
<
0
)
goto
out_warn_father
;
goto
out_warn_father
;
...
@@ -1156,10 +1176,6 @@ static int lxc_spawn(struct lxc_handler *handler)
...
@@ -1156,10 +1176,6 @@ static int lxc_spawn(struct lxc_handler *handler)
flags
=
handler
->
clone_flags
;
flags
=
handler
->
clone_flags
;
if
(
handler
->
clone_flags
&
CLONE_NEWUSER
)
if
(
handler
->
clone_flags
&
CLONE_NEWUSER
)
flags
&=
~
CLONE_NEWNET
;
flags
&=
~
CLONE_NEWNET
;
if
(
cgns_supported
())
{
handler
->
clone_flags
|=
CLONE_NEWCGROUP
;
flags
|=
CLONE_NEWCGROUP
;
}
handler
->
pid
=
lxc_clone
(
do_start
,
handler
,
flags
);
handler
->
pid
=
lxc_clone
(
do_start
,
handler
,
flags
);
if
(
handler
->
pid
<
0
)
{
if
(
handler
->
pid
<
0
)
{
SYSERROR
(
"failed to fork into a new namespace"
);
SYSERROR
(
"failed to fork into a new namespace"
);
...
...
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