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
a760603e
Unverified
Commit
a760603e
authored
Oct 31, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups/cgfsng: support MS_READONLY with cgroup ns
If we lack CAP_SYS_ADMIN this is really useful. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
058c1cb6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
cgfsng.c
src/lxc/cgroups/cgfsng.c
+20
-11
No files found.
src/lxc/cgroups/cgfsng.c
View file @
a760603e
...
@@ -1630,27 +1630,36 @@ do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
...
@@ -1630,27 +1630,36 @@ do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
return
0
;
return
0
;
}
}
static
int
mount_cgroup_cgns_supported
(
struct
hierarchy
*
h
,
const
char
*
controllerpath
)
static
int
mount_cgroup_cgns_supported
(
int
type
,
struct
hierarchy
*
h
,
const
char
*
controllerpath
)
{
{
int
ret
;
int
ret
;
char
*
controllers
=
NULL
;
char
*
controllers
=
NULL
;
char
*
type
=
"cgroup2"
;
char
*
fstype
=
"cgroup2"
;
unsigned
long
flags
=
0
;
if
(
!
h
->
is_cgroup_v2
)
{
flags
|=
MS_NOSUID
;
controllers
=
lxc_string_join
(
","
,
(
const
char
**
)
h
->
controllers
,
false
);
flags
|=
MS_NOEXEC
;
if
(
!
controllers
)
flags
|=
MS_NODEV
;
return
-
ENOMEM
;
flags
|=
MS_RELATIME
;
type
=
"cgroup"
;
if
(
type
==
LXC_AUTO_CGROUP_RO
||
type
==
LXC_AUTO_CGROUP_FULL_RO
)
flags
|=
MS_RDONLY
;
if
(
!
h
->
is_cgroup_v2
)
{
controllers
=
lxc_string_join
(
","
,
(
const
char
**
)
h
->
controllers
,
false
);
if
(
!
controllers
)
return
-
ENOMEM
;
fstype
=
"cgroup"
;
}
}
ret
=
mount
(
"cgroup"
,
controllerpath
,
type
,
MS_NOSUID
|
MS_NOEXEC
|
MS_NODEV
|
MS_RELATIME
,
controllers
);
ret
=
mount
(
"cgroup"
,
controllerpath
,
fstype
,
flags
,
controllers
);
free
(
controllers
);
free
(
controllers
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount %s with cgroup filesystem type %s"
,
controllerpath
,
type
);
SYSERROR
(
"Failed to mount %s with cgroup filesystem type %s"
,
controllerpath
,
fs
type
);
return
-
1
;
return
-
1
;
}
}
DEBUG
(
"Mounted %s with cgroup filesystem type %s"
,
controllerpath
,
type
);
DEBUG
(
"Mounted %s with cgroup filesystem type %s"
,
controllerpath
,
fs
type
);
return
0
;
return
0
;
}
}
...
@@ -1714,7 +1723,7 @@ static bool cgfsng_mount(void *hdata, const char *root, int type)
...
@@ -1714,7 +1723,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
(
h
,
controllerpath
);
r
=
mount_cgroup_cgns_supported
(
type
,
h
,
controllerpath
);
free
(
controllerpath
);
free
(
controllerpath
);
if
(
r
<
0
)
if
(
r
<
0
)
goto
bad
;
goto
bad
;
...
...
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