summaryrefslogtreecommitdiff
path: root/dev-python/cffi/files
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/cffi/files')
-rw-r--r--dev-python/cffi/files/cffi-1.1.0-test-backport.patch44
-rw-r--r--dev-python/cffi/files/issue177_prot_exec.patch79
2 files changed, 123 insertions, 0 deletions
diff --git a/dev-python/cffi/files/cffi-1.1.0-test-backport.patch b/dev-python/cffi/files/cffi-1.1.0-test-backport.patch
new file mode 100644
index 000000000000..2609e333991e
--- /dev/null
+++ b/dev-python/cffi/files/cffi-1.1.0-test-backport.patch
@@ -0,0 +1,44 @@
+# HG changeset patch
+# User Armin Rigo <arigo@tunes.org>
+# Date 1433182838 -7200
+# Node ID 34d5fd98bc84d202dd6692906f21509bb5abefaf
+# Parent feea0af4a450e0ff0045f1b7c0a5f430c97520f9
+Issue #204: second try
+
+diff --git a/testing/cffi1/test_zdist.py b/testing/cffi1/test_zdist.py
+--- a/testing/cffi1/test_zdist.py
++++ b/testing/cffi1/test_zdist.py
+@@ -29,13 +29,17 @@
+ if hasattr(self, 'saved_cwd'):
+ os.chdir(self.saved_cwd)
+
+- def run(self, args):
++ def run(self, args, cwd=None):
+ env = os.environ.copy()
+- newpath = self.rootdir
+- if 'PYTHONPATH' in env:
+- newpath += os.pathsep + env['PYTHONPATH']
+- env['PYTHONPATH'] = newpath
+- subprocess.check_call([self.executable] + args, env=env)
++ # a horrible hack to prevent distutils from finding ~/.pydistutils.cfg
++ # (there is the --no-user-cfg option, but not in Python 2.6...)
++ env['HOME'] = '/this/path/does/not/exist'
++ if cwd is None:
++ newpath = self.rootdir
++ if 'PYTHONPATH' in env:
++ newpath += os.pathsep + env['PYTHONPATH']
++ env['PYTHONPATH'] = newpath
++ subprocess.check_call([self.executable] + args, cwd=cwd, env=env)
+
+ def _prepare_setuptools(self):
+ if hasattr(TestDist, '_setuptools_ready'):
+@@ -44,8 +48,7 @@
+ import setuptools
+ except ImportError:
+ py.test.skip("setuptools not found")
+- subprocess.check_call([self.executable, 'setup.py', 'egg_info'],
+- cwd=self.rootdir)
++ self.run(['setup.py', 'egg_info'], cwd=self.rootdir)
+ TestDist._setuptools_ready = True
+
+ def check_produced_files(self, content, curdir=None):
diff --git a/dev-python/cffi/files/issue177_prot_exec.patch b/dev-python/cffi/files/issue177_prot_exec.patch
new file mode 100644
index 000000000000..8dbcf07c0052
--- /dev/null
+++ b/dev-python/cffi/files/issue177_prot_exec.patch
@@ -0,0 +1,79 @@
+# HG changeset patch
+# User Armin Rigo <arigo@tunes.org>
+# Date 1424942568 -3600
+# Node ID c7edb1e84eb3c29cac0674790cb4efcbcf1683b2
+# Parent 95e0563201602a2e1a8d83cc95a6a70048dfeece
+issue #177: workaround for some Linux kernels
+
+diff --git a/c/malloc_closure.h b/c/malloc_closure.h
+--- a/c/malloc_closure.h
++++ b/c/malloc_closure.h
+@@ -14,6 +14,54 @@
+ # endif
+ #endif
+
++/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
++
++ This is, apparently, an undocumented change to ffi_prep_closure():
++ depending on the Linux kernel we're running on, we must give it a
++ mmap that is either PROT_READ|PROT_WRITE|PROT_EXEC or only
++ PROT_READ|PROT_WRITE. In the latter case, just trying to obtain a
++ mmap with PROT_READ|PROT_WRITE|PROT_EXEC would kill our process(!),
++ but in that situation libffi is fine with only PROT_READ|PROT_WRITE.
++ There is nothing in the libffi API to know that, though, so we have
++ to guess by parsing /proc/self/status. "Meh."
++ */
++#ifdef __linux__
++#include <stdlib.h>
++
++static int emutramp_enabled = -1;
++
++static int
++emutramp_enabled_check (void)
++{
++ char *buf = NULL;
++ size_t len = 0;
++ FILE *f;
++ int ret;
++ f = fopen ("/proc/self/status", "r");
++ if (f == NULL)
++ 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');
++ break;
++ }
++ free (buf);
++ fclose (f);
++ return ret;
++}
++
++#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
++ : (emutramp_enabled = emutramp_enabled_check ()))
++#else
++#define is_emutramp_enabled() 0
++#endif
++
++
+ /* 'allocate_num_pages' is dynamically adjusted starting from one
+ page. It grows by a factor of PAGE_ALLOCATION_GROWTH_RATE. This is
+ meant to handle both the common case of not needing a lot of pages,
+@@ -77,9 +125,12 @@
+ if (item == NULL)
+ return;
+ #else
++ int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
++ if (is_emutramp_enabled ())
++ prot &= ~PROT_EXEC;
+ item = (union mmaped_block *)mmap(NULL,
+ allocate_num_pages * _pagesize,
+- PROT_READ | PROT_WRITE | PROT_EXEC,
++ prot,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ -1,
+ 0);