conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 97 forks source link

Permanently disable LD_PRELOAD of libswmhack.so #586

Closed randoragon closed 4 days ago

randoragon commented 5 days ago

This is a feature request as well as a workaround for those seeking to permanently disable the preloading of libswmhack.so.

Feature request

I find that swmhack often breaks random software. Even if it didn't, I find it unacceptable from a security and principle standpoint that a WM will just force a LD_PRELOAD on you. The man page does not mention a way to disable the preload, aside from unsetting _SWM_WS. But that's not really a solution, because the preload still happens, it just happens to do nothing.

I would like to see something like a spectrwm --no-libswmhack command-line flag to explicitly and indiscriminately disable this behavior altogether.

Workaround for the impatient

The best workaround I found is to overwrite /usr/lib/libswmhack.so.0.0 with an empty shared library. This does not prevent the preload, but it loads an empty file which effectively nullifies the functionality, and gets rid of any errors caused by it.

A simple way to do it:

# Create an empty library
touch empty.c
gcc -shared empty.c -o libswmhack.so.0.0

# Replace swmhack with the empty library (check the paths on your system!)
sudo mv /usr/lib/spectrwm/libswmhack.so.0.0 /usr/lib/spectrwm/libswmhack.so.0.0.original
sudo mv libswmhack.so.0.0 /usr/lib/spectrwm/libswmhack.so.0.0

If your C compiler complains that a translation unit cannot be empty, you can appease it by adding a typedef int _; line or something similarly meaningless.


spectrwm version 3.5.1

LordReg commented 4 days ago

This was addressed in the current relelase (3.6.0). libswmhack/LD_PRELOAD is only applied as required. It is required for the spawn-in-workspace feature, which can now be disabled at the spawn level..

spawn-in-workspace can be disabled for all spawns by placing the following before any autorun entries in the conf:

spawn_flags[.*] += nospawnws
spawn_flags = nospawnws

This sets nospawnws on existing program entries, including the default entries, and sets the default for any program/autorun entries that come later in the conf. When programs are spawned with nospawnws, LD_PRELOAD isn't used.