Re: BUG #18725: "set role" requires "grant connect on database" - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18725: "set role" requires "grant connect on database"
Date
Msg-id 1895477.1732731060@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18725: "set role" requires "grant connect on database"  (PG Bug reporting form <noreply@postgresql.org>)
Responses AW: BUG #18725: "set role" requires "grant connect on database"
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> After minor release update to version 16.5 or 16.6 "set role" to role
> without "grant connect on database" generates error:

> "ERROR:  Benutzer hat das CONNECT-Privileg nicht.keine Berechtigung für
> Datenbank »...«
> FEHLER:  keine Berechtigung für Datenbank »...«
> SQL state: 42501
> Detail: Benutzer hat das CONNECT-Privileg nicht.
> Context: paralleler Arbeitsprozess"

This bug report is not actionable, because you didn't show what
you did to provoke the error.  I did a little bit of testing
by guessing what you might be talking about, and I don't see
a problem:

regression=# create role r;
CREATE ROLE
regression=# create database d;
CREATE DATABASE
regression=# revoke connect on database d from public;
REVOKE
regression=# \c d
You are now connected to database "d" as user "postgres".
d=# set role r;                -- should work, and does
SET
d=> reset role;
RESET
d=# create user joe;
CREATE ROLE
d=# grant r to joe;
GRANT ROLE
d=# alter user joe set role = r;
ALTER ROLE
d=# \c d joe                   -- should fail, and does
connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  permission denied for database "d"
DETAIL:  User does not have CONNECT privilege.
Previous connection kept
d=# grant connect on database d to joe;
GRANT
d=# \c d joe                   -- now it should work, and does
You are now connected to database "d" as user "joe".
d=> show role;
 role
------
 r
(1 row)

Please provide a self-contained script that reproduces
your problem.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
Next
From: Nathan Bossart
Date:
Subject: Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails