--- a/src/closures.c 2013-03-17 23:27:11.000000000 +0100 +++ b/src/closures.c 2013-04-19 22:16:53.030220812 +0200 @@ -175,16 +175,40 @@ 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 +#define LINE_BUFFER 1024 static int emutramp_enabled = -1; static int emutramp_enabled_check (void) { - if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL) - return 1; - else + if (getenv ("FFI_DISABLE_EMUTRAMP") != NULL) return 0; + FILE *f; + char first[LINE_BUFFER], second[LINE_BUFFER]; + char conf_line[LINE_BUFFER]; + f = fopen("/proc/self/status", "r"); + if (f == NULL) + { + /* We can't read the needed info from /proc */ + /* So log it and make may day. */ + syslog (LOG_INFO, "Can't read /proc/self/status"); + return 0; + } + while (fgets (conf_line, LINE_BUFFER, f) ) + { + sscanf (conf_line, "%s %s", first, second ); + if( !strcmp (first, "PaX:" ) ) + { + if( second[1] != 'E' ) + syslog (LOG_INFO, "Emutramp in not enable."); + fclose (f); + return 1; + } + } + fclose (f); + return 0; } #define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ @@ -197,6 +221,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) */