Jochem van Dieten <jochemd(at)oli(dot)tudelft(dot)nl> writes:
> - can users break out of PostgresQL to execute shell commands?
Not if you don't make them superusers, which your script doesn't.
(If they are superusers, they can install C functions that do anything
the Postgres userid can do.)
> - is it a security risk to give users RULE permission?
No.
> - is it a security risk to make sql a trusted language?
It's irrelevant; the TRUST flag is only used for procedural languages.
> - how would I grant select permissions to a user on tables in a specific
> database, while connected (as superuser) to a different database in the
> same cluster?
You wouldn't.
regards, tom lane