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)