-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
launch middleman process on macOS to workaround SIP limit #416
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TingluoHuang !
This looks like it would solve our problem assuming WellKnownDirectory.Externals
is outside /usr
, which is true on the current actions VMs.
// launch `node macOSRunInvoker.js shell args` instead of `shell args` to avoid macOS SIP remove `DYLD_INSERT_LIBRARIES` when launch process | ||
string node12 = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), "node12", "bin", $"node{IOUtil.ExeExtension}"); | ||
string macOSRunInvoker = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "macOSRunInvoker.js"); | ||
arguments = $"\"{macOSRunInvoker.Replace("\"", "\\\"")}\" \"{fileName.Replace("\"", "\\\"")}\" {arguments}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace("\"", "\\\"")
is not enough to escape an arbitrary string for the command line. For a unix-like OS, I think you should at least also escape \
, $
and ` .
Isn't there a utility function somewhere for escaping an argument string in an OS specific way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to escape those since those are special character for bash/sh, the runner launch process directly, so we only need to worry about "
and
(space).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we pass the command line using an environment variable instead? Then we avoid escaping complexity
INPUT_FILENAME
AND INPUT_ARGS
And delete the env vars (delete process.env.INPUT_FILENAME
etc) before launching the child process from node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I see you have _proc.StartInfo.UseShellExecute = false
in ProcessInvoker.cs
.
In that case you probably still need to worry about \
. Otherwise an argument containing \"
(a backslash and a quote) might cause some trouble. After the Replace
you'd end-up with \\"
, which I think would be interpreted as an escaped backslash and an unescaped "
.
Wouldn't it be easier to use ProcessStartInfo.ArgumentList
instead of ProcessStartInfo.Arguments
? That looks more convenient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to be in a business of parse customer's arg string into arg array. :)
d9a08df
to
39bc519
Compare
13e78bd
to
ff2b794
Compare
We do not need to prefix `$CODEQL_RUNNER` here on macOS to bypass SIP, because we assume that the `init` step exported `DYLD_INSERT_LIBRARIES` into the environment, which activates the Actions workaround for SIP. See actions/runner#416.
We do not need to prefix `$CODEQL_RUNNER` here on macOS to bypass SIP, because we assume that the `init` step exported `DYLD_INSERT_LIBRARIES` into the environment, which activates the Actions workaround for SIP. See actions/runner#416.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fix the malfunction so stop bullying people
When
DYLD_INSERT_LIBRARIES
set on macOS, SIP will remove it when launch process that under/usr/bin
, ex:bash
We will use
node
as a proxy process on macOS whenDYLD_INSERT_LIBRARIES
is set to executeruns
script.More detail:
https://github.com/github/c2c-actions-runtime/issues/447