So I found out about this through the Phoronix article, so I’m presumably not up to date on the various details, but on the face of it, I have some technical concerns.
If I’m reading this right, this relies on a few things:
- argv[0] containing the invoked name, in order for a symbolic link to resolve. This is unreliable and plain doesn’t work if another symlink is used. A hard link would be better, although would have the same problem if the user creates a hard link.
- It is acceptable to the user/system to search a path, which could be a security problem.
- The overhead of a second exec() would be acceptable.
I can think of at least a few ways this could be done “better”.
- Make /usr/bin an overlay filesystem. The attributes of the running CPU are known at boot time! Upside: completely invisible to the user, should be fast. Downside: global change, and may need some awareness on part of the package manager.
- Create a new binfmt “indirect executable” and handle the indirection in the kernel. This could be as simple as a text file with a magic number pointing to the paths of a set of executables and their requirements. Upside: should be fast. Downside: kernel support needed, could still cause hard link issues unless pathnames are absolute.
- Stub executable. An executable with the appropriate pathnames and requirements compiled in, which uses dlopen() to open the proper executable. Upside: most likely faster than a whole new exec(). Downside: requires PIE executables, could still have hard link issues unless pathnames are absolute.
- Fat executables. The executable is an archive of the actual executables, and ld.so would need to select the appropriate one. Upside: well understood technology; could be done entirely in user space if the fat executable has an appropriate ELF header. Could merge identical sections (e.g. data sections) with a smart enough linker. Downside: has been rejected before in Linux; significant development effort (support in the ELF interpreter ld.so.)
- Relying entirely on the system default $PATH. Upside: trivial to do. Downside: anything that explicitly sanitizes the PATH will most likely lose this information.
- Using filesystem extended attributes to point to alternative binaries. Pretty much a different implementation of #2.
- Add support using filesystem extended attributes to make it possible to do exec() on a directory. Upside: no link issues (directories cannot be hard linked); probably fast. Downside: Al Viro might go ballistic
, might encourage application developers to do NeXT/Mac-style “application code and data directory” hacks.