Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKlNn-004Ntu-Jq for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jan 2024 20:29:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rKlNl-001TdN-HA for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jan 2024 20:29:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKlNl-001TdF-8O for pgsql-bugs@lists.postgresql.org; Tue, 02 Jan 2024 20:29:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKlNe-00FDDB-Ow for pgsql-bugs@lists.postgresql.org; Tue, 02 Jan 2024 20:29: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 402KSe4s012830; Tue, 2 Jan 2024 15:28:41 -0500 From: Tom Lane To: liulang cc: pgsql-bugs@lists.postgresql.org Subject: Re: lost status 'STATUS_EOF' for authentication when using 'MD5' or 'scram-sha-256' In-reply-to: References: Comments: In-reply-to liulang message dated "Tue, 02 Jan 2024 18:31:00 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12828.1704227320.1@sss.pgh.pa.us> Date: Tue, 02 Jan 2024 15:28:40 -0500 Message-ID: <12829.1704227320@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk liulang writes: > The above code does not affect the database execution,but > ClientAuthentication_hook will be confused whether the password is > incorrect or not currently entered? > so.. The CheckPWChallengeAuth should returns STATUS_EOF when It is, I think. Yeah, I think you are right. Overriding the subroutine's result here is mistaken, even without considering whether it confuses any ClientAuthentication_hook. The whole point, as per the comments, is to not betray to the remote end whether or not there is a user with a password set. But if we substitute STATUS_ERROR for STATUS_EOF then we cause exactly that to happen: if the remote closes the connection for send only, it can tell by whether an error comes back whether or not the code found a password. I think we can do it more simply than you suggest though. Just drop the "return STATUS_ERROR" bit; the Assert is enough. regards, tom lane