Remove g+w bit from $T for TPE bug #519566

Grant permissions to the portage user instead of the group, in order
to avoid TPE complaints about the g+w bit.

X-Gentoo-Bug: 519566
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=519566
portage.data._get_global: fix UnboundLocalError

Since commit 1364fcd89384c9f60e6d72d7057dc00d8caba175, an
UnboundLocalError was triggered for portage_gid when userpriv was
enabled. This is fixed by using _get_global('portage_gid') to access
the variable value.

Fixes: 1364fcd89384 ("Support unprivileged mode for bug #433453.")
X-Gentoo-Bug: 433453
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=433453