The way we sidestep SIP on vscode is to get the executable from the launch configuration - pass it to the mirrord CLI, and replace the executable in the config with a path to the patched executable.
Since each configuration type puts the executable in a different configuration field, we need to individually add support for each configuration type.
With this new type, node-terminal, it's a tiny bit more complicated then in all other cases so far, because there is no field that holds just the executable. There is a command field, that holds a command line that is probably passed as an argument to sh/bash/whatever. This leads to 2 slight complications:
We don't just replace the whole field, we need to replace just the executable out of the line.
Since vscode calls something like sh -c <command>, and there is no field in the configuration that controls that sh/bash/whatever, we cannot replace it with a patched binary. Since bash is SIP, DYLD_INSERT_LIBRARIES is silently stripped away from the env. So to get around that challenge, we prepend that env var to the command line, and then the layer is loaded to the potentially SIP-patched binary.
This means that if the user sets the command field of the launch configuration to be "npm run dotenv-cli", we change it to something like DYLD_INSERT_LIBRARIES=/tmp/14438233328252234237-libmirrord_layer.dylib /var/folders/4l/810mmn597cx7zy5w2bk11clh0000gn/T/mirrord-bin/opt/homebrew/bin/npm run dotenv-cli.
Closes #26
The way we sidestep SIP on vscode is to get the executable from the launch configuration - pass it to the mirrord CLI, and replace the executable in the config with a path to the patched executable. Since each configuration type puts the executable in a different configuration field, we need to individually add support for each configuration type.
With this new type,
node-terminal
, it's a tiny bit more complicated then in all other cases so far, because there is no field that holds just the executable. There is acommand
field, that holds a command line that is probably passed as an argument tosh
/bash
/whatever. This leads to 2 slight complications:sh -c <command>
, and there is no field in the configuration that controls thatsh
/bash
/whatever, we cannot replace it with a patched binary. Since bash is SIP,DYLD_INSERT_LIBRARIES
is silently stripped away from the env. So to get around that challenge, we prepend that env var to the command line, and then the layer is loaded to the potentially SIP-patched binary.This means that if the user sets the
command
field of the launch configuration to be"npm run dotenv-cli"
, we change it to something likeDYLD_INSERT_LIBRARIES=/tmp/14438233328252234237-libmirrord_layer.dylib /var/folders/4l/810mmn597cx7zy5w2bk11clh0000gn/T/mirrord-bin/opt/homebrew/bin/npm run dotenv-cli
.