From c4a41cf22604fb8bb66f195aa7780d843418344a 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 09/25] 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 7c0eeab5db..a73ea8a0e9 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -778,13 +778,18 @@ calculate_module_search_path(PyCalculatePath *calculate,
                              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 ||
