> I understand why the socket needs to be in /tmp, but why the lockfile?
It would probably be better if the socket files weren't in /tmp but in
a postgres-owned directory. However, at this point we have a huge
backwards compatibility problem to overcome if we want to move the
socket files. The location of the socket files is essentially a core
part of the frontend-backend protocol, because both client and server
must know it ab initio. Move the socket, break your clients.
There is an option in 7.1 to support defining a different directory
for the socket files, but I doubt very many people will use it.
I see no real good reason to keep the lockfiles in a different place
from the sockets themselves, however. Doing so would just complicate
things even more, without adding any real safety or security.
regards, tom lane