Exposing an installation's default value of unix_socket_directory

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 18:07:25
Message-ID: 27500.1287684445@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I just noticed that there doesn't seem to be any good way of finding
out what a postmaster's default value of unix_socket_directory is.
If you try to SHOW it you just get an empty string. We could probably
fix things so that SHOW exposes the actual setting, but (1) there might
be security arguments against that, and (2) if your problem is that you
would like to find out the value so's you can connect to said
postmaster, SHOW isn't going to help you.

One possible response would be to add an item to what pg_config knows
about, eg "pg_config --socketdir". This doesn't answer every possible
use-case either, but it would be helpful for some scenarios.

Thoughts?

regards, tom lane


From: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 19:01:30
Message-ID: AANLkTinSA-ME9fteP1b5UYZ8UhZfFVHWweh40ojL2UFs@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2010/10/21 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> I just noticed that there doesn't seem to be any good way of finding
> out what a postmaster's default value of unix_socket_directory is.
> If you try to SHOW it you just get an empty string.  We could probably
> fix things so that SHOW exposes the actual setting, but (1) there might
> be security arguments against that, and (2) if your problem is that you
> would like to find out the value so's you can connect to said
> postmaster, SHOW isn't going to help you.
>
> One possible response would be to add an item to what pg_config knows
> about, eg "pg_config --socketdir".  This doesn't answer every possible
> use-case either, but it would be helpful for some scenarios.
>
> Thoughts?

I agree this is interesting information to get, but wonder how
pg_config can know that and it looks to me that this information as
nothing to do in pg_config....

pg_config is all about installation, socket_dir is a postgresql.conf setting.

I'd prefer a 'pg_ctl status' output.

>
>                        regards, tom lane
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
Cédric Villemain               2ndQuadrant
http://2ndQuadrant.fr/     PostgreSQL : Expertise, Formation et Support


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 19:39:30
Message-ID: 1287689813-sup-7919@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Cédric Villemain's message of jue oct 21 16:01:30 -0300 2010:

> I agree this is interesting information to get, but wonder how
> pg_config can know that and it looks to me that this information as
> nothing to do in pg_config....
>
> pg_config is all about installation, socket_dir is a postgresql.conf setting.

Yeah -- how is pg_config to know? All it can tell you is what was the
compiled-in default.

pg_ctl would be nice, but we'd have to make it parse the config file
(there has been talk about that). In any case, if you don't know where
the socket is, presumably you don't know where the config file is,
either. You've just moved the problem.

Maybe you should go the SHOW route. The user could connect via TCP and
find out the socket directory that way.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 19:46:25
Message-ID: m2ocanfhwu.fsf@2ndQuadrant.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> One possible response would be to add an item to what pg_config knows
> about, eg "pg_config --socketdir". This doesn't answer every possible
> use-case either, but it would be helpful for some scenarios.
>
> Thoughts?

Following some links one can find out
http://packages.debian.org/source/unstable/postgresql-9.0
http://ftp.de.debian.org/debian/pool/main/p/postgresql-9.0/postgresql-9.0_9.0.1-1.debian.tar.gz

And check that debian package is patching src/include/pg_config_manual.h
and not using the other facility proposed in the comments:

* here's where to twiddle it. You can also override this at runtime
* with the postmaster's -k switch.

-#define DEFAULT_PGSOCKET_DIR "/tmp"
+#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"

But still, I wonder how this -k switch will get a role here, pg_control
certainly won't know about that. I guess it's worse to give a wrong
value rather than none, but that's easy to fix by having a good label
for the line, I guess.

All in all it would be good to have that in pg_control.
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 20:10:43
Message-ID: 5271.1287691843@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Excerpts from Cdric Villemain's message of jue oct 21 16:01:30 -0300 2010:
>> I agree this is interesting information to get, but wonder how
>> pg_config can know that and it looks to me that this information as
>> nothing to do in pg_config....
>>
>> pg_config is all about installation, socket_dir is a postgresql.conf setting.

> Yeah -- how is pg_config to know? All it can tell you is what was the
> compiled-in default.

That's what I wanted, actually. If you've set a non-default value in
postgresql.conf, SHOW will tell you about that, but it fails to expose
the default value.

> Maybe you should go the SHOW route. The user could connect via TCP and
> find out the socket directory that way.

