pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Kresse <mkresse@slyde.in-berlin.de>
To: pgsql-sql@postgresql.org
Subject: "Permission denied" on public view
Date: Mon, 14 Feb 2000 19:36:07 +0100
Message-ID: <200002141832.e1EIWWR16053@einhorn.in-berlin.de> (raw)

Hi there,

I am working on a db application that allows students to choose 
their courses, so I try to design everything securely. However, it 
seems to be that secure, that users don't have access on a certain 
view, which I don't understand.
To track down and understand the problem, I devised a little model, 
which is supposed to store information about different cars of 
different postgres users:

/* Main Table */
CREATE TABLE data(owner NAME, car TEXT);
CREATE SEQUENCE datalog;
CREATE RULE ins_data AS ON INSERT TO data DO
	SELECT NEXTVAL('datalog');
GRANT ALL ON datalog TO PUBLIC;

/* Public View */
CREATE VIEW publicdata AS SELECT * FROM data WHERE 
owner = USER;
CREATE RULE ins_publicdata AS ON INSERT TO publicdata DO 
INSTEAD
	INSERT INTO data(owner, car) VALUES(USER, new.car);
GRANT SELECT, INSERT ON publicdata TO PUBLIC;

The datalog sequence is used to detect and track changes in the 
data table. Everything works fine when I use a Postgres superuser, 
for example an insert like:
 INSERT INTO publicdata(car) VALUES('Ford');

However, when I try the exact same statement with a different user, 
I get the error message:
 ERROR:  data: Permission denied.

When I remove the ins_data rule, the INSERT works for the other 
users as well. Does the rule need access to the data table? Is this 
a bug or am I doing something wrong?

I appreciate your help,
  Martin Kresse



view thread (3+ messages)  latest in thread

Message-ID: <200002141832.e1EIWWR16053@einhorn.in-berlin.de>
Permalink:  ../200002141832.e1EIWWR16053@einhorn.in-berlin.de/
Also on:    postgresql.org/message-id/200002141832.e1EIWWR16053@einhorn.in-berlin.de

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: mkresse@slyde.in-berlin.de
  Subject: Re: "Permission denied" on public view
  In-Reply-To: <200002141832.e1EIWWR16053@einhorn.in-berlin.de>
  References: <200002141832.e1EIWWR16053@einhorn.in-berlin.de>

* 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