docs: def _drop_privs(self):
          """ Reduces effective privileges for this process to that of the task
              owner. The umask and environment variables are also modified to
              recreate the environment of the user.
              """
  
          uid = self._task.owner
  
          # get pwd database info for task owner
          try:
              pwd_info = pwd.getpwuid(uid)
  
          except OSError:
              pwd_info = None
  
          # set secondary group ids for user, must come first
          if pwd_info:
              try:
                  gids = [g.gr_gid for g in grp.getgrall()
                          if pwd_info.pw_name in g.gr_mem]
                  gids.append(pwd_info.pw_gid)
                  os.setgroups(gids)
  
              except OSError:
                  pass
  
              # set group id, must come before uid
              try:
                  os.setgid(pwd_info.pw_gid)
              except OSError:
                  pass
  
          # set user id
          try:
              os.setuid(uid)
  
              # update user env variables
              if pwd_info:
                  for k in ('USER', 'USERNAME', 'SHELL', 'HOME'):
                      if k in os.environ:
                          if k in ('USER', 'USERNAME'):
                              val = pwd_info.pw_name
  
                          elif k == 'SHELL':
                              val = pwd_info.pw_shell
  
                          elif k == 'HOME':
                              val = pwd_info.pw_dir
  
                          # update value
                          os.environ[k] = val
  
              # remove unneeded env variables
              keys = []
              for k, _ in os.environ.iteritems():
                  if k.startswith('SUDO_') or k == 'LOGNAME':
                      keys.append(k)
              for k in keys:
                  del os.environ[k]
  
          except OSError:
              pass
  
          # set default umask
          try:
              os.umask(022)
          except OSError:
              pass