Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdc7S-0004Lb-RM for pgsql-general@arkaria.postgresql.org; Thu, 21 Oct 2021 17:44:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mdc7P-00027t-F2 for pgsql-general@arkaria.postgresql.org; Thu, 21 Oct 2021 17:44:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdc7P-00027k-5J for pgsql-general@lists.postgresql.org; Thu, 21 Oct 2021 17:44:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdc7I-0000FB-VH for pgsql-general@lists.postgresql.org; Thu, 21 Oct 2021 17:44:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 19LHiXqH2440552; Thu, 21 Oct 2021 13:44:33 -0400 From: Tom Lane To: Adrian Klaver cc: Toomas , Vijaykumar Jain , pgsql-general Subject: Re: Can db user change own password? In-reply-to: References: <62f56a19-0504-4d7b-5f73-b10e8206642a@aklaver.com> <7FC82398-5C8C-4F2D-9620-D16E54E77091@gmail.com> <2424680.1634835237@sss.pgh.pa.us> Comments: In-reply-to Adrian Klaver message dated "Thu, 21 Oct 2021 10:29:08 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2440550.1634838273.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 Oct 2021 13:44:33 -0400 Message-ID: <2440551.1634838273@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Adrian Klaver writes: > On 10/21/21 09:53, Tom Lane wrote: >> I'm not sure if we want to change a security-relevant behavior >> in released branches. But if we don't, we probably need to >> change the docs to something like "(by default, the logged-in >> user)". > I would suggest session(_)user to make it match with the rest of = > documentation. But that's not right either. regression=3D# select session_user; session_user = -------------- postgres (1 row) regression=3D# create user joe; CREATE ROLE regression=3D# set session authorization joe; SET regression=3D> select session_user; session_user = -------------- joe (1 row) regression=3D> \password Enter new password: = Enter it again: = ERROR: must be superuser to alter superuser roles or change superuser att= ribute regression=3D> = Another angle to this: even without SET SESSION AUTHORIZATION, the existence of username mapping options in the pg_hba machinery means that the role name that psql thought it logged in with might have nothing to do with the role name that the server thinks is the authenticated user. There might be no SQL role by that name at all. So what psql is doing here is flat-out wrong. I'm still hesitant about changing the behavior in the back branches, though, especially given the lack of prior complaints. regards, tom lane