libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
194 stars 40 forks source link

glhack, GNOME, Wayland: Failed to initialise the SDL library. #236

Closed smcv closed 1 year ago

smcv commented 1 year ago

Prerequisites:

To reproduce:

Expected result: all work

Actual result: with sdl12-compat and SDL_VIDEODRIVER=wayland, it fails with:

** glHack: Failed to initialise the SDL library.

Workaround: use X11.

icculus commented 1 year ago

This is almost certainly my own ignorance, but I could not get this game to run against sdl12-compat with LD_LIBRARY_PATH or LD_PRELOAD and I can't figure out why.

[icculus@taise ~/projects/SDL-1.2/buildbot]$ readelf -d /usr/lib/games/glhack/glhack

Dynamic section at offset 0x1cf7f0 contains 30 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libSDL-1.2.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libGL.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpng16.so.16]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
[...]

I had to replace the system library with sdl12-compat, it just wouldn't let me override it any other way; nothing else has had this problem for me, any idea what would cause it?

(I'll look at the actual issue shortly either way, I'm just baffled by this.)

icculus commented 1 year ago

Ack, it's because /usr/lib/games/glhack/glhack is setuid root!

icculus commented 1 year ago

(I meant setgid, not setuid. See comments in #247 about setgid binaries vs LD_LIBRARY_PATH.)

smcv commented 1 year ago

setgid games, rather than setgid root. Same as https://github.com/libsdl-org/sdl12-compat/issues/247#issuecomment-1276887769

In this case disabling setgid breaks the game ("Cannot lock /var/games/glhack/perm for unknown reason (1)", where 1 is probably EPERM); but if I install libsdl1.2-compat-shim version 1.2.58-1 (which replaces the libSDL-1.2.so.0 in the default library search path with sdl12-compat) then it seems to work fine.

If Debian moves to sdl12-compat as the default (like Fedora and Arch did), it'll be via something more like libsdl1.2-compat-shim: the only reason I'm preferring to use LD_LIBRARY_PATH for this round of testing is that using LD_LIBRARY_PATH lets me compare sdl12-compat vs. classic SDL 1.2, so that when I see an apparent bug I can check whether it's a sdl12-compat regression or a pre-existing bug.