Unix Technical Forum

control pg_hba.conf via SQL

This is a discussion on control pg_hba.conf via SQL within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi all, i would like to work on control setting pg_hba.conf via SQL....( cf TODO List ), and i ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 01:47 AM
BERTHOULE Emmanuel
 
Posts: n/a
Default control pg_hba.conf via SQL

Hi all,

i would like to work on control setting pg_hba.conf via SQL....( cf TODO
List ), and i would know if the pg_hda.conf must be replaced by pg_hba
table ?

Emmanuel BERTHOULE

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 01:47 AM
Jonah H. Harris
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

I'd like to expand this idea with this TODO item. If this is already
on the TODO, please disregard. I'm thinking something like the
following:

Enable the alteration and persistence of postgresql.conf and
pg_hba.conf configuration parameters via SQL.


On 3/29/06, BERTHOULE Emmanuel <pgdev@manberth.homeip.net> wrote:
> Hi all,
>
> i would like to work on control setting pg_hba.conf via SQL....( cf TODO
> List ), and i would know if the pg_hda.conf must be replaced by pg_hba
> table ?
>
> Emmanuel BERTHOULE
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>



--
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporation
732.331.1324

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 01:47 AM
Andrew Dunstan
 
Posts: n/a
Default Re: control pg_hba.conf via SQL


ISTM that the first requirement is for a sane API that will handle the
fact that HBA lines are ordered. Persistence in itself shouldn't be a
big problem - we already do that with some shared tables, iirc.

so we might have some functions like:

insert_hba_rule(at_position int, connection_type text, username text,
dbname text, cidr_host text, method text)
move_hba_rule(from_position int, to_position int)
delete_hba_rule(at_position int)

Inventing new SQL syntax might make things a bit tougher.

cheers

andrew


Jonah H. Harris wrote:
> I'd like to expand this idea with this TODO item. If this is already
> on the TODO, please disregard. I'm thinking something like the
> following:
>
> Enable the alteration and persistence of postgresql.conf and
> pg_hba.conf configuration parameters via SQL.
>
>
> On 3/29/06, BERTHOULE Emmanuel <pgdev@manberth.homeip.net> wrote:
>
>> Hi all,
>>
>> i would like to work on control setting pg_hba.conf via SQL....( cf TODO
>> List ), and i would know if the pg_hda.conf must be replaced by pg_hba
>> table ?
>>
>>



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 01:47 AM
Jonah H. Harris
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

On 3/29/06, Andrew Dunstan <andrew@dunslane.net> wrote:
> ISTM that the first requirement is for a sane API that will handle the
> fact that HBA lines are ordered. Persistence in itself shouldn't be a
> big problem - we already do that with some shared tables, iirc.


I agree.

--
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporation
732.331.1324

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 01:47 AM
Tom Lane
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

Andrew Dunstan <andrew@dunslane.net> writes:
> ISTM that the first requirement is for a sane API that will handle the
> fact that HBA lines are ordered. Persistence in itself shouldn't be a
> big problem - we already do that with some shared tables, iirc.


I'm a bit suspicious of proposals that we move either hba or conf into
SQL tables --- one of the main reasons why they are flat files is so
you can still edit them after you've hosed them to the point that the
database won't start or won't let you in. If you don't have a non-kluge
solution to the DBA-mistake-recovery scenario, this is not going to be
an improvement.

Pushing postgresql.conf into a SQL table will also destroy all the work
that was done recently to allow config sharing across multiple
installations (eg the recent commit to support "include" goes out the
window again). If we no longer care about that, why not?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 01:47 AM
Robert Treat
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

On Wednesday 29 March 2006 17:04, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
> > ISTM that the first requirement is for a sane API that will handle the
> > fact that HBA lines are ordered. Persistence in itself shouldn't be a
> > big problem - we already do that with some shared tables, iirc.

>
> I'm a bit suspicious of proposals that we move either hba or conf into
> SQL tables --- one of the main reasons why they are flat files is so
> you can still edit them after you've hosed them to the point that the
> database won't start or won't let you in. If you don't have a non-kluge
> solution to the DBA-mistake-recovery scenario, this is not going to be
> an improvement.
>


I've often thought that a GUC in postgresql.conf could control whether to use the hba file or an hba table. Most likely you would need to restart the db to toggle control, but if your at the point where you've locked yourself out thisdoesn't seem onerous. If pushing postgresql.conf into the db would negate this plan, we could either allow a command line flag to override the conf/hba behavior, or force postgresql to use files if started in single operator mode. In any case, I don't think this restriction is insurmountable.

> Pushing postgresql.conf into a SQL table will also destroy all the work
> that was done recently to allow config sharing across multiple
> installations (eg the recent commit to support "include" goes out the
> window again). If we no longer care about that, why not?
>


