]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
set close-on-exec flag on command socket
authorDaniel Lezcano <daniel.lezcano@free.fr>
Thu, 2 Jun 2011 07:50:38 +0000 (09:50 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 2 Jun 2011 07:50:38 +0000 (09:50 +0200)
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 <karma@jazz.email.ne.jp>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/commands.c

index b83d65a41d82ba330042078d4d619c08971f1396..ac75ae476ba3a25aa3d6b248a4ebfc5071b0e638 100644 (file)
@@ -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");