From a137ff9cf74e0e27414a0d0b440ba994d2844cd5 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Sat, 27 Oct 2018 18:48:30 +0100
Subject: [PATCH 14/30] Disable registry lookup unless CONDA_PY_ALLOW_REG_PATHS
 is not 0

---
 PC/getpathp.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/PC/getpathp.c b/PC/getpathp.c
index 53da3a6d05..3fc90067c5 100644
--- a/PC/getpathp.c	2022-03-21 10:40:37.395694838 +0300
+++ b/PC/getpathp.c	2022-03-21 10:40:47.279917400 +0300
@@ -778,13 +778,18 @@
                              const wchar_t *zip_path)
 {
     int skiphome = calculate->home==NULL ? 0 : 1;
-#ifdef Py_ENABLE_SHARED
-    if (!Py_IgnoreEnvironmentFlag) {
-        calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE,
-                                                   skiphome);
+    char * allow_registry_paths = getenv("CONDA_PY_ALLOW_REG_PATHS");
+    if (!Py_IgnoreEnvironmentFlag && allow_registry_paths && allow_registry_paths[0] != '0')
+    {
+        calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);
         calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome);
     }
-#endif
+    else
+    {
+        calculate->machine_path = NULL;
+        calculate->user_path = NULL;
+    }
+
     /* We only use the default relative PYTHONPATH if we haven't
        anything better to use! */
     int skipdefault = (calculate->pythonpath_env != NULL ||
