From c251fce9a7d00baf95f3e79abcf9f7fe5a36fe3e 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 15/15] 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 461f9fc545..fba70cb905 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -467,6 +467,7 @@ calculate_path(void)
     size_t bufsz;
     char *pythonhome = Py_GetPythonHome();
     char *envpath = Py_GETENV("PYTHONPATH");
+    char * allow_registry_paths = NULL;
 
 #ifdef MS_WINDOWS
     int skiphome, skipdefault;
@@ -512,8 +513,17 @@ calculate_path(void)
 
     skiphome = pythonhome==NULL ? 0 : 1;
 #ifdef Py_ENABLE_SHARED
-    machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);
-    userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome);
+    allow_registry_paths = getenv("CONDA_PY_ALLOW_REG_PATHS");
+    if (allow_registry_paths && allow_registry_paths[0] != '0')
+    {
+        machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome);
+        userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome);
+    }
+    else
+    {
+        machinepath = NULL;
+        userpath = NULL;
+    }
 #endif
     /* We only use the default relative PYTHONPATH if we havent
        anything better to use! */
-- 
2.19.1

