libsdl-org / sdl12-compat

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

njam/Wayland: Error initializing SDL: No available video device #247

Closed smcv closed 1 year ago

smcv commented 1 year ago

Prerequisites:

To reproduce:

Expected result: all work

Actual result: with sdl12-compat and Wayland, Error initializing SDL: No available video device

icculus commented 1 year ago

This binary has a setgid bit set on it so it ignores the LD_LIBRARY_PATH environment var, which means it probably picked up classic SDL 1.2, which gives this error message since it doesn't have a video backend named "wayland"

When I removed the setgid bit, it ran with SDL_VIDEODRIVER=wayland without problems.

I've taken to exporting SDL12COMPAT_DEBUG_LOGGING=1, which doesn't do much, but will print a version notice to stderr on startup, which just makes me certain I have the right library and correct build of it.

When you get a moment, please confirm this is the issue, or if I should look further.

smcv commented 1 year ago

Sigh, I'd forgotten how common this meme of "make your game setgid so it can write to a system-wide high score table" used to be. I should probably do some mass-bug-filing in Debian to get people to stop using setgid frivolously - although many of the affected games are essentially unmaintained anyway, so they're unlikely to change any time soon.

I should probably re-test a bunch of the games earlier in the alphabet to make sure they were genuinely using sdl12-compat like I thought they were...

The good news is that if/when we swap from real SDL 1.2 to sdl12-compat as Debian's implementation of the SDL 1.2 ABI (like Fedora and Arch did), we'll no longer be using a custom LD_LIBRARY_PATH, so it won't matter whether the executable is setgid or not.

I confirm that njam works fine with

SDL_VIDEODRIVER=wayland \
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/sdl12-compat \
SDL12COMPAT_DEBUG_LOGGING=1 \
ld.so /usr/games/njam

which bypasses the setgid bit by using ld.so as an interpreter.