def set_group_user(group=None, user=None):
 if group:
  (_, gid) = get_group_name_id(group)
  os.setgid(gid)
  os.setegid(gid)
 if user:
  (username, uid) = get_user_name_id(user)
  for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
   os.environ[name] = username
  os.setuid(uid)
  os.seteuid(uid)

def set_group_user ( group = None , user = None ) : if group : ( _ , gid ) = get_group_name_id ( group ) os . setgid ( gid ) os . setegid ( gid ) if user : ( username , uid ) = get_user_name_id ( user ) for name in ( 'LOGNAME' , 'USER' , 'LNAME' , 'USERNAME' ) : os . environ [ name ] = username os . setuid ( uid ) os . seteuid ( uid )
set the group and user id if gid or uid is defined .