Yeah, the SHOW case is not useless by any means.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 20:19:42
Message-ID: AANLkTin6rBW2=B0zepiQ+DYbxdLEi1A=4Zj_8AgOU8mu@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2010/10/21 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>> Excerpts from Cédric Villemain's message of jue oct 21 16:01:30 -0300 2010:
>>> I agree this is interesting information to get, but wonder how
>>> pg_config can know that and it looks to me that this information as
>>> nothing to do in pg_config....
>>>
>>> pg_config is all about installation, socket_dir is a postgresql.conf setting.
>
>> Yeah -- how is pg_config to know?  All it can tell you is what was the
>> compiled-in default.
>
> That's what I wanted, actually.  If you've set a non-default value in
> postgresql.conf, SHOW will tell you about that, but it fails to expose
> the default value.
>
>> Maybe you should go the SHOW route.  The user could connect via TCP and
>> find out the socket directory that way.
>
> Yeah, the SHOW case is not useless by any means.

I think adding this to pg_config is sensible. Sure, the user could
have moved the socket directory. But it's a place to start looking.
So why not?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 20:31:50
Message-ID: B8D77661-C379-4A99-9A16-35702676E6F3@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Oct 21, 2010, at 4:19 PM, Robert Haas wrote:

> 2010/10/21 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>>> Excerpts from Cédric Villemain's message of jue oct 21 16:01:30 -0300 2010:
>>>> I agree this is interesting information to get, but wonder how
>>>> pg_config can know that and it looks to me that this information as
>>>> nothing to do in pg_config....
>>>>
>>>> pg_config is all about installation, socket_dir is a postgresql.conf setting.
>>
>>> Yeah -- how is pg_config to know? All it can tell you is what was the
>>> compiled-in default.
>>
>> That's what I wanted, actually. If you've set a non-default value in
>> postgresql.conf, SHOW will tell you about that, but it fails to expose
>> the default value.
>>
>>> Maybe you should go the SHOW route. The user could connect via TCP and
>>> find out the socket directory that way.
>>
>> Yeah, the SHOW case is not useless by any means.
>
> I think adding this to pg_config is sensible. Sure, the user could
> have moved the socket directory. But it's a place to start looking.
> So why not?

Because pg_config is supposed to return the current state of a cluster?
Because it might indicate a connection to the wrong server?

Cheers,
M


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-10-21 20:59:47
Message-ID: 6358.1287694787@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"A.M." <agentm(at)themactionfaction(dot)com> writes:
> On Oct 21, 2010, at 4:19 PM, Robert Haas wrote:
>> I think adding this to pg_config is sensible. Sure, the user could
>> have moved the socket directory. But it's a place to start looking.
>> So why not?

> Because pg_config is supposed to return the current state of a cluster?

pg_config is not supposed to do any such thing. It exists specifically
and solely to tell you about build options that were baked into the
compiled code.

Actually, the only reason this is even up for discussion is that there's
no configure option to set DEFAULT_PGSOCKET_DIR. If there were, and
debian were using it, then pg_config --configure would tell what I wish
to know. I thought for a bit about proposing we add such an option,
but given the current state of play it might be more misleading than
helpful: as long as distros are accustomed to changing this setting via
a patch, you couldn't trust pg_config --configure to tell you what a
given installation actually has compiled into it.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-11-11 06:38:20
Message-ID: 1289457500.31709.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tor, 2010-10-21 at 16:59 -0400, Tom Lane wrote:
> Actually, the only reason this is even up for discussion is that
> there's
> no configure option to set DEFAULT_PGSOCKET_DIR. If there were, and
> debian were using it, then pg_config --configure would tell what I
> wish
> to know. I thought for a bit about proposing we add such an option,
> but given the current state of play it might be more misleading than
> helpful: as long as distros are accustomed to changing this setting
> via
> a patch, you couldn't trust pg_config --configure to tell you what a
> given installation actually has compiled into it.

Presumably, if a configure option were added, they couldn't change it
via patch anymore. Of course, there will be a transition period, but
there will have to be one of some kind anyway.

