> For now, the best way to make this work is to change one of the
> SELinux booleans (do not disable SELinux entirely).  As root, do
>
>   # setsebool -P httpd_tmp_exec 1


Another more secure option, if all you need is to generate a uuid and you
don't need to use ctypes for anything else, is to generate an
RFC 4122-compliant random uuid as follows.  This allows you to omit
importing the python uuid module, which in turn imports ctypes.

(This works because SELinux allows reading from /dev/urandom under
the default policy rules)


def make_random_uuid():
    bytes = open('/dev/urandom','rb').read(16)
    num = long(('%02x'*16) % tuple(map(ord, bytes)), 16)
    # Set the variant to RFC 4122.
    num &= ~(0xc000 << 48L)
    num |= 0x8000 << 48L
    # Set the version number (4 = random uuid).
    num &= ~(0xf000 << 64L)
    num |= 4 << 76L
    # Convert to hex-string format
    hex = '%032x' % num
    return '%s-%s-%s-%s-%s' % (
        hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])

-- 
Deron Meranda
http://deron.meranda.us/

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to