From 4ebe1fc257fd3ea8c0eed8b8eb2acbb3ef7a0adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 30 Apr 2020 20:19:52 +0100 Subject: [PATCH 1/3] win: allow skipping the supported platform check Fixes: https://github.com/nodejs/node/issues/33034 --- doc/api/cli.md | 8 ++++++++ src/node_main.cc | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 2b42e9a5dbd689..e4cd18cc72f2ce 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1336,6 +1336,14 @@ 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` + + +Skips the check for a supported platform that happens during Node.js startup. +Using this might lead to issues during execution. + ### `NODE_TLS_REJECT_UNAUTHORIZED=value` If `value` equals `'0'`, certificate validation is disabled for TLS connections. diff --git a/src/node_main.cc b/src/node_main.cc index 00f3f2a4836818..d79e8f695e6bb8 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -27,13 +27,19 @@ #include #include +#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK" + 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. if (!IsWindows8Point1OrGreater() && - !(IsWindowsServer() && IsWindows8OrGreater())) { + !(IsWindowsServer() && IsWindows8OrGreater()) && + GetEnvironmentVariableA(SKIP_CHECK_VAR, nullptr, 0) == 0) { fprintf(stderr, "This application is only supported on Windows 8.1, " - "Windows Server 2012 R2, or higher."); + "Windows Server 2012 R2, or higher.\n" + "If the environment varaible " SKIP_CHECK_VAR + " is defined this check is skipped, but Node.js might " + "not execute correctly."); exit(ERROR_EXE_MACHINE_TYPE_MISMATCH); } From 9e2c90f8eaf534ed4bfc3431ccda0fc944cfdcb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 21 May 2020 04:11:46 +0100 Subject: [PATCH 2/3] fixup! win: allow skipping the supported platform check --- doc/api/cli.md | 5 +++-- src/node_main.cc | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index e4cd18cc72f2ce..14015570169bfb 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1341,8 +1341,9 @@ Overriding this value to an empty string (`''`) will use the built-in REPL. added: REPLACEME --> -Skips the check for a supported platform that happens during Node.js startup. -Using this might lead to issues during execution. +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` diff --git a/src/node_main.cc b/src/node_main.cc index d79e8f695e6bb8..e08ae8e5309b20 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -28,18 +28,24 @@ #include #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()) && - GetEnvironmentVariableA(SKIP_CHECK_VAR, nullptr, 0) == 0) { + (GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) != + SKIP_CHECK_SIZE || + strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) { fprintf(stderr, "This application is only supported on Windows 8.1, " - "Windows Server 2012 R2, or higher.\n" - "If the environment varaible " SKIP_CHECK_VAR - " is defined this check is skipped, but Node.js might " - "not execute correctly."); + "Windows Server 2012 R2, or\nhigher.\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); } From 77eb635286ecf87ba7522f2948f11335726785c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 26 May 2020 16:37:29 +0100 Subject: [PATCH 3/3] fixup! win: allow skipping the supported platform check --- doc/node.1 | 7 +++++++ src/node_main.cc | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/node.1 b/doc/node.1 index 278061424c07c6..3af77ca2355030 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -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 , diff --git a/src/node_main.cc b/src/node_main.cc index e08ae8e5309b20..9f4ea22d12c6e8 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -40,8 +40,8 @@ int wmain(int argc, wchar_t* wargv[]) { (GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) != SKIP_CHECK_SIZE || strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) { - fprintf(stderr, "This application is only supported on Windows 8.1, " - "Windows Server 2012 R2, or\nhigher.\n" + 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 "