Btw., a configure option for this was rejected years ago to discourage
people from actually changing the default.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-11-11 14:45:30
Message-ID: 13984.1289486730@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On tor, 2010-10-21 at 16:59 -0400, Tom Lane wrote:
>> Actually, the only reason this is even up for discussion is that
>> there's
>> no configure option to set DEFAULT_PGSOCKET_DIR. If there were, and
>> debian were using it, then pg_config --configure would tell what I
>> wish
>> to know. I thought for a bit about proposing we add such an option,
>> but given the current state of play it might be more misleading than
>> helpful: as long as distros are accustomed to changing this setting
>> via
>> a patch, you couldn't trust pg_config --configure to tell you what a
>> given installation actually has compiled into it.

> Presumably, if a configure option were added, they couldn't change it
> via patch anymore.

Hm, you're right: we'd remove the pg_config_manual.h entry, so the
existing patches would stop working, and presumably maintainers would
figure out that they ought to use the configure switch instead. So
that argument holds little water.

> Btw., a configure option for this was rejected years ago to discourage
> people from actually changing the default.

Yeah, I remember that discussion now that you mention it. It still
seems like a good policy ... but given that some popular packages are
changing the default whether we think it's a good idea or not, maybe
it's better to acknowledge that reality. We could still have some
text in the manual pointing out the compatibility hazards of using
the switch, I guess.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2010-11-12 03:01:10
Message-ID: 201011120301.oAC31A605588@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > On tor, 2010-10-21 at 16:59 -0400, Tom Lane wrote:
> >> Actually, the only reason this is even up for discussion is that
> >> there's
> >> no configure option to set DEFAULT_PGSOCKET_DIR. If there were, and
> >> debian were using it, then pg_config --configure would tell what I
> >> wish
> >> to know. I thought for a bit about proposing we add such an option,
> >> but given the current state of play it might be more misleading than
> >> helpful: as long as distros are accustomed to changing this setting
> >> via
> >> a patch, you couldn't trust pg_config --configure to tell you what a
> >> given installation actually has compiled into it.
>
> > Presumably, if a configure option were added, they couldn't change it
> > via patch anymore.
>
> Hm, you're right: we'd remove the pg_config_manual.h entry, so the
> existing patches would stop working, and presumably maintainers would
> figure out that they ought to use the configure switch instead. So
> that argument holds little water.
>
> > Btw., a configure option for this was rejected years ago to discourage
> > people from actually changing the default.
>
> Yeah, I remember that discussion now that you mention it. It still
> seems like a good policy ... but given that some popular packages are
> changing the default whether we think it's a good idea or not, maybe
> it's better to acknowledge that reality. We could still have some
> text in the manual pointing out the compatibility hazards of using
> the switch, I guess.

Might have been a nice change for 9.0. :-(

I don't think there is a great amount of defense that it should be in
/tmp except for backward compatibility, and for non-root installs. For
a package installer, I think moving it out of temp makes sense, hence a
configure flag.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Exposing an installation's default value of unix_socket_directory
Date: 2011-02-27 22:40:46
Message-ID: 201102272240.p1RMekt10034@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Added to TODO:

Allow simpler reporting of the unix domain socket directory and allow
easier configuration of its default location

* http://archives.postgresql.org/pgsql-hackers/2010-10/msg01555.php

---------------------------------------------------------------------------

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > On tor, 2010-10-21 at 16:59 -0400, Tom Lane wrote:
> >> Actually, the only reason this is even up for discussion is that
> >> there's
> >> no configure option to set DEFAULT_PGSOCKET_DIR. If there were, and
> >> debian were using it, then pg_config --configure would tell what I
> >> wish
> >> to know. I thought for a bit about proposing we add such an option,
> >> but given the current state of play it might be more misleading than
> >> helpful: as long as distros are accustomed to changing this setting
> >> via
> >> a patch, you couldn't trust pg_config --configure to tell you what a
> >> given installation actually has compiled into it.
>
> > Presumably, if a configure option were added, they couldn't change it
> > via patch anymore.
>
> Hm, you're right: we'd remove the pg_config_manual.h entry, so the
> existing patches would stop working, and presumably maintainers would
> figure out that they ought to use the configure switch instead. So
> that argument holds little water.
>
> > Btw., a configure option for this was rejected years ago to discourage
> > people from actually changing the default.
>
> Yeah, I remember that discussion now that you mention it. It still
> seems like a good policy ... but given that some popular packages are
> changing the default whether we think it's a good idea or not, maybe
> it's better to acknowledge that reality. We could still have some
> text in the manual pointing out the compatibility hazards of using
> the switch, I guess.
>
> regards, tom lane
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +