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
56f8ff00
Commit
56f8ff00
authored
Jul 20, 2015
by
Patrick Toomey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set UID/GID to parent value for lxc-execute
Signed-off-by:
Patrick Toomey
<
ptoomey3@biasedcoin.com
>
parent
e06155c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
conf.c
src/lxc/conf.c
+3
-0
conf.h
src/lxc/conf.h
+4
-0
start.c
src/lxc/start.c
+6
-4
No files found.
src/lxc/conf.c
View file @
56f8ff00
...
@@ -2604,6 +2604,9 @@ struct lxc_conf *lxc_conf_init(void)
...
@@ -2604,6 +2604,9 @@ struct lxc_conf *lxc_conf_init(void)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
for
(
i
=
0
;
i
<
LXC_NS_MAX
;
i
++
)
new
->
inherit_ns_fd
[
i
]
=
-
1
;
new
->
inherit_ns_fd
[
i
]
=
-
1
;
new
->
parent_uid
=
getuid
();
new
->
parent_gid
=
getgid
();
return
new
;
return
new
;
}
}
...
...
src/lxc/conf.h
View file @
56f8ff00
...
@@ -365,6 +365,10 @@ struct lxc_conf {
...
@@ -365,6 +365,10 @@ struct lxc_conf {
/* init command */
/* init command */
char
*
init_cmd
;
char
*
init_cmd
;
/* The UID/GID of the process creating the container */
uid_t
parent_uid
;
gid_t
parent_gid
;
};
};
#ifdef HAVE_TLS
#ifdef HAVE_TLS
...
...
src/lxc/start.c
View file @
56f8ff00
...
@@ -667,13 +667,15 @@ static int do_start(void *data)
...
@@ -667,13 +667,15 @@ static int do_start(void *data)
* privilege over our namespace. We don't become root for lxc-execute, as
* privilege over our namespace. We don't become root for lxc-execute, as
* the intent is to execute a command as the original user.
* the intent is to execute a command as the original user.
*/
*/
if
(
!
handler
->
conf
->
is_execute
&&
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
if
(
!
lxc_list_empty
(
&
handler
->
conf
->
id_map
))
{
NOTICE
(
"switching to gid/uid 0 in new user namespace"
);
gid_t
new_gid
=
handler
->
conf
->
is_execute
?
handler
->
conf
->
parent_gid
:
0
;
if
(
setgid
(
0
))
{
gid_t
new_uid
=
handler
->
conf
->
is_execute
?
handler
->
conf
->
parent_uid
:
0
;
NOTICE
(
"switching to gid/uid %d/%d in new user namespace"
,
new_gid
,
new_uid
);
if
(
setgid
(
new_gid
))
{
SYSERROR
(
"setgid"
);
SYSERROR
(
"setgid"
);
goto
out_warn_father
;
goto
out_warn_father
;
}
}
if
(
setuid
(
0
))
{
if
(
setuid
(
new_uid
))
{
SYSERROR
(
"setuid"
);
SYSERROR
(
"setuid"
);
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