Re: PGSTAT: bind(2): Can't assign requested address - Mailing list pgsql-bugs

From Bjoern A. Zeeb
Subject Re: PGSTAT: bind(2): Can't assign requested address
Date
Msg-id 20060405135540.T76259@maildrop.int.zabbadoz.net
Whole thread Raw
In response to Re: PGSTAT: bind(2): Can't assign requested address  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: PGSTAT: bind(2): Can't assign requested address  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PGSTAT: bind(2): Can't assign requested address  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-bugs
On Fri, 7 Jun 2002, Bruce Momjian wrote:

Hi,

it's been some months so I left the fullquote attached.

> Well, you are the first to report that 127.0.0.1 doesn't work for stats.
> Unless someone else has a problem, I think we will leave it unchanged.


The last years this problem was disucced several times (mostly on
FreeBSD lists) for the reason of FreeBSD jails. I thought that we
had another mail in 2002 about that but couldn't find it anymore.

Anyway binding to 127.0.0.1 in a jail binds to the (usually public) IP
address of that jail which means the stats socket is basically open to
world (from the socket point of view).


Another problem (which is not a postgresql problem per se) is that if
the system is built without inet6 support or does not support inet6
(as in jails) but there is a ::1 localhost in /etc/hosts the error
messages gives a warning like:
     could not create socket for statistics collector:
     Protocol not supported
which sound annoying in first places until you find out that it worked
anyway and remember what cuases the warning.


Is there any reason why you explicitly disallow a posix local socket
at that point in backend/postmaster/pgstat.c:pgstat_init:

...
         for (addr = addrs; addr; addr = addr->ai_next)
         {
#ifdef HAVE_UNIX_SOCKETS
                 /* Ignore AF_UNIX sockets, if any are returned. */
                 if (addr->ai_family == AF_UNIX)
                         continue;
#endif
...


Couldn't you use/allow (if possible or configured) a posix local socket
or even use pipes for that?


Greetings
Bjoern A. Zeeb


> ---------------------------------------------------------------------------
>
> Bjoern A. Zeeb wrote:
>> PRIO: low
>>
>> Hi,
>>
>> in src/backend/postmaster/pgstat.c there is a hard coded bind to
>> 127.0.0.1 that fails if 127.0.0.1 is not configured on loopback
>> interface (e.g. administrator explicitly removed this IP).
>> This should _not_ be the case in normal setups.
>>
>> --- gmake check ---
>> ...
>> ============== creating temporary installation        ==============
>> ============== initializing database system           ==============
>> ============== starting postmaster                    ==============
>>
>> pg_regress: postmaster did not start
>> Examine ./log/postmaster.log for the reason.
>>
>> kill: 97857: No such process
>> rm regress.o
>> gmake[2]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test/regress'
>> gmake[1]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test'
>> % cat src/test/regress/log/postmaster.log
>> PGSTAT: bind(2): Can't assign requested address
>> --- snipp ---
>>
>> With postgresql-7.2.1 (and perhaps also earlier versions ?) this
>> prevents postmaster from starting if one does not configure
>>     'stats_start_collector = false'.
>> This works as a workaround.
>> One may also patch the sources and recompile of course.
>>
>> I have seen that there were changes in CVS already but the 127.0.0.1 is
>> still hard coded in there.
>>
>> I discovered that after playing with some routing daemons on my test
>> machine and therefor had removed 127.0.0.1. OS was FreeBSD 4.5-STABLE
>> but that shouldn't matter.

--
Bjoern A. Zeeb                bzeeb at Zabbadoz dot NeT

pgsql-bugs by date:

Previous
From: "Brock Peabody"
Date:
Subject: Re: BUG #2371: database crashes with semctl failed error
Next
From: Tom Lane
Date:
Subject: Re: BUG #2371: database crashes with semctl failed error