Commit 454ec0ab by Serge Hallyn Committed by Stéphane Graber

api_start: always close fds 0-2 when daemonized

commit 507cee36 moved the close and re-open of fds 0-2 into do_start. But this means that the lxc monitor itself keeps the caller's fds 0-2 open, which is wrong for daemonized containers. Closes #548 Reported-by: 's avatarMathieu Le Marec - Pasquet <kiorky@cryptelium.net> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 27be5731
...@@ -722,6 +722,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a ...@@ -722,6 +722,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
return false; return false;
} }
lxc_check_inherited(conf, true, -1); lxc_check_inherited(conf, true, -1);
close(0);
close(1);
close(2);
open("/dev/zero", O_RDONLY);
open("/dev/null", O_RDWR);
open("/dev/null", O_RDWR);
setsid(); setsid();
} else { } else {
if (!am_single_threaded()) { if (!am_single_threaded()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment