--- a/src/closures.c 2013-03-17 23:27:11.000000000 +0100 +++ b/src/closures.c 2013-04-28 23:37:30.292535296 +0200 @@ -175,16 +175,39 @@ selinux_enabled_check (void) /* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ #ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX #include +#include static int emutramp_enabled = -1; static int emutramp_enabled_check (void) { - if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL) - return 1; - else - return 0; + char *buf = NULL; + size_t len = 0; + FILE *f; + int ret; + f = fopen("/proc/self/status", "r"); + if (f == NULL) + { + /* We can't read the needed info from /proc */ + syslog (LOG_INFO, "Can't read /proc/self/status"); + return 0; + } + ret = 0; + + while (getline (&buf, &len, f) != -1) + if (!strncmp (buf, "PaX:", 4)) + { + char emutramp; + if (sscanf (buf, "%*s %*c%c", &emutramp) == 1) + ret = (emutramp == 'E'); + if (ret == 0) + syslog (LOG_INFO, "Emutramp in not enable."); + break; + } + free(buf); + fclose (f); + return ret; } #define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ @@ -197,6 +220,7 @@ emutramp_enabled_check (void) /* Cygwin is Linux-like, but not quite that Linux-like. */ #define is_selinux_enabled() 0 +#define is_emutramp_enabled() 0 #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */