I think there is a more interesting hybrid approach that reads the initial binary's library paths, infer and allows access to their directories, while also reading $PATH and allowing access to these directories too. This should make Island automatically compatible with systems such as NixOS, Devbox, or GNU Stow.
BTW, a similar mechanism would be very useful for scripts as well, even if it would be limited to the interpreter and its dependencies and ignoring binaries launched by the script itself. This would not be very useful for shell scripts, but it should be useful for Python or similar interpreted languages. This would be potential future and challenging work per interpreter though.
Originally posted by @l0kod in #1
Island should be able to handle interpreted binaries, such as python, perl, lua, and various shell scripts.
This issue is tied to #1, which handles shared library resolution. While ELF files have symbols marking the required paths to shared libraries, interpreted executables use shebangs to find their interpreter program.
Island fails to handle these currently without bespoke profiles manually adding required files for the interpreter and it's required files (ie python site-packages). Just adding the executable script to the profile alone is insufficient, running
#!/bin/sh
echo Hello, World
Requires rules to add
- /bin/sh (and all shared libraries)
- the script itself
- And /bin/echo (and all shared libraries)
With some smart shebang parsing and heuristics from the invoked arguments, we should be able to get a rough idea of what interpreter (python, bash, etc) is being ran and add the files to the profile at runtime.
For shell scripts, we also should recursively allow the dependencies of all files on the PATH of the shell.
Of course, such an approach isn't perfect (shebangs allow arbitrary invocation commands, making parsing difficult without execution), but this approach could be helpful for many common usecases.
Users should be able to opt out of these features for each interpreter with the no_dependency profile option.
Originally posted by @l0kod in #1
Island should be able to handle interpreted binaries, such as python, perl, lua, and various shell scripts.
This issue is tied to #1, which handles shared library resolution. While ELF files have symbols marking the required paths to shared libraries, interpreted executables use shebangs to find their interpreter program.
Island fails to handle these currently without bespoke profiles manually adding required files for the interpreter and it's required files (ie python site-packages). Just adding the executable script to the profile alone is insufficient, running
Requires rules to add
With some smart shebang parsing and heuristics from the invoked arguments, we should be able to get a rough idea of what interpreter (python, bash, etc) is being ran and add the files to the profile at runtime.
For shell scripts, we also should recursively allow the dependencies of all files on the PATH of the shell.
Of course, such an approach isn't perfect (shebangs allow arbitrary invocation commands, making parsing difficult without execution), but this approach could be helpful for many common usecases.
Users should be able to opt out of these features for each interpreter with the no_dependency profile option.