On Thu, Oct 09, 2008 at 01:14:28AM +0200, Samuel Thibault wrote:
> Just to summarize a few things:

recap - there's more than one client scenario:

        a) w3m, the last I looked, was abusing ncurses interface to
           access gpm in its own way.  I'll keep in mind to not break
           it, but its usage is completely unsupported.

        b) I'm not as familiar with pdmenu source - but reading, seems to
           talk directly to gpm using its documented interface, and to
           be using slang.

        c) aptitude is using ncurses via cwidgets (this might be mine ;-)
 
> - apparently it happens just for clients run in an terminal in X.
> - the server logs previously attached to the bug show
> "Failed gpm connect attempt by uid 1000 for vc /dev/tty0"
> which means that libgpm tried to connect to the gpm server, and failed
> since it didn't know which VT to acquire, thus tried tty0, and failed
> since it probably belongs to root, not to uid 1000.
> 
> I tried to reproduce that, and I noticed something in the strace I could
> get: 
> 
> # the client logs the connection error
> sendto(52, "<14>Oct  9 00:55:37 aptitude: *** info", 39, MSG_NOSIGNAL, NULL, 
> 0) = 39
> sendto(52, "<14>Oct  9 00:55:37 aptitude: Warning: closing connection", 57, 
> MSG_NOSIGNAL, NULL, 0) = 57
> # closes the socket
> close(4)    
> ...
> # and still tries to select it!
> select(5, [0 4], NULL, NULL, {0, 166000}) = -1 EBADF (Bad file descriptor)
> 
> it looks like the caller of libgpm didn't notice that gpm_fd is not
> a valid file descriptor any more.  In the case of aptitude, that's
> ncurses...  Thomas?
> 
> Now, that being said, that reminds me bug #472063: actually libgpm
> shouldn't even have tried to connect to the server, it should have just
> noticed it is running in an X terminal and set gpm_fd to -2...

With the latest update, ncurses won't try to use gpm if $TERM doesn't
contain "linux", unless it's overridden (with a new environment variable).

Before the immediate changes of the past month - ncurses would try to
use gpm - and I agree that it should have failed since I'd expect gpm_fd
to be returned as a negative value.  That check is made in one place in
lib_mouse.c:

        result = (my_Gpm_Open(&SP->_mouse_gpm_connect, 0) >= 0);

I noticed that for some reason it was _not_ failing, when the gpm server was
running, but did not dig into the gpm package (just examined the source code
w/o seeing the problem).  As I recall it, ncurses did both checks because
some previous users insisted that gpm works in xterm.

But that issue prompted me to add the additional restriction, to move
away from gpm a little further.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Attachment: pgp4Qhz2MapUW.pgp
Description: PGP signature

Reply via email to