From 6f3056546857c399442c04bb1168ed7ca2fe93a5 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Jan 22 2007 12:21:26 +0000 Subject: - refuse connections while waiting for console, fixes #168076 --- diff --git a/gpm-1.20.1-deadsocket.patch b/gpm-1.20.1-deadsocket.patch new file mode 100644 index 0000000..e0b674e --- /dev/null +++ b/gpm-1.20.1-deadsocket.patch @@ -0,0 +1,56 @@ +--- gpm-1.20.1/src/gpm.c.deadsocket 2007-01-22 12:53:19.000000000 +0100 ++++ gpm-1.20.1/src/gpm.c 2007-01-22 12:49:54.000000000 +0100 +@@ -544,7 +544,7 @@ + * we can safely use micelist + */ + close(micelist->dev.fd); +- wait_text_console(); ++ wait_text_console(ctlfd); + /* reopen, reinit (the function is only used if we have one mouse device) */ + if ((micelist->dev.fd = open(micelist->device, O_RDWR)) < 0) + gpm_report(GPM_PR_OOPS, GPM_MESS_OPEN, micelist->device); +--- gpm-1.20.1/src/console.c.deadsocket 2007-01-22 00:50:25.000000000 +0100 ++++ gpm-1.20.1/src/console.c 2007-01-22 13:08:18.000000000 +0100 +@@ -101,7 +101,7 @@ + } + + /*-------------------------------------------------------------------*/ +-void wait_text_console(void) ++void wait_text_console(int ctlfd) + { + struct timeval now; + int usecs; +@@ -113,7 +113,21 @@ + usecs -= 1000000; + usecs += 1000000 - now.tv_usec; + +- usleep(usecs); ++ now.tv_sec = 0; ++ now.tv_usec = usecs; ++ ++ /* check for pending connections and reject them */ ++ fd_set fds; ++ FD_ZERO(&fds); ++ FD_SET(ctlfd, &fds); ++ ++ select(ctlfd + 1, &fds, 0, 0, &now); ++ ++ if (FD_ISSET(ctlfd, &fds) && !is_text_console()) { ++ int fd = accept(ctlfd, 0, 0); ++ if (fd >= 0) ++ close(fd); ++ } + } while (!is_text_console()); + } + +--- gpm-1.20.1/src/headers/console.h.deadsocket 2007-01-22 12:53:27.000000000 +0100 ++++ gpm-1.20.1/src/headers/console.h 2007-01-22 12:51:49.000000000 +0100 +@@ -33,7 +33,7 @@ + char *get_console_name(); + char *compose_vc_name(int vc); + int is_text_console(void); +-void wait_text_console(void); ++void wait_text_console(int ctlfd); + void refresh_console_size(void); + int is_console_owner(int vc, uid_t uid); + int get_console_state(unsigned char *shift_state); diff --git a/gpm.spec b/gpm.spec index 9f93952..af23ef2 100644 --- a/gpm.spec +++ b/gpm.spec @@ -1,7 +1,7 @@ Summary: A mouse server for the Linux console. Name: gpm Version: 1.20.1 -Release: 77 +Release: 78 License: GPL Group: System Environment/Daemons Source: http://ftp.linux.it/pub/People/rubini/gpm/%{name}-%{version}.tar.gz @@ -183,6 +183,9 @@ fi %{_libdir}/libgpm.so %changelog +* Mon Jan 22 2007 Tomas Janousek - 1.20.1-78 +- refuse connections while waiting for console, fixes #168076 + * Mon Jan 22 2007 Tomas Janousek - 1.20.1-77 - #223696: non-failsafe install-info use in scriptlets