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
87bf0db0
Unverified
Commit
87bf0db0
authored
Jan 07, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start: check for CAP_SETGID before setgroups()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ca364dc0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
start.c
src/lxc/start.c
+5
-10
No files found.
src/lxc/start.c
View file @
87bf0db0
...
@@ -889,22 +889,17 @@ static int do_start(void *data)
...
@@ -889,22 +889,17 @@ static int do_start(void *data)
* uid/gid.
* uid/gid.
*/
*/
if
(
handler
->
conf
->
is_execute
)
{
if
(
handler
->
conf
->
is_execute
)
{
uid_t
new_uid
=
0
;
bool
have_cap_setgid
;
gid_t
new_gid
=
0
;
uid_t
new_uid
=
handler
->
conf
->
init_uid
;
gid_t
new_gid
=
handler
->
conf
->
init_gid
;
if
(
handler
->
conf
->
init_uid
>
0
)
new_uid
=
handler
->
conf
->
init_uid
;
if
(
handler
->
conf
->
init_gid
>
0
)
new_gid
=
handler
->
conf
->
init_gid
;
/* If we are in a new user namespace we already dropped all
/* If we are in a new user namespace we already dropped all
* groups when we switched to root in the new user namespace
* groups when we switched to root in the new user namespace
* further above. Only drop groups if we can, so ensure that we
* further above. Only drop groups if we can, so ensure that we
* have necessary privilege.
* have necessary privilege.
*/
*/
bool
can_setgroups
=
((
getuid
()
==
0
)
&&
(
getgid
()
==
0
)
);
have_cap_setgid
=
lxc_cap_is_set
(
CAP_SETGID
,
CAP_EFFECTIVE
);
if
(
lxc_list_empty
(
&
handler
->
conf
->
id_map
)
&&
can_setgroups
)
{
if
(
lxc_list_empty
(
&
handler
->
conf
->
id_map
)
&&
have_cap_setgid
)
{
if
(
lxc_setgroups
(
0
,
NULL
)
<
0
)
if
(
lxc_setgroups
(
0
,
NULL
)
<
0
)
goto
out_warn_father
;
goto
out_warn_father
;
}
}
...
...
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