mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-21 16:33:45 -04:00
Instead of setting LD_LIBRARY_PATH to make the app load the right libraries we run ldconfig to generate a ld.so.cache that we feed to the sandbox as /etc/ld.so.cache. The cache itself is generated by running ldconfig at run time, but for apps we cache the result in $HOME/.var/app/$APPID/.ld.so/cache based on the current app/runtime/extensions commit ids. We also unset LD_LIBRARY_PATH, to ensure any host-side value does not mess with the sandbox. The default ld.so.conf we set (if the runtime has none, or an empty one) is: include /run/flatpak/ld.so.conf.d/*.conf include /app/etc/ld.so.conf /app/lib Additionally all the extension points that have add_ld_path set gets a ld.so.conf snippet in /run/flatpak/ld.so.conf.d. This allows applications and extensions to install their own paths if needed, and if the runtime wants more location they can install a custom ld.so.conf that includes the above. In the flatpak build case we still use LD_LIBRARY_PATH like before, because there is no good key (like the commit ids) for keeping the cache up-to-date. Also, the behaviour is different when building an app for instance. If /app/lib is not in LD_LIBRARY_PATH then the sandbox-wide /etc/ld.so.cache must be updated for a newly installed library to work, but the sandbox is not allowed to update /etc/ld.so.cache. This code was originally written by Valentin David <valentin.david@gmail.com> with changes by Alexander Larsson <alexl@redhat.com>. Closes: #1073 Approved by: alexlarsson