private function switchUser()
    {
        if (isset($this->user) && function_exists('posix_getpwnam')) {
            $current_user = @posix_getpwuid(@posix_getuid());
            if (!is_array($current_user)) {
                $this->log("user switch to {$this->user} failed: could not determine current username");
                return false;
            }
            if ($current_user['name'] !== $this->user) {
                $u = @posix_getpwnam($this->user);
                if (!is_array($u)) {
                    $this->log("user switch failed: could not find user {$this->user}");
                    return false;
                }
                if (!@posix_setgid($u['gid'])) {
                    $this->log("warning: error switching group for {$this->user} to gid {$u['gid']}");
                }
                if (!@posix_setuid($u['uid'])) {
                    $this->log("user switch failed: could not switch to {$this->user} using uid {$u['uid']}");
                    return false;
                }
                $current_user = @posix_getpwuid(@posix_getuid());
                if (is_array($current_user) && $current_user['name'] === $this->user) {
                    $this->log("user switch successful: teleport running as {$this->user}");
                }
            } else {
                $this->log("teleport already running as user {$this->user}...");
            }
        }
        return true;
    }