Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebzjW-0006UM-6N for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Jan 2018 02:15:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ebzjV-0000Tv-F2 for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Jan 2018 02:15:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ebzjV-0000TP-9L for pgsql-bugs@lists.postgresql.org; Thu, 18 Jan 2018 02:15:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ebzjR-00076c-Fg for pgsql-bugs@lists.postgresql.org; Thu, 18 Jan 2018 02:15:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w0I2F63U010655; Wed, 17 Jan 2018 21:15:06 -0500 From: Tom Lane To: Michael Paquier cc: "David G. Johnston" , Tomas Vondra , eshkinkot@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15006: "make check" error if current user is "user" In-reply-to: <20180118013509.GC29962@paquier.xyz> References: <20180111125319.1423.23692@wrigleys.postgresql.org> <3568.1516234863@sss.pgh.pa.us> <20180118013509.GC29962@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Thu, 18 Jan 2018 10:35:09 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10653.1516241706.1@sss.pgh.pa.us> Date: Wed, 17 Jan 2018 21:15:06 -0500 Message-ID: <10654.1516241706@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > Perhaps a stupid question. What's the point behind the logic to forbid a > double-quoted "public" but to authorize a double-quoted "user"? The > whole thing looks inconsistent to me. Good question. There may be some backwards-compatibility considerations here, but still this is just plain inconsistent: regression=# create user public; ERROR: role name "public" is reserved LINE 1: create user public; ^ regression=# create user "public"; ERROR: role name "public" is reserved LINE 1: create user "public"; ^ regression=# create user user; ERROR: syntax error at or near "user" LINE 1: create user user; ^ regression=# create user "user"; CREATE ROLE regression=# create user current_user; ERROR: CURRENT_USER cannot be used as a role name here LINE 1: create user current_user; ^ regression=# create user "current_user"; CREATE ROLE I can see the point of disallowing a user named "public", because otherwise syntax like GRANT some-privilege TO PUBLIC is just a trap for the unwary DBA, one that could have bad security consequences. But it's not clear to me why the same logic doesn't apply to "user", "current_user", or "session_user", all of which are equally conflatable with a built-in meaning in some security-relevant contexts. BTW, you might think that those wildly different phrasings of essentially the same error come from different places in the code, but no, they are from adjacent lines in gram.y. WTF? This seems to be deliberately anti-consistent. And, to return to the original scenario, if you do initdb -U public it goes through just fine ... so our defenses against having such a username have a hole in them. Probably the OP would not be very happy if the outcome of this discussion is that "initdb -U user" fails, but I am not seeing a principled reason why that should be allowed. regards, tom lane