mottalrd
mottalrd

Reputation: 4490

How does the PostgreSQL user configuration work on MacOSX?

I just installed Postgres 9.4 (EnterpriseDB package) and I am confused by the users I see in the system.

If I print /etc/passwd I see the _postgres user:

$ cat /etc/passwd | grep postgres
_postgres:*:216:216:PostgreSQL Server:/var/empty:/usr/bin/false

But if I try to login with it I am still identified with my user.

$ su _postgres
Password:
$ whoami
motta

The weird behavior is that I can login with the postgres user even if this is not listed in /etc/passwd

$ su postgres
Password:
$ whoami
postgres

This is really strange to me.
Could someone explain what's going on?

Thank you

Upvotes: 1

Views: 593

Answers (1)

Daniel Vérité
Daniel Vérité

Reputation: 61546

_postgres:*:216:216:PostgreSQL Server:/var/empty:/usr/bin/false

The last component of this /etc/passwd entry is the shell to use for that user. If it was something like /bin/sh it would work as you expect (compare with the entry for postgres without the underscore. EDIT: actually no, don't bother, because it may not be there).

Since it's /usr/bin/false it immediately terminates and gives control back to the caller instead of waiting for shell commands.

It implies that _postgres as a user is not meant to be used for shell access.

Upvotes: 2

Related Questions