Re: How can I kow my permissions? - Mailing list pgsql-general

From Martin Neimeier
Subject Re: How can I kow my permissions?
Date
Msg-id 39B3753B.303DFCF2@ibn.de
Whole thread Raw
In response to How can I kow my permissions?  (Waldemar Baraldi <wbaraldi@lacasilla.com.ar>)
List pgsql-general
Waldemar Baraldi wrote:
>
> I'm programming a database application that uses the API, but I have
> some security issues that I have to manage, so I need to know my access
> rights on a table and the "try" technique is not appropiate because if I
> get a "Permission denied" then my transaction block is aborted and I
> don't want that to happend.
> The psql program can read it with the \z option so I know that it can be
> done, so, how? from tha API, a query? which?.
>
> Thanks in advance and sorry for my English, I speak Spanish.

H Waldemar,

you can query the system-table "pg_class". The filed "relacl" holds the acl for the table.

The form is:
{RIGHT[,RIGHT]}

where RIGHT is in the form:
"[user]=[acl-for-user]"

acl-for-user is a combination of the following:
a - insert granted
r - select granted
w - update granted
R - rule granted

Sample Entry:
{"=","admin=arwR","simpleuser=r","updater=w"}

means:
PUBLIC: allowed nothing
admin: insert,select,update,rule
simpleuser: select
updater: update

Hope this works for you.

cu
Martin
--
Martin Neimeier
Ingenieur-Buero Neimeier
Schwarzach / Germany
mailto:nei@ibn.de  / http://www.ibn.de (under heavy reconstruction)
Tel:+49(6262)912344 / Fax:+49(6262)912347

pgsql-general by date:

Previous
From: Gabriel Fernandez
Date:
Subject: Problem with drop table within a transaction
Next
From: Gilles DAROLD
Date:
Subject: Re: PL/Perl compilation error