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 1mdcEU-0004WU-Jh for pgsql-general@arkaria.postgresql.org; Thu, 21 Oct 2021 17:52:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mdcET-0000M6-16 for pgsql-general@arkaria.postgresql.org; Thu, 21 Oct 2021 17:52:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdcES-0000Lh-NQ for pgsql-general@lists.postgresql.org; Thu, 21 Oct 2021 17:52:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdcEM-0006lH-1i for pgsql-general@lists.postgresql.org; Thu, 21 Oct 2021 17:52:00 +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 19LHpnW82441079; Thu, 21 Oct 2021 13:51:49 -0400 From: Tom Lane To: Toomas cc: Adrian Klaver , 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> Comments: In-reply-to Toomas message dated "Thu, 21 Oct 2021 20:32:18 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2441077.1634838709.1@sss.pgh.pa.us> Date: Thu, 21 Oct 2021 13:51:49 -0400 Message-ID: <2441078.1634838709@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Toomas writes: > 2) db=> select current_user, session_user; > current_user | session_user > --------------+-------------- > db_owner | db_user > (1 row) Given that setup, I wonder which role you expected \password to change. If we target the current_user, we can expect the command to succeed. I'm just wondering if people will find that surprising. Targeting the session_user might be less surprising (or not?) but as this example shows, it can fail. One thing that would help, regardless of which definition we think is most appropriate, is to have \password explicitly say which role it's intending to set the password for: db=> \password Enter new password for role "dbowner": Enter it again: regards, tom lane