Enhance compatibility of ``postgres._run_as_pg`` and ``require.postgres.database``

- ``postgres._run_as_pg`` should use ``~postgres`` to determine the ``postgres`` user's home dir instead of relying on a static path.  This change makes the function compatible with SmartOS (and maybe other systems where ``/var/lib/postgres`` doesn't exist or isn't the right directory to ``cd`` into).

- ``require.postgres.database`` currently fails on systems that are not targeted by ``require.system.locale(s)`` (it even fails on some of them by only supporting the Debian/Ubuntu way of handling locales).  The fix does not include a function to have a currently unavailable locale made available, but at least ``require.postgres.database`` can now be used everywhere if the locale is already available.