pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Sawtell <csawtell@paradise.net.nz>
To: Zot O'Connor <zot@zotconsulting.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Execute permsissions on fuctions
Date: Sat, 25 Aug 2001 20:19:48 +1200
Message-ID: <20010825082001.E04BC1F9E33@deborah.paradise.net.nz> (raw)
In-Reply-To: <3B872CA4.C888A771@zotconsulting.com>
References: <3B8550E9.3BC47EA7@zotconsulting.com>
	<20010824051425.22A6C1FA01E@deborah.paradise.net.nz>
	<3B872CA4.C888A771@zotconsulting.com>

On Sat, 25 Aug 2001 16:42, Zot O'Connor wrote:
> Christopher Sawtell wrote:
> > On Fri, 24 Aug 2001 06:52, Zot O'Connor wrote:
> > > Other SQL servers have the concept of stored procedures having
> > > different permissions.
> > >
> > > For instance a procedure that can update a table.
> > >
> > > Since a web site typically connects as the webuser (or equiv postgres
> > > user), I do not want to offer update to the webuser.
> > >
> > > The way I have done this elsewhere is to create a stored procedure that
> > > could update the table, and allow the webuser to update the table.  The
> > > procedure had perms of a user who could update the table, but the
> > > webuser could not.
> > >
> > > How can I do this in Postgres?
> >
> > By not GRANTing the webuser write permission to the tables in question.
>
> I guess I should have been more clear.  I want the webuser to
> be able to upadte the table VIA the function, and but not directly.
>
> Currently this does not work, since CREATE FUNCTION acts as any
> old function:
>
> zot=# CREATE TABLE testperms (id int4);
> CREATE
> zot=# CREATE FUNCTION effect_testperms (int4) RETURNS int4 AS 'INSERT INTO
> testperms (id) VALUES ($1); RETURN 1;' LANGUAGE 'sql'; SELECT
> effect_testperms(1);
>  effect_testperms
> ------------------
>                 1
> (1 row)
> zot=# \connect - nobody
> You are now connected as new user nobody.
> zot=> select * from testperms;
> ERROR:  testperms: Permission denied.
> zot=> SELECT effect_testperms(2);
> ERROR:  testperms: Permission denied.
> zot=>
>
> So it appears that FUCNTION effect_testperms() is taking on
> the perms of the user calling it.
>
> So it may be a generic issue with Postgres that other DBMS's
> effectively run the stored procedure as SUID-like, in that it
> takes on the perms of the owner of the procedure, not the
> user calling the procedure.



view thread (4+ messages)

Message-ID: <20010825082001.E04BC1F9E33@deborah.paradise.net.nz>
Permalink:  ../20010825082001.E04BC1F9E33@deborah.paradise.net.nz/
Also on:    postgresql.org/message-id/20010825082001.E04BC1F9E33@deborah.paradise.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: csawtell@paradise.net.nz, zot@zotconsulting.com
  Subject: Re: Execute permsissions on fuctions
  In-Reply-To: <20010825082001.E04BC1F9E33@deborah.paradise.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox