From 3f30ea68c7a7629c557bf7850f0520902a4421e1 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 17/22] Disable registry lookup unless CONDA_PY_ALLOW_REG_PATHS
 is not 0

---
 PC/getpathp.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/PC/getpathp.c b/PC/getpathp.c
index dc4e43fe7d..65f38f3884 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -782,9 +782,19 @@ calculate_module_search_path(const _PyCoreConfig *core_config,
 {
     int skiphome = calculate->home==NULL ? 0 : 1;
 #ifdef Py_ENABLE_SHARED
-    calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);
-    calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome);
+    char * allow_registry_paths = getenv("CONDA_PY_ALLOW_REG_PATHS");
+    if (allow_registry_paths && allow_registry_paths[0] != '0')
+    {
+        calculate->machine_path = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);
+        calculate->user_path = getpythonregpath(HKEY_CURRENT_USER, skiphome);
+    }
+    else
+    {
+        calculate->machine_path = NULL;
+        calculate->user_path = NULL;
+    }
 #endif
+
     /* We only use the default relative PYTHONPATH if we haven't
        anything better to use! */
     int skipdefault = (core_config->module_search_path_env != NULL ||
-- 
2.23.0

