The UTF-8 char* is marshaled to a UTF-16 string automatically. It must
be allocated on the heap as the CLR will free the returned memory.
This removes entire classes of possible errors, greatly reducing the
code complexity and number of tests.
This removes the dependency on a TTY and now does what is expected: gets
the (possibly impersonated) username of the current process/thread.
Implementation and tests updated, still uses reentrant versions where possible.
Note that these fail when run in a Docker container because a) the
current container's locale is not completely set, and b) getlogin()
returns null with ENOENT since /var/run/utmp is being mapped to the
host, and thus denied access from within the container.
The container needs the locale set and its own /run/utmp, see
https://lists.linuxcontainers.org/pipermail/lxc-users/2011-July/002374.html