Honestly I never cared much about that, and I run several machines that contain 3+ versions of the db on them. Certainly not as much as I would like to enhance remote administration between machines.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-12-2008, 01:47 AM
Andrew Dunstan
 
Posts: n/a
Default Re: control pg_hba.conf via SQL



Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>
>
>>ISTM that the first requirement is for a sane API that will handle the
>>fact that HBA lines are ordered. Persistence in itself shouldn't be a
>>big problem - we already do that with some shared tables, iirc.
>>
>>

>
>I'm a bit suspicious of proposals that we move either hba or conf into
>SQL tables --- one of the main reasons why they are flat files is so
>you can still edit them after you've hosed them to the point that the
>database won't start or won't let you in. If you don't have a non-kluge
>solution to the DBA-mistake-recovery scenario, this is not going to be
>an improvement.
>
>Pushing postgresql.conf into a SQL table will also destroy all the work
>that was done recently to allow config sharing across multiple
>installations (eg the recent commit to support "include" goes out the
>window again). If we no longer care about that, why not?
>
>
>


I think we should treat pg_hba.conf and postgresql.conf as separate
cases. The proposal was only for pg_hba.conf.

There are several possible ways around the "settings hosed" issue,
including Robert's suggestion of a flag to say "don't read the table,
read this file instead".

I agree about the value of "include" for postgresql.conf.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 01:47 AM
Tino Wildenhain
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

Andrew Dunstan wrote:
>
> ISTM that the first requirement is for a sane API that will handle the
> fact that HBA lines are ordered. Persistence in itself shouldn't be a
> big problem - we already do that with some shared tables, iirc.
>
> so we might have some functions like:
>
> insert_hba_rule(at_position int, connection_type text, username text,
> dbname text, cidr_host text, method text)
> move_hba_rule(from_position int, to_position int)
> delete_hba_rule(at_position int)
>
> Inventing new SQL syntax might make things a bit tougher.
>


I dont think it has to be ordered preliminary. Since we are
dealing with subnets and stuff - the ordering already lays
in the data - just like routing tables work: most specific
matches first.

I could think of a solution where pg_hba.conf just
overrides the database table (so you have a starting
point with empty table and/or reentry in case of a
mistake)

regards
Tino

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-12-2008, 01:47 AM
Simon Riggs
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

On Wed, 2006-03-29 at 16:20 -0500, Jonah H. Harris wrote:

> Enable the alteration and persistence of postgresql.conf and
> pg_hba.conf configuration parameters via SQL.


Agreed.

I'd also add the seemingly obvious caveat that parameters should be
unique. A common problem is for one person to edit a postgresql.conf by
editing in place, then another person to add a line at the bottom. The
second entry overrides the first.

I would also like these settings to be grouped together as Profiles.
It's fairly common to have multiple postgresql.conf files for different
modes of processing: Normal Running, Bulkload, TuningMode so we would
want to be able to retain that capability in the future.

Best Regards, Simon Riggs


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-12-2008, 01:48 AM
Andrew Dunstan
 
Posts: n/a
Default Re: control pg_hba.conf via SQL

Tino Wildenhain wrote:
> Andrew Dunstan wrote:
>
>> ISTM that the first requirement is for a sane API that will handle the
>> fact that HBA lines are ordered. Persistence in itself shouldn't be a
>> big problem - we already do that with some shared tables, iirc.
>>
>> so we might have some functions like:
>>
>> insert_hba_rule(at_position int, connection_type text, username text,
>> dbname text, cidr_host text, method text)
>> move_hba_rule(from_position int, to_position int)
>> delete_hba_rule(at_position int)
>>
>> Inventing new SQL syntax might make things a bit tougher.
>>
>>

>
> I dont think it has to be ordered preliminary. Since we are
> dealing with subnets and stuff - the ordering already lays
> in the data - just like routing tables work: most specific
> matches first.
>
> I could think of a solution where pg_hba.conf just
> overrides the database table (so you have a starting
> point with empty table and/or reentry in case of a
> mistake)
>
>
>


We don't have the luxury of being able just to throw out old stuff
because we think it might be neater to do it another way. The current
rules for HBA are order dependent. The issue raised as I understood it
was not to invent a new scheme but to be able to manage it from inside a
postgres session.

Of course, if we go for a new scheme that is not order dependent, then
inventing a reasonable SQL syntax to support it becomes a heck of a lot
easier. Something along the lines of GRANT/REVOKE CONNECT ... should do
the trick.

Maybe we could do something like this: if there is a pg_hba.conf file
present, then use it as now and ignore the access rights table - if
someone does GRANT/REVOKE CONNECT while under pg_hba.conf then process
it but issue a warning. Maybe there could also be an initdb switch that
gave users a choice.

cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com