From e20b217e7edf70f64a8c07701465c458e927d6f2 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 16/18] 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 1b553d53af..93f1cf087e 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -774,9 +774,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.17.2 (Apple Git-113)

