Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YSx0W-00023Z-7E for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2015 00:17:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YSx0V-00013z-Ma for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Mar 2015 00:17:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YSx0U-00013p-Ry for pgsql-hackers@postgresql.org; Wed, 04 Mar 2015 00:17:46 +0000 Received: from mail-bn1on0600.outbound.protection.outlook.com ([2a01:111:f400:fc10::600] helo=na01-bn1-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YSx0P-0004J3-H3 for pgsql-hackers@postgresql.org; Wed, 04 Mar 2015 00:17:45 +0000 Received: from decina.local (24.55.12.91) by BY1PR11MB0343.namprd11.prod.outlook.com (25.160.206.156) with Microsoft SMTP Server (TLS) id 15.1.99.14; Wed, 4 Mar 2015 00:17:32 +0000 Message-ID: <54F64F13.6010509@BlueTreble.com> Date: Tue, 3 Mar 2015 18:17:23 -0600 From: Jim Nasby User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Greg Stark CC: Abhijit Menon-Sen , PostgreSQL-development , "Prabakaran, Vaishnavi" , Magnus Hagander , Jaime Casanova Subject: Re: Providing catalog view to pg_hba.conf file - Patch submission References: <82897A1301080E4B8E461DDAA0FFCF14DDE1@SYD1216> <82897A1301080E4B8E461DDAA0FFCF14FD6E@SYD1216> <20140629165554.GA5984@toroid.org> <20140630070646.GY31357@toroid.org> <54F5F7DD.8020501@BlueTreble.com> In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [24.55.12.91] X-ClientProxiedBy: BLUPR05CA0069.namprd05.prod.outlook.com (10.141.20.39) To BY1PR11MB0343.namprd11.prod.outlook.com (25.160.206.156) Authentication-Results: 2ndquadrant.com; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR11MB0343; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:BY1PR11MB0343; BCL:0; PCL:0; RULEID:; SRVR:BY1PR11MB0343; X-Forefront-PRVS: 0505147DDB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(51704005)(52314003)(479174004)(24454002)(377454003)(19580405001)(47776003)(19580395003)(66066001)(80316001)(65806001)(2171001)(40100003)(83506001)(62966003)(50986999)(86362001)(87976001)(64126003)(65816999)(54356999)(110136001)(76176999)(93886004)(42186005)(122386002)(50466002)(2950100001)(92566002)(46102003)(15975445007)(77156002)(36756003)(23746002)(33656002)(85282002)(336755003)(18886065003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR11MB0343; H:decina.local; FPR:; SPF:None; MLV:sfv; LANG:en; X-OriginatorOrg: bluetreble.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2015 00:17:32.9635 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR11MB0343 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 3/3/15 12:57 PM, Greg Stark wrote: > On Tue, Mar 3, 2015 at 6:05 PM, Jim Nasby wrote: > >> What about a separate column that's just the text from pg_hba? Or is that what you're opposed to? > > I'm not sure what you mean by that. There's a rawline field we could > put somewhere but it contains the entire line. I mean have a field for each of user/databases that gives you valid pg_hba.conf output. That would allow for cut & paste. But perhaps that's just not a use case. >> FWIW, I'd say that having the individual array elements be correct is more >> important than what the result of array_out is. That way you could always do >> array_to_string(..., ', ') and get valid pg_hba output. > > Well I don't think you can get that without making the view less > useful for every other purpose. > > Like, I would want to be able to do WHERE "user" @> array[?] or WHERE > database = array[?] or to join against a list of users or databases > somewhere else. I think we're screwed in that regard anyway, because of the special constructs. You'd need different logic to handle things like +role and sameuser. We might even end up painted in a corner where we can't change it in the future because it'll break everyone's scripts. > To do what you suggest would mean the tokens will need to be quoted > based on pg_hba.conf syntax requirements. That would mean I would need > to check each variable or join value against pg_hba.conf's quoting > requirements to compare with it. It seems more practical to have that > knowledge if you're actually going to generate a pg_hba.conf than to > pass around these quoted strings all the time. What about this: - database_specials enum[] contains all occurrences of all, sameuser, samerole and replication (or maybe it doesn't need to be an array) - in_roles name[] is a list of all cases of +role_name, with the + stripped off (I think the @ case is already handled before the SRF is called??) - role_specials enum[] handles all (enum[] for any future expansion) Alternatively in_roles could just be combined with role_specials as long as we preserve the +. Any tokens that match the special conditions do not show up in databases/users, and those fields become name[]. AFAIK that means the quoting should be identical (at least looking at check_db() and check_role()). I can make these changes if you want. -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers