diff options
author | patr0nus <dk4rest@gmail.com> | 2020-06-18 17:41:56 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-06-25 20:56:34 +0300 |
commit | cb2c8106a7aced1a226eba468e27ac75b2ee8bfc (patch) | |
tree | 5c5d287952ea8cef84e29640503e99404d2ae5f5 /src/node.cc | |
parent | 56124e92e8948d72d21e1aeeaab32b5cb403ed32 (diff) |
src: tolerate EPERM returned from tcsetattr
macOS app sandbox makes tcsetattr return EPERM. The CHECK_EQ(0, err)
here would fail when a sandboxed Node.js process is exiting. This commit
fixes this issue.
* test: add test for running in macOS app sandbox
Bare-bone command-line executables cannot run directly in the app sandbox.
To test that Node.js is able to run in the sandbox (and to test the fix in
317621b4a12562eb75055a67bb2c5556f53fe017), this commit creates a typical
Cocoa app bundle, puts the node executable in it and calles Apple's codesign
command to enable sandbox.
* test: use process.execPath to get path of testing node
PR-URL: https://github.com/nodejs/node/pull/33944
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node.cc')
-rw-r--r-- | src/node.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc index b83e888ab3c..d30de83e94f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -730,7 +730,10 @@ void ResetStdio() { err = tcsetattr(fd, TCSANOW, &s.termios); while (err == -1 && errno == EINTR); // NOLINT CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sa, nullptr)); - CHECK_EQ(0, err); + + // Normally we expect err == 0. But if macOS App Sandbox is enabled, + // tcsetattr will fail with err == -1 and errno == EPERM. + CHECK_IMPLIES(err != 0, err == -1 && errno == EPERM); } } #endif // __POSIX__ |