Thread: Permission denied for relation pg_database , one role has problem

Permission denied for relation pg_database , one role has problem

From
Jukka Inkeri
Date:
And many others errors when xsome user connect to database x, schema
xxx. PG 8.4.

Problems started about same time as search_path has SET.
search_path has reset, but did'nt help.

ALTER DATABASE x SET search_path=some, public;
-- xxx wasn't in that list
ALTER DATABASE x RESET search_path;  - has done

Only one group has this priviledge problem, xgroup.

pg_log after tried to connect:
2012-08-25 11:39:36 EEST ERROR:  permission denied for relation pg_database
2012-08-25 11:39:36 EEST STATEMENT:  SET DateStyle=ISO;
     SELECT oid, pg_encoding_to_char(encoding) AS encoding, datlastsysoid
       FROM pg_database WHERE oid = 16395


role xuser has done:
CREATE ROLE xuser LOGIN
   ENCRYPTED PASSWORD 'some...'
   NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE;
ALTER ROLE xuser SET search_path=xxx;
GRANT xgroup TO xuser;

And xgroup has done:

CREATE ROLE xgroup
   NOSUPERUSER NOINHERIT NOCREATEDB NOCREATEROLE;
COMMENT ON ROLE xgroup IS 'X Group';


Schema xxx has done:
CREATE SCHEMA xxx
   AUTHORIZATION postgres;

GRANT ALL ON SCHEMA xxx TO postgres;
GRANT USAGE ON SCHEMA xxx TO xgroup;


Schema xxx include some views to public.tables and some own tables.

Views:
CREATE OR REPLACE VIEW
    SELECT * FROM product;
ALTER TABLE xxx.product
   OWNER TO postgres;
GRANT ALL ON TABLE xxx.product TO postgres;
GRANT SELECT ON TABLE xxx.product TO xgroup;

Own tables:
CREATE TABLE xxx.mytable
(
   stamp timestamp without time zone NOT NULL
)
WITH (
   OIDS=FALSE
);
ALTER TABLE xxx.mytable
   OWNER TO postgres;
GRANT ALL ON TABLE xxx.mytable TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE xxx.mytable TO xgroup;

Something interesting happened when search_path has set ?
Is this some kind of catalog priviledge problem ?

-jukka-


Re: Permission denied for relation pg_database , one role has problem

From
Tom Lane
Date:
Jukka Inkeri <pg@awot.fi> writes:
> Only one group has this priviledge problem, xgroup.

> pg_log after tried to connect:
> 2012-08-25 11:39:36 EEST ERROR:  permission denied for relation pg_database
> 2012-08-25 11:39:36 EEST STATEMENT:  SET DateStyle=ISO;
>      SELECT oid, pg_encoding_to_char(encoding) AS encoding, datlastsysoid
>        FROM pg_database WHERE oid = 16395

Either you messed up the permissions on that catalog, or you created
another table named pg_database ...

            regards, tom lane