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
03afa514
Commit
03afa514
authored
Sep 12, 2017
by
Stéphane Graber
Committed by
GitHub
Sep 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1807 from brauner/2017-09-12/start_move_env_setup
start: move env setup before container setup
parents
52109c4b
98ff08ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
start.c
src/lxc/start.c
+29
-29
No files found.
src/lxc/start.c
View file @
03afa514
...
...
@@ -913,6 +913,23 @@ static int do_start(void *data)
INFO
(
"Unshared CLONE_NEWCGROUP."
);
}
/* The clearenv() and putenv() calls have been moved here to allow us to
* use environment variables passed to the various hooks, such as the
* start hook above. Not all of the variables like CONFIG_PATH or ROOTFS
* are valid in this context but others are.
*/
if
(
clearenv
())
{
SYSERROR
(
"Failed to clear environment."
);
/* Don't error out though. */
}
lxc_list_for_each
(
iterator
,
&
handler
->
conf
->
environment
)
{
if
(
putenv
((
char
*
)
iterator
->
elem
))
{
SYSERROR
(
"Failed to set environment variable: %s."
,
(
char
*
)
iterator
->
elem
);
goto
out_warn_father
;
}
}
/* Setup the container, ip, names, utsname, ... */
ret
=
lxc_setup
(
handler
);
close
(
handler
->
data_sock
[
0
]);
...
...
@@ -962,35 +979,6 @@ static int do_start(void *data)
goto
out_warn_father
;
}
/* The clearenv() and putenv() calls have been moved here to allow us to
* use environment variables passed to the various hooks, such as the
* start hook above. Not all of the variables like CONFIG_PATH or ROOTFS
* are valid in this context but others are.
*/
if
(
clearenv
())
{
SYSERROR
(
"Failed to clear environment."
);
/* Don't error out though. */
}
lxc_list_for_each
(
iterator
,
&
handler
->
conf
->
environment
)
{
if
(
putenv
((
char
*
)
iterator
->
elem
))
{
SYSERROR
(
"Failed to set environment variable: %s."
,
(
char
*
)
iterator
->
elem
);
goto
out_warn_father
;
}
}
if
(
putenv
(
"container=lxc"
))
{
SYSERROR
(
"Failed to set environment variable: container=lxc."
);
goto
out_warn_father
;
}
if
(
handler
->
conf
->
pty_names
)
{
if
(
putenv
(
handler
->
conf
->
pty_names
))
{
SYSERROR
(
"Failed to set environment variable for container ptys."
);
goto
out_warn_father
;
}
}
close
(
handler
->
sigfd
);
if
(
devnull_fd
<
0
)
{
...
...
@@ -1017,6 +1005,18 @@ static int do_start(void *data)
if
(
lxc_sync_barrier_parent
(
handler
,
LXC_SYNC_CGROUP_LIMITS
))
goto
out_warn_father
;
if
(
putenv
(
"container=lxc"
))
{
SYSERROR
(
"Failed to set environment variable: container=lxc."
);
goto
out_warn_father
;
}
if
(
handler
->
conf
->
pty_names
)
{
if
(
putenv
(
handler
->
conf
->
pty_names
))
{
SYSERROR
(
"Failed to set environment variable for container ptys."
);
goto
out_warn_father
;
}
}
/* The container has been setup. We can now switch to an unprivileged
* uid/gid.
*/
...
...
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