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
bc41134f
Commit
bc41134f
authored
Mar 29, 2016
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #927 from tych0/only-use-host-devnull-no-autodev
start: only use host's /dev/null when absolutely necessary
parents
8f1de71b
7a55c157
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
start.c
src/lxc/start.c
+27
-2
No files found.
src/lxc/start.c
View file @
bc41134f
...
@@ -710,7 +710,8 @@ static int do_start(void *data)
...
@@ -710,7 +710,8 @@ static int do_start(void *data)
{
{
struct
lxc_list
*
iterator
;
struct
lxc_list
*
iterator
;
struct
lxc_handler
*
handler
=
data
;
struct
lxc_handler
*
handler
=
data
;
int
devnull_fd
=
-
1
;
int
devnull_fd
=
-
1
,
ret
;
char
path
[
PATH_MAX
];
if
(
sigprocmask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
))
{
if
(
sigprocmask
(
SIG_SETMASK
,
&
handler
->
oldmask
,
NULL
))
{
SYSERROR
(
"failed to set sigprocmask"
);
SYSERROR
(
"failed to set sigprocmask"
);
...
@@ -789,11 +790,28 @@ static int do_start(void *data)
...
@@ -789,11 +790,28 @@ static int do_start(void *data)
}
}
#endif
#endif
if
(
handler
->
backgrounded
)
{
ret
=
sprintf
(
path
,
"%s/dev/null"
,
handler
->
conf
->
rootfs
.
mount
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
{
SYSERROR
(
"sprintf'd too many chars"
);
goto
out_warn_father
;
}
/* In order to checkpoint restore, we need to have everything in the
* same mount namespace. However, some containers may not have a
* reasonable /dev (in particular, they may not have /dev/null), so we
* can't set init's std fds to /dev/null by opening it from inside the
* container.
*
* If that's the case, fall back to using the host's /dev/null. This
* means that migration won't work, but at least we won't spew output
* where it isn't wanted.
*/
if
(
handler
->
backgrounded
&&
!
handler
->
conf
->
autodev
&&
access
(
path
,
F_OK
)
<
0
)
{
devnull_fd
=
open_devnull
();
devnull_fd
=
open_devnull
();
if
(
devnull_fd
<
0
)
if
(
devnull_fd
<
0
)
goto
out_warn_father
;
goto
out_warn_father
;
WARN
(
"using host's /dev/null for container init's std fds, migraiton won't work"
);
}
}
/* Setup the container, ip, names, utsname, ... */
/* Setup the container, ip, names, utsname, ... */
...
@@ -861,6 +879,13 @@ static int do_start(void *data)
...
@@ -861,6 +879,13 @@ static int do_start(void *data)
close
(
handler
->
sigfd
);
close
(
handler
->
sigfd
);
if
(
devnull_fd
<
0
)
{
devnull_fd
=
open_devnull
();
if
(
devnull_fd
<
0
)
goto
out_warn_father
;
}
if
(
handler
->
backgrounded
&&
set_stdfds
(
devnull_fd
))
if
(
handler
->
backgrounded
&&
set_stdfds
(
devnull_fd
))
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