From 40514ca2eb01ebe10b0754d7481d3eba23f80547 Mon Sep 17 00:00:00 2001 From: benoitc Date: Sun, 21 Feb 2010 11:06:43 +0100 Subject: [PATCH] versions of python < 2.6.2 don't manage unsigned int for groups like on osx or fedora s Please enter the commit message for your changes. Lines starting --- gunicorn/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gunicorn/main.py b/gunicorn/main.py index b92a9c46..0c178215 100644 --- a/gunicorn/main.py +++ b/gunicorn/main.py @@ -3,7 +3,7 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. - +import ctypes import grp import logging import optparse as op @@ -106,7 +106,13 @@ def set_owner_process(user,group): gid = int(group) else: gid = grp.getgrnam(group).gr_gid + + try: os.setgid(gid) + except OverflowError: + # 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) if user: if user.isdigit() or isinstance(user, int): uid = int(user)