Bug 385930 - kwin_* binaries when setcap'ed lose $LD_LIBRARY_PATH
Summary: kwin_* binaries when setcap'ed lose $LD_LIBRARY_PATH
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-19 00:45 UTC by bluescreenavenger
Modified: 2018-04-20 00:55 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bluescreenavenger 2017-10-19 00:45:17 UTC
Hi

When testing running kwin_wayland after running
setcap cap_sys_nice=eip /opt/bin/kwin_wayland
on my self-built kwin, it seems that $LD_LIBRARY_PATH is lost.

This seems to be similar to what happens running a setuid binary

It seems that the rpath might have to be set on the binaries themselves, so they can find the libraries

...unfortunately I also think that $PATH is lost


Thanks
Comment 1 Martin Flöser 2017-10-19 15:29:02 UTC
This is expected. All LD_* variables are ignored when an executable with capabilities is launched.
Comment 2 bluescreenavenger 2017-10-19 23:48:40 UTC
Could the RPATH attribute be set on the kwin_* binaries so they can run without the LD_LIBRARY_PATH having to be set?
Comment 3 Martin Flöser 2017-10-20 04:16:54 UTC
I have KWin compiled into a non standard path. Everything works fine. So it is possible.
Comment 4 bluescreenavenger 2017-10-20 12:13:55 UTC
I'll have to look at my configuration maybe... 
My Kwin cmake line is
cmake -Wno-dev .. -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DCMAKE_PREFIX_PATH=$INSTALLDIR  -DCMAKE_BUILD_TYPE=Release 

...and the libraries are installed in /opt/lib/(i386-linux-gnu|x86_64-linux-gnu)
I do specify some things to be installed there, mostly Frameworks, but I'm not sure how that was automatically inherited... 

I also don't have anything /opt in /etc/environment or my ld.conf
Comment 5 Martin Flöser 2017-10-20 13:00:54 UTC
I guess it's some RPATH setting. I know that I haven't used LD_LIBRARY_PATH for years and rpath was just being used by default.
Comment 6 bluescreenavenger 2017-10-21 04:48:57 UTC
Maybe I need a cmake argument, objdump and readelf seen to imply there's not RPATH set
Comment 7 bluescreenavenger 2018-01-02 04:05:04 UTC
OK... I made some tweaks, and set kwin's RPATH... ...it looks like RPATHs are not handled recursively though, so for every kf5 library, I might need to add 
-DCMAKE_INSTALL_RPATH=/opt/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)
Comment 8 bluescreenavenger 2018-04-20 00:55:17 UTC
I have tried again, to no avail... I wonder if I am doing something wrong. I have no Qt5 under /usr, only the one and Frameworks I built in /opt

This is what I tried to change for Kwin's cmake options (where $INSTALLDIR=/opt)
cmake -Wno-dev .. -DCMAKE_INSTALL_PREFIX=$INSTALLDIR -DCMAKE_PREFIX_PATH=$INSTALLDIR  -DCMAKE_BUILD_TYPE=Release  -DCMAKE_INSTALL_RPATH=$INSTALLDIR/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) -DCMAKE_SKIP_BUILD_RPATH=FALSE -DLIB_INSTALL_DIR=$INSTALLDIR/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)