From: Adrian Klaver <adrian.klaver@aklaver.com>
To: AC Gomez <antklc@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: permission denied for schema
Date: Wed, 1 Apr 2020 08:59:53 -0700
Message-ID: <552dd5ec-d865-c99c-80c4-97098d23c982@aklaver.com> (raw)
In-Reply-To: <CABtmK-h7pVkTko3ay17K-TDDq-tu+ojo1prLYkvsWgGPt5zi9g@mail.gmail.com>
References: <CABtmK-h7pVkTko3ay17K-TDDq-tu+ojo1prLYkvsWgGPt5zi9g@mail.gmail.com>
On 4/1/20 6:35 AM, AC Gomez wrote:
> I'm trying to write a function that eventually will rotate users.
> Currently I have the code below which works and creates a new user using
> the prior user which ultimately has the same rights as the master user,
> ie, can do everything.
>
> select mysch.dblink('dbname=mydb user=themasteruser password=abc123
> connect_timeout=200000 host=localhost', 'CREATE USER newuname WITH
> PASSWORD ''pass1'' CREATEDB CREATEROLE;GRANT rds_superuser TO newuname;');
>
>
> DROP SERVER IF EXISTS fs_link_b CASCADE;
> CREATE SERVER fs_link_b FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host
> 'localhost', port '5432', dbname 'mydb ', connect_timeout '200000');
> CREATE USER MAPPING FOR newuname SERVER fs_link_b OPTIONS ("user"
> 'newuname',password 'pass1');
> ALTER SERVER fs_link_b OWNER TO newuname;
>
> However, when I make a connection with the above created user and I try
> to run the query below:
>
> select * from mysch.dblink('link_b', 'select usename from PG_USER limit
> 1;') as t(uu text);
>
> I get this error:
>
> > SQL Error [42501]: ERROR: permission denied for schema mysch
Looks to me the issue is that whatever user is running:
select * from mysch.dblink('link_b', 'select usename from PG_USER limit
1;') as t(uu text);
does not have access to objects in schema mysch on the originating server.
>
> If I created the user based on a master user, then should it not have
> all rights as the master user as created above? Or Do I need to do a
> bunch of individual GRANTS still?
>
> Thanks
--
Adrian Klaver
adrian.klaver@aklaver.com
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-general@postgresql.org
Cc: adrian.klaver@aklaver.com, antklc@gmail.com
Subject: Re: permission denied for schema
In-Reply-To: <552dd5ec-d865-c99c-80c4-97098d23c982@aklaver.com>
References: <CABtmK-h7pVkTko3ay17K-TDDq-tu+ojo1prLYkvsWgGPt5zi9g@mail.gmail.com> <552dd5ec-d865-c99c-80c4-97098d23c982@aklaver.com>
* 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