Re: How to hide stored procedure's bodies from specific user - Mailing list pgsql-general

From Merlin Moncure
Subject Re: How to hide stored procedure's bodies from specific user
Date
Msg-id CAHyXU0yjw2gBMgdEp7YkSWMQubimA0c+BYvOmxqRn38FxtadKw@mail.gmail.com
Whole thread Raw
In response to Re: How to hide stored procedure's bodies from specific user  (Saimon Lim <aimon.slim@gmail.com>)
List pgsql-general
On Fri, Feb 13, 2015 at 5:17 AM, Saimon Lim <aimon.slim@gmail.com> wrote:
> Thanks for your help
>
> I want to restrict some postgres users as much as possible and allow them to
> execute a few my own stored procedures only.
>
> If I block access using:
>
> REVOKE ALL ON pg_catalog.pg_proc FROM PUBLIC;
> REVOKE ALL ON FUNCTION pg_catalog.pg_get_functiondef(oid) FROM PUBLIC;
>
> the user will fail to select procedure's body from pg_catalog.pg_proc and
> using psql \sf of \ef.
> Is this method correct?

[FYI -- please try to avoid top-posting]

That is correct. However, I'm not guaranteeing that it's a 100% clean
solution...there may be other loopholes you have to close also.  For
example, if you get an unhandled error inside a function the database
will send the error context back to the client.  Basically you're
playing 'whack-a-mole' -- however, it's not too difficult to hide
stored procedure bodies from the *casual observer* if you take certain
precautions.

A stronger approach would be write a wrapper to pl/pgsql that
encrypted the function bodies (this is not trivial), or to write them
in C as John noted.

merlin


pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Re: Unknown error while running <> postgresql_installer_dc46cfee2c\getlocales.exe
Next
From: David G Johnston
Date:
Subject: Re: infinite recursion detected in rules for relation