Skip to content

Commit

Permalink
win: allow skipping the supported platform check
Browse files Browse the repository at this point in the history
Fixes: #33034

PR-URL: #33176
Reviewed-By: Bartosz Sosnowski <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
joaocgreis authored and codebytere committed Jun 18, 2020
1 parent 0b34c4f commit 0ef6e04
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
9 changes: 9 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,15 @@ added:
Path to a Node.js module which will be loaded in place of the built-in REPL.
Overriding this value to an empty string (`''`) will use the built-in REPL.

### `NODE_SKIP_PLATFORM_CHECK=value`
<!-- YAML
added: REPLACEME
-->

If `value` equals `'1'`, the check for a supported platform is skipped during
Node.js startup. Node.js might not execute correctly. Any issues encountered
on unsupported platforms will not be fixed.

### `NODE_TLS_REJECT_UNAUTHORIZED=value`

If `value` equals `'0'`, certificate validation is disabled for TLS connections.
Expand Down
7 changes: 7 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ The default path is
which is overridden by this variable.
Setting the value to an empty string ("" or " ") will disable persistent REPL history.
.
.It Ev NODE_SKIP_PLATFORM_CHECK
When set to
.Ar 1 ,
the check for a supported platform is skipped during Node.js startup.
Node.js might not execute correctly.
Any issues encountered on unsupported platforms will not be fixed.
.
.It Ev NODE_TLS_REJECT_UNAUTHORIZED
When set to
.Ar 0 ,
Expand Down
18 changes: 15 additions & 3 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@
#include <VersionHelpers.h>
#include <WinError.h>

#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK"
#define SKIP_CHECK_SIZE 1
#define SKIP_CHECK_VALUE "1"

int wmain(int argc, wchar_t* wargv[]) {
// Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
// to run in the experimental support tier.
char buf[SKIP_CHECK_SIZE + 1];
if (!IsWindows8Point1OrGreater() &&
!(IsWindowsServer() && IsWindows8OrGreater())) {
fprintf(stderr, "This application is only supported on Windows 8.1, "
"Windows Server 2012 R2, or higher.");
!(IsWindowsServer() && IsWindows8OrGreater()) &&
(GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) !=
SKIP_CHECK_SIZE ||
strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) {
fprintf(stderr, "Node.js is only supported on Windows 8.1, Windows "
"Server 2012 R2, or higher.\n"
"Setting the " SKIP_CHECK_VAR " environment variable "
"to 1 skips this\ncheck, but Node.js might not execute "
"correctly. Any issues encountered on\nunsupported "
"platforms will not be fixed.");
exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
}

Expand Down

0 comments on commit 0ef6e04

Please sign in to comment.