From: Daniel Lezcano Date: Thu, 2 Jun 2011 07:50:38 +0000 (+0200) Subject: set close-on-exec flag on command socket X-Git-Tag: lxc-0.7.5~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ccb2dbcd2c437ca8cc867814ba0412a3fe55420;p=thirdparty%2Flxc.git set close-on-exec flag on command socket When we accept a connection, we have to set the close-on-exec flag, otherwise that won't be possible to reboot a container through a lxc-console command. Reported-by: Katoh Yasufumi Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/commands.c b/src/lxc/commands.c index b83d65a41..ac75ae476 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -236,6 +236,11 @@ static int incoming_command_handler(int fd, void *data, return -1; } + if (fcntl(connection, F_SETFD, FD_CLOEXEC)) { + SYSERROR("failed to set close-on-exec on incoming connection"); + goto out_close; + } + if (setsockopt(connection, SOL_SOCKET, SO_PASSCRED, &opt, sizeof(opt))) { SYSERROR("failed to enable credential on socket");