[Apple] Disable environment access on Apple platforms that are not OSX.
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 9 Oct 2015 19:54:48 +0000 (15:54 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 9 Oct 2015 19:55:03 +0000 (15:55 -0400)
The two known ways to access the environment variables are no longer allowed Apple.

Until something blessed by them is found, we'll provide no way to list all the envvars
of the current process.

eglib/src/gspawn.c
mono/io-layer/processes.c
mono/metadata/icall.c

index 4d0bf9e8eca919c44d609095fef62b01ada0f9a9..01639be101fb1d18e57f6dc74b94c7630bf30aed 100644 (file)
 #define NO_INTR(var,cmd) do { (var) = (cmd); } while ((var) == -1 && errno == EINTR)
 #define CLOSE_PIPE(p) do { close (p [0]); close (p [1]); } while (0)
 
-#if defined(__APPLE__) && !defined (__arm__) && !defined (__aarch64__)
+#if defined(__APPLE__)
+#if defined (TARGET_OSX)
 /* Apple defines this in crt_externs.h but doesn't provide that header for 
  * arm-apple-darwin9.  We'll manually define the symbol on Apple as it does
  * in fact exist on all implementations (so far) 
  */
-gchar ***_NSGetEnviron();
+gchar ***_NSGetEnviron(void);
 #define environ (*_NSGetEnviron())
+#else
+static char *mono_environ[1] = { NULL };
+#define environ mono_environ
+#endif /* defined (TARGET_OSX) */
 #elif defined(_MSC_VER)
 /* MS defines this in stdlib.h */
 #else
index df101ae76a42d42424b56a21f47a2c1f2fb93566..94938f53704a8d4213ef0bd118ba658488cc124c 100644 (file)
 #include <mono/utils/mono-proclib.h>
 
 /* The process' environment strings */
-#if defined(__APPLE__) && !defined (__arm__) && !defined (__aarch64__)
+#if defined(__APPLE__)
+#if defined (TARGET_OSX)
 /* Apple defines this in crt_externs.h but doesn't provide that header for 
  * arm-apple-darwin9.  We'll manually define the symbol on Apple as it does
  * in fact exist on all implementations (so far) 
  */
-char ***_NSGetEnviron(void);
+gchar ***_NSGetEnviron(void);
 #define environ (*_NSGetEnviron())
 #else
+static char *mono_environ[1] = { NULL };
+#define environ mono_environ
+#endif /* defined (TARGET_OSX) */
+#else
 extern char **environ;
 #endif
 
index e47f958817170c1c735f20615cdd3d391d5a78a4..e937e437c0400e44f43100b761692d19705b37fa 100644 (file)
@@ -5846,7 +5846,8 @@ ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
  */
 #ifndef _MSC_VER
 #ifndef __MINGW32_VERSION
-#if defined(__APPLE__) && !defined (__arm__) && !defined (__aarch64__)
+#if defined(__APPLE__)
+#if defined (TARGET_OSX)
 /* Apple defines this in crt_externs.h but doesn't provide that header for 
  * arm-apple-darwin9.  We'll manually define the symbol on Apple as it does
  * in fact exist on all implementations (so far) 
@@ -5854,6 +5855,10 @@ ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
 gchar ***_NSGetEnviron(void);
 #define environ (*_NSGetEnviron())
 #else
+static char *mono_environ[1] = { NULL };
+#define environ mono_environ
+#endif /* defined (TARGET_OSX) */
+#else
 extern
 char **environ;
 #endif