gpm 1.19.4 - SEGV in Gpm_Open()
Jakub Bogusz
qboosh@pld.org.pl
Sun, 9 Sep 2001 20:04:32 +0200
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
[note: I am not subscriber of gpm list, so please Cc: to me when you answer]
[BTW, are gpm@prosa.it and gpm@lists.linux.it separate lists or one is
an alias to the other? I am not sure which I should write to...]
On Sat, Sep 08, 2001 at 10:39:24PM +0200, Nico Schottelius wrote:
> You are right!
> This is fixed in the next gpm version.
> I will release 1.19.5 in about one week.
>
> check_devfs was a small hack.
Oh, sorry, but my fix wasn't complete.
I just copied check_devfs() from gpm.c; but it can't be used in
Gpm_Open() that way - because some program linked with libgpm (mc,
links) can be run by user without privileges to open tty0 (e.g. from
xterm or through telnet/ssh, or if one than more users are logged on
console).
AFAIK in case of xterm/non local terminal Gpm_Open() should fail
(return error status), but not call oops() which exits whole program
(leaving terminal in wrong state)...
In case of more than 1 local user Gpm_Open should work - so at least in
Gpm_Open different method of devfs detection should be used (e.g. checking
for presence of /dev/vc directory or /dev/.devfsd file).
I attach new version of patch, where these problems are fixed.
I've just changed open() to stat() - it may be not the best method
(also, I haven't tested it with devfs because I don't use devfs).
--
Jakub Bogusz http://prioris.mini.pw.edu.pl/~qboosh/
PLD Team http://www.pld.org.pl/
--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gpm-checkdevfsbug.patch"
--- gpm-1.19.4.orig/liblow.c Sun May 27 22:53:22 2001
+++ gpm-1.19.4/liblow.c Sun Sep 9 19:49:12 2001
@@ -183,6 +183,31 @@
}
#endif /* SIGTSTP */
+/*
+ * check for devfs
+ */
+
+static int check_devfs( void )
+{
+
+ int fd, retval = GPM_IS_NOTHING;
+ struct stat buf;
+
+ /* first try the devfs device, because in the next time this will be
+ * the preferred one. If that fails, take the old console */
+
+ /* Check for open new console */
+ if ((fd=stat(GPM_DEVFS_CONSOLE, &buf)) == 0)
+ retval = GPM_IS_DEVFS;
+
+ /* Failed, try OLD console */
+ else if((fd=stat(GPM_NO_DEVFS_CONSOLE, &buf)) == 0)
+ retval = GPM_IS_NOT_DEVFS;
+
+ return retval;
+
+}
+
/*-------------------------------------------------------------------*/
int Gpm_Open(Gpm_Connect *conn, int flag)
{
@@ -196,6 +221,7 @@
/* check whether there is a devfs */
+ devfs_id = check_devfs();
switch(devfs_id)
{
@@ -203,8 +229,7 @@
break;
case GPM_IS_NOT_DEVFS: consolename = GPM_NO_DEVFS_CONSOLE; vcname = GPM_NO_DEVFS_VC;
break;
- case GPM_IS_NOTHING: oops("No console to open");
- break;
+ case GPM_IS_NOTHING: return -1;
}
--Kj7319i9nmIyA2yE--