'Change the UID and GID or the EUID and EGID of this process.
@type euid: C{bool}
@param euid: A flag which, if set, indicates that only the I{effective}
UID and GID should be set.
@type uid: C{int} or L{None}
@param uid: If not L{None}, the UID to which to switch.
@type gid: C{int} or L{None}
@param gid: If not L{None}, the GID to which to switch.'

def shedPrivileges(self, euid, uid, gid):

    if ((uid is not None) or (gid is not None)):
        extra = ((euid and 'e') or '')
        desc = ('%suid/%sgid    %s/%s' % (extra, extra, uid, gid))
        try:
            switchUID(uid, gid, euid)
        except OSError:
            log.msg(('failed    to    set    %s    (are    you    root?)    --    exiting.' % desc))
            sys.exit(1)
        else:
            log.msg(('set    %s' % desc))
