pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hkauchi@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14613: Referencing foreign key needs privileges of table owner?
Date: Thu, 06 Apr 2017 02:09:41 +0000
Message-ID: <20170406020941.25934.30410@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14613
Logged by:          Hisahiro Kauchi
Email address:      hkauchi@gmail.com
PostgreSQL version: 9.5.4
Operating system:   Linux
Description:        

Situation:

User1 is a table owner of table1, table2.
User2 is an operator of table1, table2.
Table2 references table1;

-------------------------------
create role user1;
create role user2 login;

create table table1(id int primary key);
create table table2(id int primary key, table1_id integer references
table1(id));
alter table table1 owner to user1;
alter table table2 owner to user2;
grant select,insert,update,delete on table1 to user2;
grant select,insert,update,delete on table2 to user2;

revoke all on schema public from public; // To prevent creation of
objects.
grant usage on schema public to user2;
-------------------------------

Problem:

User2 cannot insert to table2;

-------------------------------
-bash-4.1$ psql -U user2 test
psql (9.5.4)
Type "help" for help.

test=# insert into table1 values(1);
INSERT 0 1
test=# insert into table2(id, table1_id) values(1,1);
ERROR:  permission denied for schema public
LINE 1: SELECT 1 FROM ONLY "public"."table1" x WHERE "id" OPERATOR(p...
                           ^
QUERY:  SELECT 1 FROM ONLY "public"."table1" x WHERE "id"
OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x
-------------------------------

When user1 has USAGE privilege on schema public, there is no problem.

-------------------------------
-bash-4.1$ psql test
psql (9.5.4)
Type "help" for help.

test=# grant usage on schema public to user1;
GRANT
test=# \q
-bash-4.1$ psql -U user2 test
psql (9.5.4)
Type "help" for help.

test=> insert into table2(id, table1_id) values(1,1);
INSERT 0 1
-------------------------------

Is this a bug?


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (3+ messages)  latest in thread

Message-ID: <20170406020941.25934.30410@wrigleys.postgresql.org>
Permalink:  ../20170406020941.25934.30410@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170406020941.25934.30410@wrigleys.postgresql.org

 · 

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-bugs@postgresql.org
  Cc: hkauchi@gmail.com
  Subject: Re: BUG #14613: Referencing foreign key needs privileges of table owner?
  In-Reply-To: <20170406020941.25934.30410@wrigleys.postgresql.org>
  References: <20170406020941.25934.30410@wrigleys.postgresql.org>

* 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