Mic92 / envfs

Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process.
249 stars 5 forks source link

Resolve the target for all syscalls when ENVFS_RESOLVE_ALWAYS is defined #36

Closed wentasah closed 2 years ago

wentasah commented 3 years ago

Some projects not only have shebangs pointing to /usr/bin, but also check for interpreter presence in /usr/bin before running the scripts with the "wrong" shebangs. For such projects it is useful to have a way to force envfs to resolve the symlinks for all system calls and not only for the execve syscall. This commits adds exactly this. When the requesting process has ENVFS_RESOLVE_ALWAYS environment variable set, the symlinks are always resolved. This can be demonstrated with the following examples:

$ /usr/bin/bash -c 'echo Hello' # execve() always works
Hello
$ ls -l /usr/bin/bash
ls: cannot access '/usr/bin/bash': No such file or directory
$ ENVFS_RESOLVE_ALWAYS=1 ls -l /usr/bin/bash
lr----x--t 1 root root 0 Jan  1  1970 /usr/bin/bash -> /run/current-system/sw/bin/bash

This is related to my questions in #35. I've not updated the README yet. If agreed, I can update it with the above example (or similar).

Mic92 commented 2 years ago

Thanks for the PR! Sorry that it took me ages to get around merging it.