Subject: CIDR address in pg_hba.conf

From: Fujii Masao <[email-masked]>
Date: Tue, 7 Jun 2011 01:31:54 +0900

Hi,

http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html
> An IP address is specified in standard dotted decimal notation with
> a CIDR mask length. The mask length indicates the number of
> high-order bits of the client IP address that must match. Bits to the
> right of this must be zero in the given IP address.

Is the last statement correct? When I specified the following setting
in pg_hba.conf, I could not find any problem in PostgreSQL.

    host  all  all  192.168.1.99/24  trust

As far as I read the code, those bits seem not to need to be zero.
Attached patch just removes that statement.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
*** a/doc/src/sgml/client-auth.sgml
--- b/doc/src/sgml/client-auth.sgml
***************
*** 231,238 **** hostnossl  <replaceable>database</replaceable>  <replaceable>user</replaceable>
         An IP address is specified in standard dotted decimal
         notation with a <acronym>CIDR</> mask length.  The mask
         length indicates the number of high-order bits of the client
!        IP address that must match.  Bits to the right of this must
!        be zero in the given IP address.
         There must not be any white space between the IP address, the
         <literal>/</literal>, and the CIDR mask length.
        </para>
--- 231,237 ----
         An IP address is specified in standard dotted decimal
         notation with a <acronym>CIDR</> mask length.  The mask
         length indicates the number of high-order bits of the client
!        IP address that must match.
         There must not be any white space between the IP address, the
         <literal>/</literal>, and the CIDR mask length.
        </para>

---

From: Tom Lane <[email-masked]>
Date: Mon, 06 Jun 2011 12:56:25 -0400

> Attached patch just removes that statement.

Even if it happens to work that way at the moment, do we want to
encourage people to depend on such an implementation artifact?

IOW, if you read "must" as "if you want to trust it to work in future
versions, you must", the advice is perfectly sound.

			regards, tom lane

---

From: Fujii Masao <[email-masked]>
Date: Tue, 7 Jun 2011 02:27:34 +0900

> versions, you must", the advice is perfectly sound.

Okay. Sounds reasonable. I drop the patch.

Regards,

---

From: Bruce Momjian <[email-masked]>
Date: Thu, 9 Jun 2011 20:42:10 -0400 (EDT)

> versions, you must", the advice is perfectly sound.

Should we use "should"?

> >> right of this should be zero in the given IP address.

-- 
  Bruce Momjian  <[email-masked]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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

---

From: Robert Haas <[email-masked]>
Date: Mon, 13 Jun 2011 13:19:32 -0400

>> versions, you must", the advice is perfectly sound.

+1.

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

---

From: Bruce Momjian <[email-masked]>
Date: Mon, 13 Jun 2011 20:58:03 -0400 (EDT)

Robert Haas wrote:
> >> > ? ? host ?all ?all ?192.168.1.99/24 ?trust
> >>

Thanks for the feedback.  Patched in head and 9.1.