From c21578df40e65e5d5de2c2280c603c5d9dce1bb2 Mon Sep 17 00:00:00 2001 From: benoitc Date: Sun, 6 Mar 2011 10:14:52 +0100 Subject: [PATCH] ctypes triggers selinux execmem denial https://bugzilla.redhat.com/show_bug.cgi?id=488396 fix issue #168. Thanks! --- gunicorn/util.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gunicorn/util.py b/gunicorn/util.py index 9bf29dc8..bd63f9e0 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -4,7 +4,13 @@ # See the NOTICE for more information. -import ctypes +try: + import ctypes +except MemoryError: + # selinux execmem denial + # https://bugzilla.redhat.com/show_bug.cgi?id=488396 + ctypes = None + import fcntl import os import pkg_resources @@ -87,6 +93,8 @@ def set_owner_process(uid,gid): try: os.setgid(gid) except OverflowError: + if not ctypes: + raise # versions of python < 2.6.2 don't manage unsigned int for # groups like on osx or fedora os.setgid(-ctypes.c_int(-gid).value) @@ -98,6 +106,8 @@ def chown(path, uid, gid): try: os.chown(path, uid, gid) except OverflowError: + if not ctypes: + raise os.chown(path, uid, -ctypes.c_int(-gid).value)