I don't know, if what I'm saying is off-topic.
I'm sure it's not off-topic, but I'm not sure it's right.
Doctrine has it that if you're running with elevated privilege or are using POSIX capabilities (e.g. to bypass all filesystem ownership checks) then you do the dirty work as early as possible and then relinquish those additional rights. In the case of Lazarus I think that means putting the relevant code in the .lpi file.
If you mark a gtk2 program setuid root and try to start it it objects before any of the application code gets a chance to run:
$ sudo chmod +s ./x2741-x86_64-linux-gtk2
$ ./x2741-x86_64-linux-gtk2
(process:24046): Gtk-WARNING **: 09:29:31.890: This process is currently running setuid or setgid.
This is not a supported use of GTK+. You must create a helper
program instead. For further details, see:
http://www.gtk.org/setuid.html
Refusing to initialize GTK+.
I think I spotted that in about 2013, Qt is more tolerant. I'll check, but I think that GTK barfed before anything in the .lpi file was run.
That behaviour provides a strong incentive to investing time in the arcana of POSIX capabilities, but since manipulating them requires root privilege it looks as though it can't be done easily from inside the IDE.
There is one way which might /possibly/ work, and that would be if the final linker stage could be persuaded to overwrite an existing file rather than creating a new one which /might/ inherit the same extended attributes.
MarkMLl