Lines 175-190
selinux_enabled_check (void)
Link Here
|
175 |
/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ |
175 |
/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */ |
176 |
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX |
176 |
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX |
177 |
#include <stdlib.h> |
177 |
#include <stdlib.h> |
|
|
178 |
#include <syslog.h> |
178 |
|
179 |
|
179 |
static int emutramp_enabled = -1; |
180 |
static int emutramp_enabled = -1; |
180 |
|
181 |
|
181 |
static int |
182 |
static int |
182 |
emutramp_enabled_check (void) |
183 |
emutramp_enabled_check (void) |
183 |
{ |
184 |
{ |
184 |
if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL) |
185 |
char *buf = NULL; |
185 |
return 1; |
186 |
size_t len = 0; |
186 |
else |
187 |
FILE *f; |
187 |
return 0; |
188 |
int ret; |
|
|
189 |
f = fopen ("/proc/self/status", "r"); |
190 |
if (f == NULL) |
191 |
{ |
192 |
/* We can't read the needed info from /proc */ |
193 |
syslog (LOG_INFO, "Can't read /proc/self/status"); |
194 |
return 0; |
195 |
} |
196 |
ret = 0; |
197 |
|
198 |
while (getline (&buf, &len, f) != -1) |
199 |
if (!strncmp (buf, "PaX:", 4)) |
200 |
{ |
201 |
char emutramp; |
202 |
if (sscanf (buf, "%*s %*c%c", &emutramp) == 1) |
203 |
ret = (emutramp == 'E'); |
204 |
if (ret == 0) |
205 |
syslog (LOG_INFO, "Emutramp in not enable."); |
206 |
break; |
207 |
} |
208 |
free (buf); |
209 |
fclose (f); |
210 |
return ret; |
188 |
} |
211 |
} |
189 |
|
212 |
|
190 |
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ |
213 |
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \ |
Lines 197-202
emutramp_enabled_check (void)
Link Here
|
197 |
|
220 |
|
198 |
/* Cygwin is Linux-like, but not quite that Linux-like. */ |
221 |
/* Cygwin is Linux-like, but not quite that Linux-like. */ |
199 |
#define is_selinux_enabled() 0 |
222 |
#define is_selinux_enabled() 0 |
|
|
223 |
#define is_emutramp_enabled() 0 |
200 |
|
224 |
|
201 |
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ |
225 |
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ |
202 |
|
226 |
|