ext-sources/ucredtest.py
author laca
Wed, 09 Apr 2008 23:44:03 +0000
changeset 12074 9b55b0eb183a
child 17113 9566f46ad3bb
permissions -rw-r--r--
2008-04-10 Laszlo (Laca) Peter <[email protected]> * SUNWPython.spec: add patch ucred.diff that implement the ucred python module as per 2008/243. Written by [email protected]. * ext-sources/ucredtest.py: (new) test script for the ucred module * patches/Python-10-ucred.diff: (new) Python ucred module. * closed/SUNWapoc.spec: add copyright file * copyright/SUNWapoc.copyright: new.

#!/usr/bin/python

import ucred
import os

uc = ucred.get(os.getpid())

print "pid = %d" % uc.getpid()
print "euid = %d" % uc.geteuid()
print "ruid = %d" % uc.getruid()
print "suid = %d" % uc.getsuid()
print "egid = %d" % uc.getegid()
print "rgid = %d" % uc.getrgid()
print "sgid = %d" % uc.getsgid()
print "zoneid = %d" % uc.getzoneid()
print "projid = %d" % uc.getprojid()
print "groups = %s" % uc.getgroups()
print "label = %s" % uc.getlabel()

print "getpflags(0x1) = %d" % uc.getpflags(0x1)
print "getpflags(0x2) = %d" % uc.getpflags(0x2)
print "has_priv(Effective, proc_fork) = %d" % uc.has_priv("Effective", "proc_fork")
print "has_priv(Permitted, proc_fork) = %d" % uc.has_priv("Permitted", "proc_fork")
print "has_priv(Inheritable, proc_fork) = %d" % uc.has_priv("Inheritable", "proc_fork")
print "has_priv(Limit, file_setid) = %d" % uc.has_priv("Limit", "file_setid")
print "has_priv(Effective, file_setid) = %d" % uc.has_priv("Effective", "file_setid")
try:
    uc.has_priv("Effective", "proc_bork")
except OSError, e:
    print e
try:
    uc.has_priv("Defective", "proc_fork")
except OSError, e:
    print e
try:
    uc.has_priv("Defective", "proc_bork")
except OSError, e:
    print e

del uc
uc = ucred.ucred()
try:
    uc.getpid()
except OSError, e:
    print e