Re: 7.4.3 & 8.0.0beta1 + Solaris 9: default pg_hba.conf - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: 7.4.3 & 8.0.0beta1 + Solaris 9: default pg_hba.conf
Date
Msg-id 41238C9D.9050000@dunslane.net
Whole thread Raw
In response to Re: 7.4.3 & 8.0.0beta1 + Solaris 9: default pg_hba.conf breaks  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: 7.4.3 & 8.0.0beta1 + Solaris 9: default pg_hba.conf breaks
List pgsql-hackers

Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>  
>
>>>Seems unlikely.  I suppose you could argue that we shouldn't be using
>>>getaddrinfo on the netmask field at all; there's certainly not any value
>>>in doing a DNS lookup on it, for instance.  Maybe we should go back to
>>>using plain ol' inet_aton for it?  (Nah, won't handle IPv6...)
>>>      
>>>
>
>  
>
>>We could do it if we tested the addr.ai_family first, and only did it in 
>>the IPv4 case. I agree calling getaddrinfo is overkill for masks.
>>    
>>
>
>Huh?  The reason we're using getaddrinfo in the first place is we don't
>*know* whether we've got an IPv4 or IPv6 string ...
>
>
>  
>

We know the address family - in fact we pass it to SockAddr_cidr_mask(). 
It's only the family of the mask that we don't know. But they had better 
be the same, of course. See hba.c around line 753:
       if (cidr_slash)       {           if (SockAddr_cidr_mask(&mask, cidr_slash + 1, 
addr.ss_family) < 0)               goto hba_syntax;       }       else       {           /* Read the mask field. */
     line_item = lnext(line_item);           if (!line_item)               goto hba_syntax;           token =
lfirst(line_item);
           ret = getaddrinfo_all(token, NULL, &hints, &gai_result);

cheers

andrew


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 8.0 libpq: missing get_home_path()
Next
From: Bruce Momjian
Date:
Subject: Re: 8.0 libpq: missing get_home_path()