X authorization bug

SDL boffins -

docs.html of SDL tarball says:
Please send bug reports or questions to the SDL mailing list:
http://www.libsdl.org/mailing-list.php

I’m using Gentoo Linux, kernel 2.6.8-rc2, single AMD Athlon XP, and SDL-1.2.7.

User “root” on my machine does not have X authorization.
If I forget to run “xhost +” before running an SDL application
as root, the screen goes blank and keyboard input (including
ctl-alt-del and ctl-alt-bkspc) is ignored. The only way out is
hardware reset or power off/on.

A crude workaround to fix this complaint is:

— src/video/x11/SDL_x11video.c.orig 2004-02-18 19:22:09.000000000 +0200
+++ src/video/x11/SDL_x11video.c 2004-07-22 08:45:59.926688576 +0200
@@ -94,6 +94,7 @@
display = XOpenDisplay(NULL);
if ( display != NULL ) {
XCloseDisplay(display);

  •           exit;
      }
      return(display != NULL);
    

}

After a full rebuild of SDL with this change in place:

asterix:test> pwd
/home/bobb/SDL-1.2.7/test
asterix:test> id
uid=0(root) gid=0(root)
asterix:test> ./testwm
Xlib: connection to “:0.0” refused by server
Xlib: No protocol specified

Xlib: connection to “:0.0” refused by server
Xlib: No protocol specified

Couldn’t initialize SDL: No available video device
asterix:test>

Behavior is the same if the patch uses “_exit” instead of “exit”.

This still isn’t quite what I’d expect. A typical X utility gives:

asterix:test> /usr/X11R6/bin/xdpyinfo
Xlib: connection to “:0.0” refused by server
Xlib: No protocol specified

/usr/X11R6/bin/xdpyinfo: unable to open display “:0.0”.
asterix:test>

The X utility shows one pair of X error messages, while
the SDL utility shows two pair.

Can someone give me a clean and thorough fix for this,
so that applications using libsdl exit gracefully if the user
does not have X authorization, without additional X test
code in the application?

Thanks,

Bob Barry

Bob Barry wrote:

SDL boffins -

docs.html of SDL tarball says:
Please send bug reports or questions to the SDL mailing list:
http://www.libsdl.org/mailing-list.php

I’m using Gentoo Linux, kernel 2.6.8-rc2, single AMD Athlon XP, and SDL-1.2.7.

User “root” on my machine does not have X authorization.
If I forget to run “xhost +” before running an SDL application
as root, the screen goes blank and keyboard input (including
ctl-alt-del and ctl-alt-bkspc) is ignored. The only way out is
hardware reset or power off/on.

A crude workaround to fix this complaint is:

— src/video/x11/SDL_x11video.c.orig 2004-02-18 19:22:09.000000000 +0200
+++ src/video/x11/SDL_x11video.c 2004-07-22 08:45:59.926688576 +0200
@@ -94,6 +94,7 @@
display = XOpenDisplay(NULL);
if ( display != NULL ) {
XCloseDisplay(display);

  •           exit;
     }
     return(display != NULL);
    

}

May I ask what you expect from this “exit” statement ?
Maybe you meant exit() but that’s not the same. As is, that statement
does nothing.

Stephane

Stephane -On Thu, 29 Jul 2004 20:56 you wrote:

May I ask what you expect from this “exit” statement ?
Maybe you meant exit() but that’s not the same.

You’re right; too much shell programming. But diff of the
last attempt used “_exit(1)”, and the behaviour was as stated.

asterix:x11> diff -ruN SDL_x11video.c.orig SDL_x11video.c
--- SDL_x11video.c.orig 2004-02-18 19:22:09.000000000 +0200
+++ SDL_x11video.c      2004-07-23 10:31:54.000000000 +0200
@@ -94,6 +94,7 @@
        display = XOpenDisplay(NULL);
        if ( display != NULL ) {
                XCloseDisplay(display);
+               _exit(1);
        }
        return(display != NULL);
 }

Thanks,

Bob Barry

Bob Barry wrote:

Stephane -

May I ask what you expect from this “exit” statement ?
Maybe you meant exit() but that’s not the same.

You’re right; too much shell programming. But diff of the
last attempt used “_exit(1)”, and the behaviour was as stated.

Ok, so that will make the whole program exit when it finds it can
correctly initalize the x11 backend.
Can you still use “normal” SDL programs with this patch ?

Stephane>On Thu, 29 Jul 2004 20:56 you wrote:

I’m using Gentoo Linux, kernel 2.6.8-rc2, single AMD Athlon XP, and SDL-1.2.7.

User “root” on my machine does not have X authorization.
If I forget to run “xhost +” before running an SDL application
as root, the screen goes blank and keyboard input (including
ctl-alt-del and ctl-alt-bkspc) is ignored. The only way out is
hardware reset or power off/on.

It sounds like SDL is successfully opening the framebuffer device with X11
still active. Is that what’s happening?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment