Example #1
0
 def test_uidFromUsernameString(self):
     """
     When L{uidFromString} is called with a base-ten string representation
     of an integer, it returns the integer.
     """
     pwent = pwd.getpwuid(os.getuid())
     self.assertEqual(util.uidFromString(pwent.pw_name), pwent.pw_uid)
 def test_uidFromUsernameString(self):
     """
     When L{uidFromString} is called with a base-ten string representation
     of an integer, it returns the integer.
     """
     pwent = pwd.getpwuid(os.getuid())
     self.assertEqual(util.uidFromString(pwent.pw_name), pwent.pw_uid)
Example #3
0
def getid(uid, gid):
    """
    Convert one or both of a string representation of a UID and GID into
    integer form.  On platforms where L{pwd} and L{grp} is available, user and
    group names can be converted.

    @type uid: C{str} or C{NoneType}
    @param uid: A string giving the base-ten representation of a UID or the
        name of a user which can be converted to a UID via L{pwd.getpwnam},
        or None if no UID value is to be obtained.

    @type gid: C{str} or C{NoneType}
    @param uid: A string giving the base-ten representation of a GID or the
        name of a group which can be converted to a GID via
        L{grp.getgrnam}, or None if no UID value is to be obtained.

    @return: A two-tuple giving integer UID and GID information for
        whichever (or both) parameter is provided with a non-C{None} value.

    @raise ValueError: If a user or group name is supplied and L{pwd} or L{grp}
        is not available.
    """
    if uid is not None:
        uid = uidFromString(uid)
    if gid is not None:
        gid = gidFromString(gid)
    return (uid, gid)
Example #4
0
def getid(uid, gid):
    """
    Convert one or both of a string representation of a UID and GID into
    integer form.  On platforms where L{pwd} and L{grp} is available, user and
    group names can be converted.

    @type uid: C{str} or C{NoneType}
    @param uid: A string giving the base-ten representation of a UID or the
        name of a user which can be converted to a UID via L{pwd.getpwnam},
        or None if no UID value is to be obtained.

    @type gid: C{str} or C{NoneType}
    @param uid: A string giving the base-ten representation of a GID or the
        name of a group which can be converted to a GID via
        L{grp.getgrnam}, or None if no UID value is to be obtained.

    @return: A two-tuple giving integer UID and GID information for
        whichever (or both) parameter is provided with a non-C{None} value.

    @raise ValueError: If a user or group name is supplied and L{pwd} or L{grp}
        is not available.
    """
    if uid is not None:
        uid = uidFromString(uid)
    if gid is not None:
        gid = gidFromString(gid)
    return (uid, gid)
Example #5
0
File: app.py Project: jrydberg/edgy
def switchUID(uid, gid):
    """
    Switch uid and gid to what the user has specified on the command
    line.
    """
    if uid:
        uid = util.uidFromString(uid)
    if gid:
        gid = util.gidFromString(gid)
    util.switchUID(uid, gid)
 def test_uidFromNumericString(self):
     """
     When L{uidFromString} is called with a base-ten string representation
     of an integer, it returns the integer.
     """
     self.assertEqual(util.uidFromString("100"), 100)
Example #7
0
 def test_uidFromNumericString(self):
     """
     When L{uidFromString} is called with a base-ten string representation
     of an integer, it returns the integer.
     """
     self.assertEqual(util.uidFromString("100"), 100)