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
d99e66cd
Unverified
Commit
d99e66cd
authored
Feb 08, 2018
by
Stéphane Graber
Committed by
GitHub
Feb 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2140 from brauner/2018-02-08/cgfsng_fix_ro_remount
cgfsng: add required remount flags
parents
ca20a3b3
5285689c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
cgfsng.c
src/lxc/cgroups/cgfsng.c
+11
-5
conf.c
src/lxc/conf.c
+1
-1
No files found.
src/lxc/cgroups/cgfsng.c
View file @
d99e66cd
...
@@ -1923,7 +1923,7 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
...
@@ -1923,7 +1923,7 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
char
*
controllerpath
,
char
*
cgpath
,
char
*
controllerpath
,
char
*
cgpath
,
const
char
*
container_cgroup
)
const
char
*
container_cgroup
)
{
{
int
ret
;
int
ret
,
remount_flags
;
char
*
sourcepath
;
char
*
sourcepath
;
int
flags
=
MS_BIND
;
int
flags
=
MS_BIND
;
...
@@ -1935,6 +1935,9 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
...
@@ -1935,6 +1935,9 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
return
-
1
;
return
-
1
;
}
}
remount_flags
=
add_required_remount_flags
(
controllerpath
,
controllerpath
,
flags
|
MS_REMOUNT
);
ret
=
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
ret
=
mount
(
controllerpath
,
controllerpath
,
"cgroup"
,
MS_REMOUNT
|
MS_BIND
|
MS_RDONLY
,
NULL
);
MS_REMOUNT
|
MS_BIND
|
MS_RDONLY
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -1959,13 +1962,15 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
...
@@ -1959,13 +1962,15 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
INFO
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
h
->
controllers
[
0
],
cgpath
);
INFO
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
h
->
controllers
[
0
],
cgpath
);
if
(
flags
&
MS_RDONLY
)
{
if
(
flags
&
MS_RDONLY
)
{
ret
=
mount
(
sourcepath
,
cgpath
,
"cgroup"
,
remount_flags
=
add_required_remount_flags
(
sourcepath
,
cgpath
,
MS_REMOUNT
|
flags
|
MS_RDONLY
,
NULL
);
flags
|
MS_REMOUNT
);
ret
=
mount
(
sourcepath
,
cgpath
,
"cgroup"
,
remount_flags
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to remount
\"
%s
\"
ro"
,
cgpath
);
SYSERROR
(
"Failed to remount
\"
%s
\"
ro"
,
cgpath
);
free
(
sourcepath
);
free
(
sourcepath
);
return
-
1
;
return
-
1
;
}
}
INFO
(
"Remounted %s read-only"
,
cgpath
);
}
}
free
(
sourcepath
);
free
(
sourcepath
);
...
@@ -1973,7 +1978,8 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
...
@@ -1973,7 +1978,8 @@ static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
return
0
;
return
0
;
}
}
static
int
mount_cgroup_cgns_supported
(
int
type
,
struct
hierarchy
*
h
,
const
char
*
controllerpath
)
static
int
cg_mount_in_cgroup_namespace
(
int
type
,
struct
hierarchy
*
h
,
const
char
*
controllerpath
)
{
{
int
ret
;
int
ret
;
char
*
controllers
=
NULL
;
char
*
controllers
=
NULL
;
...
@@ -2066,7 +2072,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
...
@@ -2066,7 +2072,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
* will not have CAP_SYS_ADMIN after it has started we
* will not have CAP_SYS_ADMIN after it has started we
* need to mount the cgroups manually.
* need to mount the cgroups manually.
*/
*/
r
=
mount_cgroup_cgns_supported
(
type
,
h
,
controllerpath
);
r
=
cg_mount_in_cgroup_namespace
(
type
,
h
,
controllerpath
);
free
(
controllerpath
);
free
(
controllerpath
);
if
(
r
<
0
)
if
(
r
<
0
)
goto
bad
;
goto
bad
;
...
...
src/lxc/conf.c
View file @
d99e66cd
...
@@ -575,7 +575,7 @@ int pin_rootfs(const char *rootfs)
...
@@ -575,7 +575,7 @@ int pin_rootfs(const char *rootfs)
* NOEXEC etc are honored.
* NOEXEC etc are honored.
*/
*/
unsigned
long
add_required_remount_flags
(
const
char
*
s
,
const
char
*
d
,
unsigned
long
add_required_remount_flags
(
const
char
*
s
,
const
char
*
d
,
unsigned
long
flags
)
unsigned
long
flags
)
{
{
#ifdef HAVE_STATVFS
#ifdef HAVE_STATVFS
struct
statvfs
sb
;
struct
statvfs
sb
;
...
...
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