- refuse connections while waiting for console, fixes #168076

This commit is contained in:
Tomas Janousek 2007-01-22 12:21:26 +00:00
parent 5b9ef5a801
commit 6f30565468
2 changed files with 60 additions and 1 deletions

View File

@ -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);

View File

@ -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 <tjanouse@redhat.com> - 1.20.1-78
- refuse connections while waiting for console, fixes #168076
* Mon Jan 22 2007 Tomas Janousek <tjanouse@redhat.com> - 1.20.1-77
- #223696: non-failsafe install-info use in scriptlets