Skip to content

Bring back rpaths, it's okay to use them if you're careful. #15612

@o11c

Description

@o11c

Let me start off by saying, any time that LD_LIBRARY_PATH must be used is a bug. Not just a user experience bug, but an absolute bug. The sole purpose of LD_LIBRARY_PATH is for local administrators to override the default for debugging or something, it must never be used by upstream or by distro, in any package. Never, ever, ever.

Now, looking at distro policies:

  • All setuid/setgid/setcap executables must have no relative rpaths, because the executable may be hard-linked to load arbitrary code.
  • There must not be absolute rpaths to the build directory after installation (relative rpaths are okay, subject to the previous rule), because unprivileged users can write to the build directory to load.
  • The standard directories, (/lib/, /lib64/, /usr/lib/, and /usr/lib64/), must never be specified in an rpath. (Note, however, that if you install a library to the standard paths, you must run ldconfig afterward)
  • It is possible to extend the list of standard directories by adding a file to /etc/ld.so.conf.d/, but this is the job of the distro, not upstream.
  • If a library is installed outside the standard directories (either because it is private, or because it is being installed as an unprivileged user), you must emit an rpath.
  • Rust can avoid the problem of .so version changes in basic library packages such as libc, simply by including the SONAME of all the system libraries in the hash (this doesn't strictly need to be done now, only if such a change happens, and could be pushed to the distros problem (there probably should be a way to specify that anyway), but it shouldn't be hard so it might as well be done now so that an answer can be given to distros who ask).

Finally, a brief mention of Windows. Prior discussion has claimed that Windows does not support rpaths, but this is missing one criticial thing: Windows binaries have a hard-coded rpath of ., because each binaries bundling its own libraries has been the normal route, not the exception.

The result of misunderstanding the implications of rpath has been much breakage, and telling users to use environment variables that are only intended for debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions