[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH]do not allow multiple xenconsole connect to the same pty



allowing multiple xenconsole connect to the same pty is just insane,
prevent this by acquiring a write flock on the pty fd once we opened it.

Signed-off-by: Li Dongyang <lidongyang@xxxxxxxxxx>

diff -r c64dcc4d2eca -r 08ea56ee1b70 tools/console/client/main.c
--- a/tools/console/client/main.c       Thu Feb 10 17:24:41 2011 +0000
+++ b/tools/console/client/main.c       Tue Feb 15 12:00:21 2011 +0800
@@ -96,6 +96,7 @@
  * Assumes there is already a watch set in the store for this path. */
 {
        struct timeval tv;
+       struct flock lock;
        fd_set watch_fdset;
        int xs_fd = xs_fileno(xs), pty_fd = -1;
        int start, now;
@@ -122,6 +123,12 @@
                                if (pty_fd == -1) 
                                        err(errno, "Could not open tty `%s'", 
                                            pty_path);
+                               memset(&lock, 0, sizeof(lock));
+                               lock.l_type = F_WRLCK;
+                               lock.l_whence = SEEK_SET;
+                               if (fcntl(pty_fd, F_SETLK, &lock) != 0)
+                                       err(errno, "Could not lock tty '%s'",
+                                           pty_path);
                                free(pty_path);
                        }
                }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.