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 1mgbtq-0006Ti-0z for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Oct 2021 00:07:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgbto-00033H-SS for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Oct 2021 00:07:04 +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 1mgbto-000332-J5 for pgsql-hackers@lists.postgresql.org; Sat, 30 Oct 2021 00:07:04 +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 1mgbtl-000067-R2 for pgsql-hackers@lists.postgresql.org; Sat, 30 Oct 2021 00:07:03 +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 19U06wk5765510; Fri, 29 Oct 2021 20:06:59 -0400 From: Tom Lane To: "Bossart, Nathan" cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: Improving psql's \password command In-reply-to: References: <747443.1635536754@sss.pgh.pa.us> Comments: In-reply-to "Bossart, Nathan" message dated "Fri, 29 Oct 2021 20:45:33 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <765508.1635552418.1@sss.pgh.pa.us> Date: Fri, 29 Oct 2021 20:06:58 -0400 Message-ID: <765509.1635552418@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Bossart, Nathan" writes: > On 10/29/21, 12:47 PM, "Tom Lane" wrote: >> While testing that, I noticed another bit of user-unfriendliness: >> there's no obvious way to get out of it if you realize you are >> setting the wrong user's password. simple_prompt() ignores >> control-C, and when you give up and press return, you'll just >> get the prompt to enter the password again. > Well, as of bf6b9e9, "ALTER ROLE nathan PASSWORD ''" is effectively > the same as "ALTER ROLE nathan PASSWORD NULL". I agree about the > user-unfriendliness, but maybe simple_prompt() ignoring control-C is > the root-cause of the user-unfriendliness. I was afraid somebody would say that. I have looked at it, but AFAICS we'd have to duplicate all of sprompt.c and nearly all of pg_get_line.c in order to tie it into psql's SIGINT infrastructure, since we wouldn't dare enable the signal handler except during the innermost fgets() call, and if we did get a signal we'd still need to clean up the terminal echo state, so we couldn't just longjmp out of simple_prompt(). The cost/benefit ratio of that doesn't look very good. (Note that most callers of simple_prompt() don't need to sweat over this because they haven't moved SIGINT handling off the default: they're OK with just terminating on control-C.) regards, tom lane