do not allow multiple xenconsole connect to the same pty
PATCH 1/1 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 <[email protected]>
tools/console/client/main.c +7 -0
@@ -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); } }